我有一个非常简单的页面,显示了许多部分。每个部分都有一个标题,然后是一些子弹。我想这样做,如果整个部分不适合页面,那么它将移动到下一页。
为了达到这个目的,我已将每个部分包装在div元素中,如此...
<div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'>
我得到的结果是子弹不会在内部破坏(这是好的)但是节标头不会留在子弹中(这是坏的)。
非常感谢任何可以提供的帮助。
这是我正在使用的PHP代码:
$html = "<html><head></head><body>";
$result = mysql_query("SELECT comment from comments");
while ($row = mysql_fetch_array($result)) {
$html .= "<div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'>\n";
$html .= $row['comment'] . "\n";
$html .= "</div>\n";
}
$html .= "\n</body></html>";
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$output = $dompdf->output();
$dompdf->stream("$filename.pdf");
以下是生成的HTML:
<html><head></head><body><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">BID VALIDITY:<br></span><ul><li>This ACME Painting proposal is valid until ------</li></ul><p><br></p></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">ENGINEERING NOTES:</span><br><ul><li>Vessel to be designed to include 100% Radiography of Long & Girth seams per ASME prior to PWHT</li><li>All back gouge / root welds shall undergo MPT (Magnetic Particle Testing)</li><li>All external welds shall undergo MPT after fabrication</li><li>All nozzles subject to 100% ultrasonic inspection, Cat. D joints.<br></li></ul></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">HEALTH & SAFETY:<br></span><ul><li>The goal of this project is to treat safety and welfare of each employee as the number one priority.</li><li>Project target is ZERO recordable injuries.</li></ul><p><br></p></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">OVERTIME RATES FOR EXPEDITED DELIVERY:<br><br>Premium - Time + One Half<br></span><ul><li>Time and one half hour pay shall be for all hours Monday - Friday (Day Shift) when employee exceeds 8.5 hours in one day.<br></li><li>Time and one half hour pay shall be paid for the first two hours beyond 8.5 hours.</li><li>Rate: $60/hr (CDN)</li></ul><p><br></p><p><span style="font-weight: bold;">Premium - Double Time</span><br><ul><li>Double time pay shall be for all hours Monday - Friday (Day Shift) when employee exceeds 10.5 hours in one day.</li><li>Double time pay shall be for all hours Monday - Thursday (Night Shift) when employee exceeds 10 hours in one day.</li><li>Double time pay shall be for all weekend hours Saturday - Sunday (Day Shift).</li><li>Double time pay shall be for all weekend hours Friday - Sunday (Night Shift).<br></li><li>Rate: $100/hr (CDN)</li></ul><br></p></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">DRAWING AND DOCUMENT DELIVERY:<br></span><ul><li>Drawing and Engineering documents to be submitted starting in 2-3 weeks after receipt of order.<br></li><li>Welding and NDE procedures and related shall be submitted 2-3 weeks after receipt of order.<br></li><li>Drawings and Engineering documents shall be returned to HWE 7 working days after submission.</li></ul><p><br></p></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">FABRICATION DELIVERY:<br></span><ul><li>Final fabrication will ship 10-12 weeks after receipt of Major Material and Fully Approved Drawings</li></ul><p><br></p></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">ENGINEERING NOTES:</span><br><ul><li>Vessel to be designed to include 100% Radiography of Long & Girth seams per ASME prior to PWHT</li><li>All back gouge / root welds shall undergo MPT (Magnetic Particle Testing)</li><li>All external welds shall undergo MPT after fabrication</li><li>All nozzles subject to 100% ultrasonic inspection, Cat. D joints.<br></li></ul></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">DELIVERY NOTES:</span><br><ul><li>Material delivery subject to review of Mill lead time and confirmation of delivery at time of order entry at Mill</li><li>ACME Painting Enterprises Limited will not accept responsibility or liquidated damages / contractual impact for delays at Mill or by Origin Material manufacturer</li><li>Fabrication and Delivery subject to review of shop loading at time of order<br></li></ul></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">DRAWING AND DOCUMENT DELIVERY:<br></span><ul><li>Drawing and Engineering documents to be submitted starting in 2-3 weeks after receipt of order.<br></li><li>Welding and NDE procedures and related shall be submitted 2-3 weeks after receipt of order.<br></li><li>Drawings and Engineering documents shall be returned to HWE 7 working days after submission.</li></ul><p><br></p></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">FABRICATION DELIVERY:<br></span><ul><li>Final fabrication will ship 10-12 weeks after receipt of Major Material and Fully Approved Drawings</li></ul><p><br></p></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">ENGINEERING NOTES:</span><br><ul><li>Vessel to be designed to include 100% Radiography of Long & Girth seams per ASME prior to PWHT</li><li>All back gouge / root welds shall undergo MPT (Magnetic Particle Testing)</li><li>All external welds shall undergo MPT after fabrication</li><li>All nozzles subject to 100% ultrasonic inspection, Cat. D joints.<br></li></ul></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">DELIVERY NOTES:</span><br><ul><li>Material delivery subject to review of Mill lead time and confirmation of delivery at time of order entry at Mill</li><li>ACME Painting Enterprises Limited will not accept responsibility or liquidated damages / contractual impact for delays at Mill or by Origin Material manufacturer</li><li>Fabrication and Delivery subject to review of shop loading at time of order<br></li></ul></div><div style='page-break-inside:avoid; break-inside: avoid; -webkit-column-break-inside: avoid;'><span style="font-weight: bold;">ENGINEERING NOTES:</span><br><ul><li>Vessel to be designed to include 100% Radiography of Long & Girth seams per ASME prior to PWHT</li><li>All back gouge / root welds shall undergo MPT (Magnetic Particle Testing)</li><li>All external welds shall undergo MPT after fabrication</li><li>All nozzles subject to 100% ultrasonic inspection, Cat. D joints.<br></li></ul></div></body></html>
最后,我已经包含了生成的分页符的屏幕截图...
答案 0 :(得分:1)
在v0.6.1中,这似乎是与该功能相关的一些错误行为。因为您没有将文本包含在块级元素中,所以dompdf似乎无法跟踪它以便流向下一页(对该问题的第一次猜测)。修复似乎是将该文本包装在块级元素中。
您提供的代码示例似乎无法解决问题,但您想尝试瞄准的目标是:
<div class='c2'>
<p><span class="c1">DRAWING AND DOCUMENT DELIVERY:</span></p>
<ul>
<li>Drawing and Engineering documents to be submitted starting in 2-3 weeks after receipt of order.<br></li>
<li>Welding and NDE procedures and related shall be submitted 2-3 weeks after receipt of order.<br></li>
<li>Drawings and Engineering documents shall be returned to HWE 7 working days after submission.</li>
</ul>
<p><br></p>
</div>