4.9.  Comparing JavaScript

Two PDF documents can have the same JavaScript. The comparison is done byte-wise using the method haveSameJavaScript(). Whitespaces are ignored.

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

If you want to see the JavaScript code, you can extract it with the utility ExtractJavaScript as described in chapter 9.8: “Extract JavaScript to a Text File”.