分页(或表格分隔?)以获得格式良好的 PDF

发布于 2024-08-25 12:44:11 字数 211 浏览 6 评论 0原文

我在 CakePHP 上开发了一个内部网,其中一部分使用 DOMPDF 生成自定义 PDF。问题是我有一个备注字段(mysql 文本),在从 PHP nl2br 函数获取结果后打印该字段。

问题是,在某些情况下,此文本太长(即使在字体大小:6px 上),我需要某种方法来进行分页(再次获取页眉和页脚等)...或者也许是一个不错的方法获得第二列以继续其中的文本。

有什么想法吗?

I had develop an intranet on CakePHP which in one part generates a custom PDF using DOMPDF. The problem is that I have a memo field (mysql text) which I print after getting the result from PHP nl2br function.

The problems is that in some occasions, this text is too long (even on font-size: 6px) and I need some way to make a page break (get again de header, and footer etc)... or maybe a nice way to get a second column to continue with the text inside.

any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灼痛 2024-09-01 12:44:11

从 Google 获取此信息,http://www.digitaljunkies.ca/dompdf/faq.php #page_break。然而,它并没有解决有关重复页眉和页脚的次要问题。类似于 http://www.xefteri.com/articles/show.cfm? id=26 可能会有所帮助(不推荐)。

Got this from Google, http://www.digitaljunkies.ca/dompdf/faq.php#page_break . It doesn't solve the secondary question regarding the repeated header and footer, however. Something like http://www.xefteri.com/articles/show.cfm?id=26 might help with that (not recommended).

反差帅 2024-09-01 12:44:11

您的标题是否位于备注字段周围?如果是这样,您可以将备注字段放在表格中,并使用 thead/tfoot 部分作为页眉/页脚。当表格移动到第二页时,它应该再次显示(尽管我相信 tfoot 处理存在问题)。

如果这些是文档范围的页眉和页脚,您可以使用内联 PHP(另请参阅常见问题解答)。或者,如果您使用的是最新版本(0.6.0 alpha 2)并且准备修补,您可以添加固定定位支持并使用它来创建页眉/页脚。

有关详细信息,请参阅 DOMPDF 开发者网站

如果您有示例文档,可能会更容易直观地了解问题。

Is your header just around the memo field? If so you can put your memo field in a table and use a thead/tfoot section for the header/footer. When the table moves to the second page it should be displayed again (though I believe there are problems with tfoot handling).

If these are document-wide headers and footers you could use inline PHP (see also the FAQ). Or, if you're using the latest release (0.6.0 alpha 2) and are up to patching you could add fixed positioning support and use that to create a header/footer.

See the DOMPDF developer site for more information.

If you have a sample document it might be easier to visualize the problem.

倒带 2024-09-01 12:44:11

您可以通过两种方式做到这一点

,其中一种是使用节,在分页符上,dompdf 将重复标题。您可以使用 CSS 属性 page-break-before:always 强制分页

第二个选项是使用 PHP 使用 $pdf->page_text() 函数绘制页眉/页脚,如下所示
http://www.digitaljunkies.ca/dompdf/faq.php#footers

You can do it in two ways

One of them is using a section, on pagebreaks, dompdf will repeat the header. You can force a pagebreak using CSS attribute page-break-before:always

The second option is using PHP to draw the header/footer using $pdf->page_text() function like this
http://www.digitaljunkies.ca/dompdf/faq.php#footers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文