The simplest comparison related to bookmarks is to compare the number of bookmarks in two documents:
@Test public void haveSameNumberOfBookmarks() throws Exception { String filenameTest = "documentUnderTest.pdf"; String filenameReference = "reference.pdf"; AssertThat.document(filenameTest) .and(filenameReference) .haveSameNumberOfBookmarks() ; }
Next, the bookmarks and their properties are compared. Bookmarks of two PDF documents are 'equal' if the following attributes have the same values:
label (title)
destination (URI)
destination (related page)
destination (link name)
@Test public void haveSameBookmarks() throws Exception { String filenameTest = "documentUnderTest.pdf"; String filenameReference = "reference.pdf"; AssertThat.document(filenameTest) .and(filenameReference) .haveSameBookmarks() ; }
If you are uncertain about the bookmarks, all bookmark data can be extracted into
an XML file using the utility ExtractBookmarks
.
This file can easily be analyzed.
See chapter
9.5: “Extract Bookmarks to XML”.