在 WPF FlowDocument 中实现脚注

发布于 2024-09-06 18:05:06 字数 520 浏览 2 评论 0 原文

在 FlowDocumentPageViewer 中显示 FlowDocument 内容脚注的最佳方法是什么?

我的第一个想法是让脚注内容紧跟在 FlowDocument 中的脚注锚点之后,并将脚注内容格式化为图形,并将 VerticalAnchor 设置为 PageBottom。

这很有效,但是当页面上有多个脚注时,脚注会以相反的顺序堆叠,即第一个脚注一直位于底部,后续脚注堆叠在其顶部。

这种方法的另一个困难是不允许长脚注跨页,因为图不允许这样做。

更极端的方法是反向执行相同的操作 - 将常规文本格式化为堆叠图形,并将 VerticalAnchor 设置为 PageTop,并让脚注在底部流动。但是,段落(往往比脚注长)现在不会跨页。

我还可以尝试哪些其他方法?

理想情况下,我想显示脚注,因为它们会出现在印刷品中(即在它们相关的页面底部),但我愿意接受其他方法。

这是针对专业学术内容的阅读器应用程序,其中长而频繁的脚注是常态,应该成为阅读体验的一部分。因此,我不想使用尾注,而更喜欢在每页底部显示脚注。

What would be the best approach to display footnotes for FlowDocument content in a FlowDocumentPageViewer?

My first thought was to have the contents of the footnote follow immediately after the footnote anchor within the FlowDocument, with the footnote content formatted as a Figure with VerticalAnchor set to PageBottom.

This works great, but when there are multiple footnotes on a page, the footnotes are stacked in reverse order, i.e. the first footnote is all the way on the bottom, with subsequent footnotes being stacked on top of it.

Another difficulty with this approach is that long footnotes will not be allowed to span pages, as Figure does not allow that.

A more extreme approach would be to do the same in reverse - format the regular text as stacked figures with VerticalAnchor set to PageTop, and let the footnotes flow on the bottom. However, paragraphs (which tend to be longer than footnotes) will now not span pages.

What other approaches can I try?

Ideally I would like to display the footnotes as they would appear in print (i.e. on the bottom of the page they are relevant to), but I am open to other approaches.

This is for a reader app for specialized academic content, where long and frequent footnotes are the norm and should be part of the reading experience. For this reason I do not want to use endnotes, and prefer footnotes displayed on the bottom of each page.

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

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

发布评论

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

评论(1

爱格式化 2024-09-13 18:05:06

我花了一段时间研究这个问题,并且不得不同意似乎没有一种“又好又简单”的方法来做到这一点。

我尝试从 Floater 和 Figure 类派生我自己的包装器类,但它很快就会变得非常复杂,因为分页是可怕的(至少对我来说)。这些的问题在于,Figure 允许自己锚定到 XAML 中的父级,而 Floater 具有您需要的所有不错的功能 - 比如分页 - 但它不能锚定在任何地方......确实有点像第 22 条军规,即使在 .NET 4.0 中也是如此。

我找到了两个链接 此处这里可能会有所帮助。第一个乍一看可能有点无关紧要,但看看代码,你应该明白了)我尝试了代码,总体思路是有效的。它围绕 DocumentPaginator 定义了一个包装类,因此允许您控制实际的分页。

无论如何,希望这能有所帮助。

I spent a while looking at this and have to agree that there doesn't seem to be a "nice and easy" way of doing it.

I tried deriving my own wrapper classes from the Floater and Figure classes but it gets very convoluted very quickly as pagination is horrid (at least for me) to work out. The problem with these is that the Figure allows itself to be anchored to a parent in XAML, whereas the Floater has all the nice functionality you need - like pagination - but it can't be anchored anywhere... bit of a Catch 22 really, even in .NET 4.0.

I found two links here and here that might help. The first one may seem a bit irrelevant at first glance but have a look at the code and you should get the idea) I played around with the code and the general idea works. It defines a wrapper class around the DocumentPaginator and therefore allows you to control the actual pagination.

Hopefully that helps a bit anyway.

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