Skip to content

2.22 Document Links and Named Destination

OgreTransporter edited this page Mar 2, 2020 · 1 revision

Document links allow PDF document users to click on the link and jump to another part of the document. Adding document links is done in two parts. The destination is defined as a location marker. Location marker must have a unique name, a scope (LocalDest or NamedDest), and document location (page and position). NamedDest Scope can be used for either document link or for named destination or both . The second part is the link location. The two parts can be defined in any order. They are tied together by the name. The name is case sensitive. Many links can point to the same location marker.

Named destinations are targets within the PDF document. They are defined with location marker in the same way as document links. The scope has to be set to NamedDest. When a PDF reader such as Adobe Acrobat opens a PDF document it can open the document while displaying the target in the viewing window.

To embed a location marker call the AddLocationMarker method of PdfPage. Note: Name is case sensitive.

// Add location marker to the document (PdfPage method)
public void AddLocationMarker
  (
  string          LocMarkerName, // unique destination name (case sensitive)
  LocMarkerScope  Scope,         // eigther LocalDest or NamedDest
  DestFit         FitArg,        // fit argument (see below)
  params double[] SideArg        // 0, 1 or 4 side dimension argument (see below)
  )

To add link location call AddLinkLocation method of PdfPage.

public PdfAnnotation AddLinkAction
  (
  string LocMarkerName,    // location marker name
  PdfRectangle AnnotRect   // rectangle area on the page to activate the jump
  )

For more information about named destinations please refer to Adobe PDF file specification “PDF Reference, Sixth Edition, Adobe Portable Document Format Version 1.7 November 2006”. Table 8.2 on page 582.

  • DestFit.Fit (no arg): Display the page, with its contents magnified just enough to fit the entire page within the window both horizontally and vertically.
  • DestFit.FitH (1 arg Top): Display the page, with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of the page within the window.
  • DestFit.FitV (1 arg Left): Display the page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of the page within the window.
  • DestFit.FitR (4 args Left Bottom Right Top): Display the page, with its contents magnified just enough to fit the rectangle specified by the coordinates left, bottom, right, and topentirely within the window both horizontally and vertically.
  • DestFit.FitB (No arg): Display the page, with its contents magnified just enough to fit its bounding box entirely within the window both horizontally and vertically.
  • DestFit.FitBH (1 arg Top): Display the page, with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of its bounding box within the window.
  • DestFit.FitBV (1 arg Left): Display the page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of its bounding box within the window.

The PDF reader's calling parameters are defined in Parameters for Opening PDF Files by Adobe. If the PDF is opened on a desktop computer the calling line must be:

"path\AcroRd32.exe" /A "nameddest=ChapterXX" "path\Document.pdf"

If the PDF document is pointed by a link in a web page, the destination is appended to the link:

<a href="http://example.org/Document.pdf#ChapterXX">Target description</a>

Or:

<a href="http://example.org/Document.pdf#namedsest=ChapterXX">Target description</a>

Clone this wiki locally