0

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?

Kizaru
  • 2,443
  • 3
  • 24
  • 39

2 Answers2

0

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.

Kizaru
  • 2,443
  • 3
  • 24
  • 39
0

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"
HHenn
  • 309
  • 3
  • 4