9.9.  Extract Named Destinations to XML

Named Destinations are landing points inside PDF documents. They are difficult to test because they aren’t displayed anywhere. But the utility ExtractNamedDestinations extracts all information about Named Destinations into a file. The data can be used in tests as described in chapter 3.5: “Bookmarks and Named Destinations”.

And that's the extraction script:

Program Start

::
:: Extract information about named destinations in a PDF document into an XML file
::

@echo off
setlocal
set CLASSPATH=./lib/aspectj-1.8.7/*;%CLASSPATH%
set CLASSPATH=./lib/bouncycastle-jdk15on-153/*;%CLASSPATH%
set CLASSPATH=./lib/commons-logging-1.2/*;%CLASSPATH%
set CLASSPATH=./lib/pdfbox-2.0.0/*;%CLASSPATH%
set CLASSPATH=./lib/pdfunit-2016.05/*;%CLASSPATH%

set TOOL=com.pdfunit.tools.ExtractNamedDestinations
set OUT_DIR=./tmp
set IN_FILE=bookmarksWithPdfOutline.pdf
set PASSWD=

java  %TOOL%  %IN_FILE%  %OUT_DIR%  %PASSWD%
endlocal

Input

The input file in this sample, bookmarksWithPdfOutline.pdf, contains different named destinations.

Output

The output file _named-destinations_bookmarksWithPdfOutline.out.xml contains the following data:

<?xml version="1.0" encoding="UTF-8"?>
<destinations>
  <destination name="destination1"            page="1" />
  <destination name="destination2.1"          page="2" />
  <destination name="destination2.2"          page="2" />
  <destination name="destination2_no_blank"   page="2" />
  <destination name="destination3 with blank" page="3" />
</destinations>