“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 an XML file.
And that file can be used in tests based on XML and XPath as described
in Chapter
3.4: “Bookmarks and Named Destinations”.
And that's the extraction script:
:: :: Extract information about named destinations in a PDF document into an XML file :: @echo off setlocal set CLASSPATH=./lib/pdfunit-2015.10/*;%CLASSPATH% set CLASSPATH=./lib/itext-5.5.1/*;%CLASSPATH% set CLASSPATH=./lib/bouncycastle-jdk15on-150/*;%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
The input file in this sample, bookmarksWithPdfOutline.pdf
, contains different
named destinations.
The output file _named-destinations_bookmarksWithPdfOutline.out.xml
contains the following data:
<?xml version="1.0" encoding="UTF-8"?> <Destination> <Name Page="3 XYZ 36 764 0">destination2.2</Name> <Name Page="3 XYZ 36 800 0">destination2_no_blank<</Name> <Name Page="3 XYZ 36 782 0">destination2.1</Name> <Name Page="2 XYZ 36 800 0">destination1</Name> <Name Page="4 XYZ 36 800 0">destination3 with blank</Name> </Destination>
PDFUnit uses SimpleNamedDestination.getNamedDestination(..)
from iText (http://www.itextpdf.com) internally.
Again thank you to the developers.