php 如果元素超过页面高度,dompdf 分页符?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8723487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 05:21:37  来源:igfitidea点击:

dompdf Page break if element is exceeding page height?

phppdf-generationdompdf

提问by startupsmith

What is the best way to do page breaks in dompdf?

在 dompdf 中进行分页的最佳方法是什么?

I have had a look hereat the page-break-before css attribute, but it didn't work when I did:

我在这里查看了 page-break-before css 属性,但是当我这样做时它不起作用:

table {page-break-before:auto;}

The page still breaks in the middle of my table.

页面仍然在我的桌子中间断裂。

Is it possible to setup my html/css so that the page will break before the element if the element is going to exceed the page height?

如果元素将超过页面高度,是否可以设置我的 html/css 以便页面会在元素之前中断?

Ideally I would like to divide my html up in to div sections so that each section will start on a new page if it is going to exceed the height of the current page.

理想情况下,我想将我的 html 分成 div 部分,以便每个部分都将在新页面上开始,如果它会超过当前页面的高度。

回答by BrianS

Using page-break-inside: auto;basically says to dompdf "do what you would normally do when breaking pages."

使用page-break-inside: auto;基本上对 dompdf 说“做你通常在断页时会做的事情”。

To force a page break before / after your table you would use page-break-before: always;/ page-break-after: always;.

要在表格之前/之后强制分页,您可以使用page-break-before: always;/ page-break-after: always;

To ask dompdf to avoid breaking inside an element you would use page-break-inside: avoid;.

要要求 dompdf 避免在元素内部中断,您将使用page-break-inside: avoid;.

回答by andreas-supersmart

You might make quick tests with this online debugger- i finally found my pagebreak and margin issue after days of testing.

您可以使用这个在线调试器进行快速测试- 经过几天的测试,我终于发现了我的分页和边距问题。

Excursus: Did anyone install a debug environment on the development/production environment and can point me to any documentation or tutorial?

附注:是否有人在开发/生产环境中安装了调试环境,并且可以向我指出任何文档或教程?

回答by KarinG - Semper IT

Here's a trick: place the <table>you do NOT want to print across multiple pages in another <table>.

这是一个技巧:将<table>您不想在多个页面上打印的内容放在另一个<table>.

回答by Viraj Amarasinghe

In my case it was happened since I have used a table inside another table. Like,

就我而言,这是因为我在另一张桌子内使用了一张桌子。喜欢,

<table>
   <tr>
      <td>
         <table></table>
      </td>
   </tr>
 </table>

So I did was getting the table out. Solved my issue.

所以我确实把桌子拿出来了。解决了我的问题。