4.5.  Comparing Bookmarks

Quantity

The simplest comparison related to bookmarks is to compare the number of bookmarks in two documents:

<testcase name="haveSameNumberOfBookmarks">
  <assertThat testDocument="test/test.pdf"
              masterDocument="master/master.pdf"
  >
    <haveSameNumberOfBookmarks />
  </assertThat>
</testcase>

Bookmarks with Properties

Next, the bookmarks and their properties are compared. Bookmarks of two PDF documents are equal if the following attributes have the same values:

  • title

  • namedDestination

  • relatedPage

  • action

<testcase name="haveSameBookmarks">
  <assertThat testDocument="test/test.pdf"
              masterDocument="master/master.pdf"
  >
    <haveSameBookmarks />
  </assertThat>
</testcase>

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”.