DocumentViewer 的 DocumentMap/目录,以及通过名称或链接号调用 XPS 文档的超链接

发布于 2024-09-10 20:19:01 字数 373 浏览 5 评论 0原文

我有带有标题书签的 XPS 文件。如果您在 Word 中打开源文档并转到“查看”->“文档结构图”,您会在左侧看到所有书签。是否有可能在 DocumentViewer 中获得相同的功能,就像在某种 PDF 阅读器中使用 PDF 文档一样?

此外,RequestNavigateEventHandler 显示 XPS 文档中的每个超链接/书签都有一个特定的 Uri,类似于“C:\my path\to\file.xps#PG_N_LNK_X”,其中 X 是链接的唯一编号,N 是链接的唯一编号。页码。我想找出一种通过标题调用书签的方法。例如,如果我有一个名为“主屏幕”的部分,位于 XPS 文件的第 8 页,则该书签的 Uri 将以类似 #PG_8_LNK_3 的形式结尾。我可以从书签标题中获取该 Uri 吗?

I have XPS files with header bookmarks. If you open the source document in Word and go to view->Document Map, you see all of the bookmarks on the left. Is it possible to get this same functionality in DocumentViewer, like you would get with a PDF document in some sort of PDF reader?

Also, the RequestNavigateEventHandler shows that each hyperlink/bookmark in an XPS document has a specific Uri which is something like "C:\my path\to\file.xps#PG_N_LNK_X" where X is a unique number for the link and N is the page number. I would like to figure out a way to call a bookmark by its heading. For example, if I had a section called "Main Screen" which was on page 8 of the XPS File, the Uri for that bookmark would end something like #PG_8_LNK_3. Is it possible for me to get that Uri from the Bookmark Heading?

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

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

发布评论

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

评论(2

假扮的天使 2024-09-17 20:19:01

对于那些想知道的人来说,XPS 文档只是 Z​​IP 文件。解压缩 zip 并解析 XML 文件 \Documents\1\DocStructure.Struct 以获取大纲条目。

For those wondering, XPS documents are simply ZIP files. Extract the zip and parse the XML file \Documents\1\DocStructure.Struct for the outline entries.

负佳期 2024-09-17 20:19:01

看一下:

如何在指定书签中打开 XPS

最后一个答案中的方法“GetBookmarks”从 XPS 文件中提取书签。方法“GotoBookmarkElement”导航到书签。

可以通过设置 Frame.Source 属性来更快地导航到书签:

DocFrame.Source = new Uri(string.Format("pack://file:,,,{0}/FixedDocSeq.fdseq#{1}", _filePath.Replace('\\', ','), bookmark.Name));

Uri 构造函数的输入字符串如下所示:

"pack://file:,,,C:,temp,Help,Manual.xps/FixedDocSeq.fdseq#PG_6_LNK_380"

对于位于以下位置的文件:

"C:\\temp\\Help\\Manual.xps"

Take a look at:

How to open a XPS in a specified bookmarks

The method "GetBookmarks" in the last answer extracts the bookmarks from the XPS-File. The method "GotoBookmarkElement" navigates to the bookmark.

A faster way to navigate to the bookmark could be done by setting the Frame.Source property:

DocFrame.Source = new Uri(string.Format("pack://file:,,,{0}/FixedDocSeq.fdseq#{1}", _filePath.Replace('\\', ','), bookmark.Name));

The input string for the Uri-Constructor look´s like:

"pack://file:,,,C:,temp,Help,Manual.xps/FixedDocSeq.fdseq#PG_6_LNK_380"

for a file which is located in:

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