Prev |  | Next

# Chapter 13. Appendix

## 13.1. Instantiation of PDF Documents

The following list shows the methods and data types to read PDF documents for tests:

    // Possibilities to instantiate PDFUnit with a test PDF:
    AssertThat.document(String      pdfDocument)
    AssertThat.document(File        pdfDocument)
    AssertThat.document(URL         pdfDocument)
    AssertThat.document(InputStream pdfDocument)
    AssertThat.document(byte[]      pdfDocument)

    // The same with a password when the PDF is encrypted:
    AssertThat.document(String      pdfDocument, String password)
    AssertThat.document(File        pdfDocument, String password)
    AssertThat.document(URL         pdfDocument, String password)
    AssertThat.document(InputStream pdfDocument, String password)
    AssertThat.document(byte[]      pdfDocument, String password)

    // Instantiate a test PDF and a reference PDF:
    AssertThat.document(..).and(pdfReference)
    AssertThat.document(..).and(pdfReference, String password)

    // Instantiate an array of test documents:
    AssertThat.eachDocument(String      pdfDocument)
    AssertThat.eachDocument(File        pdfDocument)
    AssertThat.eachDocument(URL         pdfDocument)
    AssertThat.eachDocument(InputStream pdfDocument)

    // Instantiate an array of password protected test documents:
    AssertThat.eachDocument(String      pdfDocument, String password)
    AssertThat.eachDocument(File        pdfDocument, String password)
    AssertThat.eachDocument(URL         pdfDocument, String password)
    AssertThat.eachDocument(InputStream pdfDocument, String password)

    // Instantiate PDF documents in a folder:
    AssertThat.eachDocument().inFolder(..)

| Also, a referenced PDF document can be read from a `String`, `File`, `URL`, `InputStream` or `byte[]`.
| PDFUnit collects all PDF files in the given folder and runs the test with each of them. The process stops if one of the PDF files does not pass the test.

If documents are password protected, PDFUnit needs either the “user password” or the “owner password” to open the file.

Prev |  | Next
12.8. Uninstall | Home | 13.2. Page Selection