4
我正在使用PHP & HTML2PDF庫來生成PDF文件。但我想要做的是生成一個PDF文件的頁面大小(寬度/高度)作爲HTML內容大小。我怎樣才能做到這一點?HTML2PDF頁面大小
我的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));
請檢查這個http://stackoverflow.com/questions/15546019/how-to-change-height-and-width-manually-of-pdf-by-using-html2pdf-in-php –