2012-02-01 279 views
0

我有HTML2PDF工作很好的PDF附加到電子郵件 但是頁面,我需要調整網頁寬度以606px 我可以在HTML做到這一點,但HTML是606px和PDF本身是portait中的標準字母寬度。 有沒有辦法將文檔壓縮到我需要的寬度? 感謝名單HTML2PDF調整大小

馬克

+0

AFAICT你不能用HTML2PDF做到這一點,但你可以使用mPDF http://mpdf1.com。 – adamors 2012-04-05 09:50:47

回答

0

構造HTML2PDF類的

public function __construct($orientation = 'P', $format = 'A4', $langue='fr', $unicode=true, $encoding='UTF-8', $marges = array(5, 5, 5, 8)) 
{ 

定義頁面大小

$format =array('user_defined_height','user_defined_width'); //for user-defined sizes accepts only in millimeter 

在你的情況 606px =160.3375毫米

$格式=陣列調整$格式變量( '160.3375', '160.3375');

2

下面是該問題的解決方案:

$html2pdf = new HTML2PDF('P', array($width_in_mm,$height_in_mm), 'en', true, 'UTF-8', array(0, 0, 0, 0)); 

高度和寬度應該是MM。如果您使用英寸將其轉換爲MM。

公式:

$width_in_mm = $width_in_inches * 25.4; 
$height_in_mm = $height_in_inches * 25.4; 

不圓其關閉。即使有小數點,也使用精確轉換。

希望這個答案能解決你的問題。