WPF FlowDocument 目录

发布于 2024-09-30 17:46:37 字数 293 浏览 1 评论 0原文

我有一个生成相当长的 FlowDocument 的应用程序。它使用“自定义”分页器在打印时将页眉和页脚包裹在每个页面周围。此外,每一页都包含一个或多个“副标题”。

我希望它还能自动为此文档创建一个目录,显示每个页面上出现的副标题。

麻烦就在这里。我不知道每页上会出现什么副标题,直到我打印文档并通过分页器,将文档分成几页。但到那时,一切都已简化为视觉效果,并且似乎不再包含有关我放入文档中的实际对象的任何相关信息(因此我无法读取任何标签属性,甚至内容)。

有谁有任何聪明的方法可以让我在打印期间/之前确定每页上出现哪些项目?

I've got an application that generates a fairly long FlowDocument. It uses a "custom" paginator to wrap a header and footer around each page when printed. In addition, each page contains one or more "subheadings".

I would like to have it also automatically create a table of contents for this document, showing what subheadings appeared on each page.

Here's the trouble. I don't know what subheadings appear on each page until I print the document and it passes through the paginator, which breaks the document into pages. But by that time, everything has been reduced to Visuals and seems to no longer contain any relevant information about the actual objects that I put in the document (so I can't read any Tag properties or even the content).

Does anyone have any clever ways that I could determine during/before printing what items appear on each page?

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

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

发布评论

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

评论(1

梦太阳 2024-10-07 17:46:37

我这样做的方法是使用我的 辅助类。为目录留出空间,否则您可以在之后重新整理整个内容。当我添加每个项目时,我知道它位于哪个页面,因此我可以在之后生成一个目录。固定文档非常容易生成和打印。

The way I've done this is to create a FixedDocument instead of a FlowDocument, with my helper class. Leave room for the TOC or you can re-flow the whole thing afterwards. As I add each item I know which page it's on, so I can generate a TOC afterwards. FixedDocuments are very easy to generate and print.

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