4.13.  Comparing Quantities of PDF Elements

The number of various items in a test document can be compared with the number of the same items in a referenced document.

Even if some of these tests are already described in other chapters, the following list gives an overview of all comparing methods for countable components:

// Overview of counting the number of parts of a PDF document:

.haveSameNumberOfBookmarks()
.haveSameNumberOfEmbeddedFiles()
.haveSameNumberOfFields()
.haveSameNumberOfImages()
.haveSameNumberOfLayers()                
.haveSameNumberOfNamedDestinations()
.haveSameNumberOfPages()
.haveSameNumberOfTaggingInfo()

Here are some examples which are not shown in other chapters:

@Test
public void haveSameNumberOfPages() throws Exception {
  String filenameTest = "documentUnderTest.pdf";
  String filenameReference = "reference.pdf";
  
  AssertThat.document(filenameTest)
            .and(filenameReference) 
            .haveSameNumberOfPages()
  ;
}
@Test
public void haveSameNumberOfLayers() throws Exception {
  String filenameTest = "documentUnderTest.pdf";
  String filenameReference = "reference.pdf";
  
  AssertThat.document(filenameTest)
            .and(filenameReference) 
            .haveSameNumberOfLayers()
  ;
}