【问题标题】:php mpdf increase the size of the pdfphp mpdf 增加pdf的大小
【发布时间】:2017-01-17 14:10:27
【问题描述】:

附加的图像是我通过单击包含使用 MPDf 库的特定 php 文件自动生成的 pdf 文档, 任何人都可以帮助我如何增加文本的大小并使其清晰可见,这是我的代码以便转换为 pdf 提前谢谢。

<?php 

require("mpdf60/mpdf.php");
$mpdf=new mPDF('utf-8','A3-L');//A4 page in portrait for landscape add -L.
$mpdf->debug = true;
$mpdf->allow_output_buffering = true;
//$mpdf->SetHeader('|Your Header here|');
//$mpdf->setFooter('{PAGENO}');// Giving page number to your footer.
//$mpdf->useOnlyCoreFonts = true;    // false is default
$mpdf->SetDisplayMode('fullpage');
// Buffer the following html with PHP so we can store it to a variable later
ob_start();
?>
<?php 

include_once "viewcomp.php";
 //This is your php page ?>
<?php 
$html = ob_get_contents();
ob_end_clean();
// send the captured HTML from the output buffer to the mPDF class for processing
$mpdf->WriteHTML($html);
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password.
$mpdf->Output();
exit;
?>

【问题讨论】:

  • 您阅读文档了吗?
  • 是的,我做到了,但我找不到任何解决方案...?

标签: mpdf


【解决方案1】:

mPDF 使用自动调整表格大小,除其他外,这也会影响字体大小。使用 mPDF 输出表格时需要设置:

<table style="overflow: wrap">

根据这个answer在每张桌子上。

您可以通过$mpdf-&gt;SetFontSize(6); 设置字体大小,这里的字体大小以点(pt)为单位。或者您可以使用 mpdf 函数 SetDefaultFontSize() 设置默认字体大小。根据 MPDF 文档,SetDefaultFontSize() 已弃用但仍然可用。另一种选择是编辑 mpdf 默认样式表(mpdf.css)。

希望对你有帮助

【讨论】:

    【解决方案2】:

    请使用

    $mpdf->keep_table_proportions = false;
    

    【讨论】:

    • 欢迎来到 Stack Overflow!虽然这段代码可能会回答这个问题,但最好包括对问题的描述,以及您的代码将如何解决给定的问题。对于未来,这里有一些信息,how to crack a awesome answer 在 Stack Overflow 上。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    • 1970-01-01
    相关资源
    最近更新 更多