Get/Set Bookmarks

<< Click to Display Table of Contents >>

Navigation:  Commands >

Get/Set Bookmarks

Bookmarks or Outlines are optionally displayed in a treeview on the left panel (see Configuration).

 

WPViewPDF also allows it to extract the bookmark list as XML. To do so, the command COMPDF_GetBookmarkXML = 351 can be used. It expects a string and an integer parameter.

 

COMPDF_GetBookmarkXML will always extract the original bookmark structure of the PDF, not the information which was previously set with COMPDF_SetBookmarkXML.

 

The XML structure is very easy. Each branch is using the tag <outline>. If the branch has children, they are enclosed inside of <outline>...</outline>, if not, the tag is closed "<outline/>".

 

This parameters are used by <outline>:

Title: The displayed Text

Dest: Optional, a named destination

pid: The internal page ID

pnr: The page number (not used if "Dest" was used)

X: The X coordinate, may be 0

Z: The zoomvalue, may be 0

Y: The Y coordinate in 72 dpi. Usually top is 0

 

Example:

<?xml version="1.0" encoding="utf-8"?>

<File id="1" name="WPViewPDFV3.pdf">

 <Outline Title="Introduction" pid="7" pnr="4" X="57" Y="85" Z="0">

  <Outline Title="WPViewPDF Standard" pid="9" pnr="6" X="57" Y="269" Z="0"/>

  <Outline Title="WPViewPDF PLUS" pid="9" pnr="6" X="57" Y="425" Z="0"/>

  <Outline Title="Example Projects" pid="10" pnr="7" X="57" Y="85" Z="0">

   <Outline Title=".NET C# Example: PDFViewNET" pid="10" pnr="7" X="57" Y="111" Z="0"/>

   <Outline Title="Delphi: PDFView" pid="12" pnr="9" X="57" Y="462" Z="0"/>

   <Outline Title="Delphi: PDF to Bitmap" pid="16" pnr="13" X="57" Y="85" Z="0"/>

   <Outline Title="Delphi: Add graphics to PDF" pid="17" pnr="14" X="57" Y="430" Z="0"/>

   </Outline>

 </Outline>

<Outline Title="Installation" pid="19" pnr="16" X="57" Y="341" Z="0">

  <Outline Title="Delphi" pid="19" pnr="16" X="57" Y="376" Z="0"/>

  <Outline Title="C++ Builder" pid="19" pnr="16" X="57" Y="657" Z="0"/> ....

 

 

The following flags can be used in the integer parameter:

1:  do not normalize the Y values to Top->Bottom, in PDF normally Y=0 is bottom of page.

2:  do not include page numbers (pnr)

4:  do not include page IDs  (pid)

 

The extracted XML can be used to display an independent bookmark viewer or -editor.

 

It is possible to set predefined bookmarks in WPViewPDF with the command

 

COMPDF_SetBookmarkXML = 352

 

It returns a string.

 

This flags are understood:

1:  Y is measured from bottom to top

2:  page numbers (pnr) should be ignored

4:  page IDs  (pid) should be ignored

512: do not update the internal treeview

 

When a PDF file is saved, the new structure will be written.

Use COMPDF_SetBookmarkXML with an empty string to clear the tree. This is also required, after a new PDF was loaded, unless the bookmark should persist.

 

If you want to implement navigation use command  COMPDF_GotoPage  = 22 to goto the page Nr in int parameter. The optional string parameter can be   "y"  or "x,y" or "x,y%z" to specify the zoom value z

 

 

set_bookmarks