4.12.  Comparing Permission

PDFUnit can compare the access permission of two PDF documents. The following example compares all permission:

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

If you want to compare a single permission you can parameterize the test method with predefined constants:

@Test
public void haveSamePermission_MultipleInvocation() throws Exception {
  String filenameTest = "documentUnderTest.pdf";
  String filenameReference = "reference.pdf";
  
  AssertThat.document(filenameTest)
            .and(filenameReference)
            .haveSameAccessPermission(COPY)
            .haveSameAccessPermission(EXTRACT_CONTENT)
            .haveSameAccessPermission(MODIFY_CONTENT)
  ;
}

The following constants are available:

// Available permissions:

com.pdfunit.Constants.ASSEMBLE_DOCUMENTS
com.pdfunit.Constants.EXTRACT_CONTENT
com.pdfunit.Constants.FILL_IN
com.pdfunit.Constants.MODIFY_ANNOTATIONS
com.pdfunit.Constants.MODIFY_CONTENT
com.pdfunit.Constants.PRINT_IN_HIGHQUALITY
com.pdfunit.Constants.PRINT_DEGRADED_ONLY
com.pdfunit.Constants.ALLOW_SCREENREADERS