Prev |  | Next

## 4.6. Comparing Format

Two documents have the same page format if width and height of all pages have the same values. The tolerance defined by DIN 476 is taken into account:

    @Test
    public void haveSameFormat() throws Exception {
      String filenameTest = "documentUnderTest.pdf";
      String filenameReference = "reference.pdf";

      AssertThat.document(filenameTest)
                .and(filenameReference)
                .haveSameFormat()
      ;
    }

The comparison can be restricted to selected pages:

    @Test
    public void haveSameFormat_OnPage2() throws Exception {
      String filenameTest = "documentUnderTest.pdf";
      String filenameReference = "reference.pdf";
      PagesToUse page2 = PagesToUse.getPage(2);

      AssertThat.document(filenameTest)
                .and(filenameReference)
                .restrictedTo(page2)
                .haveSameFormat()
      ;
    }

    @Test
    public void haveSameFormat_OnEveryPageAfter() throws Exception {
      String filenameTest = "documentUnderTest.pdf";
      String filenameReference = "reference.pdf";
      PagesToUse pagesBefore2 = ON_EVERY_PAGE.before(2);

      AssertThat.document(filename)
                .and(filenameReference)
                .haveSameFormat(pagesBefore2)
      ;
    }

All possibilities to select pages are explained in chapter 13.2: “Page Selection”.

Prev | Up | Next
4.5. Comparing Document Properties | Home | 4.7. Comparing Form Fields