我使用PHP & pdf来生成pdf,我要做的是生成一个files.But内容大小为pageSize (宽/高)的pdf文件。我如何才能做到这一点?
我的html内容是:
<page format="432x240" orientation="L" backcolor="#FFFFFF" style="font: arial;">
<div class="image">
<span class="firstname">$fname</span>
<span class="lastname">$lname</span>
</div>
图像的css类是:
position: relative;width: 100%; /* for IE 6 */ background-image: url(../img/test.png);height: 240px; width: 432px;top: 50%;我的PHP代码是:
$html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8', 0);
$html2pdf->pdf->SetDisplayMode('fullpage');
$contentTpl = $this->renderPartial('template_01', array('fname' => $firstname, 'lname' => $lastname), true);
$html2pdf->writeHTML(utf8_encode($contentTpl));发布于 2013-12-27 11:30:02
下面是这个问题的解决方案:
$html2pdf = new HTML2PDF('P', array($width_in_mm,$height_in_mm), 'en', true, 'UTF-8', array(0, 0, 0, 0));宽度和高度应以毫米为单位。如果您使用英寸,请将其转换为毫米。
公式:
$width_in_mm = $width_in_inches * 25.4;
$height_in_mm = $height_in_inches * 25.4;不要四舍五入。使用了精确转换,即使它有小数点。
希望这个答案能解决你的问题。
https://stackoverflow.com/questions/18467783
复制相似问题