3.26.  Permissions

Overview

If you expect your workflow to create copy protected PDF documents, you should test that. You can see the permissions using Adobe Reader®, but that is a poor test:

You can test permissions using the following methods. All methods have one typed parameter with the values true or false:

// Testing permissions:
.toAllowScreenReaders(..)  
.toAssembleDocument(..) 
.toExtractContent(..)
.toFillInFields(..) 
.toModifyAnnotations(..) 
.toModifyContent(..) 
.toPrintInDegradedQuality(..)
.toPrintInHighQuality(..)

Example

@Test
public void hasPermission_ScreenReadersAllowed() throws Exception {
  String filename = "documentUnderTest.pdf";
  AssertThat.document(filename)
            .hasPermission()
            .toAllowScreenReaders(true)
  ;
}

The document permissions of a protected document differ depending on whether the document is opened with the owner password or with the user password.