2012-02-01 280 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; 

不圆其关闭。即使有小数点,也使用精确转换。

希望这个答案能解决你的问题。