版本:0.6.0 beta 3
我试图以各种方式使dompdf设置页面的边距。我的页面很长,有很多文字,分成了章节......
我的CSS大致如下:
#wrapper{
padding:8px;
}
/* other styles... */
@page{margin: 0.2in 0.5in 0.2in 0.5in;}
当 PHP 时
<?php
ob_start(); // begin collecting output
include 'makemypdf.php'; // this page output the html
$html = ob_get_clean(); // retrieve output from makemypdf.php and stop buffering
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf", array("Attachment" => false));
?>
但是我得到的页面没有边距!!! 只有 #wrapper 的填充被应用...而且它们仅在整个PDF的开头和结尾处应用... 我做错了什么吗?PS-似乎只应用了底部边距...但我不确定...PPS-我也尝试了这个CSS,但没有成功:body {margin-top:40px;}html {margin-top:40px;}@page {margin-top:40px;}
<tag style="margin: 0.2in 0.5in 0.2in 0.5in;"></tag>
替换为<body style="margin: 0.2in 0.5in 0.2in 0.5in;"></body>
。 - Alsemany