我正在將基本HTML加載到DOMPDF中。在橫向模式下,第一個之後的所有頁面重疊。DOMPDF橫向輸出搞砸了
這裏是我的(基本)HTML這使得在瀏覽器罰款:
<div id="certificates-layout-1" style="<?php echo $styles['outer-container']; ?>">
<div style="<?php echo $styles['inner-container']; ?>">
<div style="<?php echo $styles['fullname']; ?>">
<?php echo $data['fullname']; ?>
</div>
<div style="<?php echo $styles['fullcouncil']; ?>">
<?php echo $data['fullcouncil']; ?>
</div>
<div style="<?php echo $styles['session_date']; ?>">
<?php echo $data['session_date']; ?>
</div>
</div>
</div>
這裏是我DOMPDF繪製邏輯:
$filename = (isset($params['filename'])) ? $params['filename'] : 'ubcdet_report_' . date('YmdHis') . '.pdf';
$lib = $_SERVER['DOCUMENT_ROOT'] . '/sites/all/libraries/vendor/';
require_once($lib . "dompdf/dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($report);
$dompdf->set_paper('letter', 'landscape');
$dompdf->render();
$dompdf->stream($filename, array("Attachment" => false));
exit(0);
我用A4紙嘗試爲好,同樣的結果。
我也試着在設置紙張之前移動渲染(),重疊的問題消失了,但它只會渲染爲肖像(此處嘗試A4)。
我還沒有嘗試輸出作爲實際的文件之前呈現在瀏覽器下載,但我會。
這是個什麼結果看起來像......
任何建議表示讚賞。謝謝。
====================================
UPDATE每請求從BrianS
感謝您的關注。這裏是呈現的HTML轉儲:
<html>
<head></head>
<body>
<div id="certificates-layout-1" style="font-family: Times New Roman; font-size:33px; text-align:center; page-break-after:auto;">
<div style="height:672px; width: 906px; border: thin solid #666666;">
<div style="font-size:45px; font-weight:bold; margin-top:96px; margin-bottom:10px;">John Smith</div>
<div style="margin-bottom:125px;">Council of Councils</div>
<div style="font-weight:bold;">April 16 - 19, 2015</div>
</div>
</div>
<style>
@font-face {
font-family: TimesBold;
src: url('/sites/all/modules/ubcdet/ubcdet_report/fonts/timesbd.ttf');
}
</style>
<style>
}
@page {
margin: 0;
}
html {
margin: 72px 76px;
}
body {
width: 1056px;
margin:0;
}
.hint {
background: none repeat scroll 0 0 #6AEA91;
font-size: 13px;
padding: 50px 10px;
text-align: center;
width: 250px;
position: absolute;
}
@media print {
.hint {
display:none;
}
}
</style>
</body>
</html>
我不認爲那裏有什麼不尋常的東西,但也許我錯了。讓我知道你是否需要額外的信息。謝謝。
這是一個很奇怪的問題。它看起來像HTML或CSS中的某些內容正在破壞dompdf的佈局跟蹤。但是如果沒有看到導致問題的示例文檔(HTML和CSS)(而不是生成文檔的PHP),我們無法真正進行調試。 – BrianS