Chapter 12. PDFUnit for non-XML Systems

12.1.  A quick Look at PDFUnit-Java

The first implementation of PDFUnit was PDFUnit-Java. It is the reference for implementations in other programming languages. Whenever it is possible, the keywords in all implementations are chosen to be the same as in PDFUnit-Java.

The following examples shows that the API follows the Fluent Interface (

public void hasTextOnFirstPageInClippingArea() throws Exception {
  String filename = PATH + "content/documentForTextClipping.pdf";
  int upperLeftX  =  50;
  int upperLeftY  = 130;
  int width       = 170;
  int height      =  25; 
  ClippingArea inClippingArea = new ClippingArea(upperLeftX, upperLeftY, width, height);
            .hasText(ON_FIRST_PAGE, inClippingArea)
            .containing("Content on first page") 
public void compareFields() throws Exception {
  String filenameTest = PATH + "acrofields/test.pdf";
  String filenameMaster = PATH + "acrofields/master.pdf";
public void hasSignature() throws Exception {
  String filename = PATH + "signed/sampleSignedPDFDocument.pdf";
  String xpath = "//signature[@name='Signature2']";
  XPathExpression expression = new XPathExpression(xpath);

A detailed documentation of PDFUnit-Java is available from