Read File Or Resource

Use data.pdf.read(String) to read and parse PDF from a path. Passed path is either relative based on working dir or absolute path. Or it can be a resource class path. Pdf pdf = data.pdf.read("sample.pdf") pdf.pageText(0).should contain('Test text paragraph Test') Check data/import-and-dependencies Import And Dependencies for prerequisites.

HTTP response

Use data.pdf.parse(body) to parse and assert PDF content from binary response. Groovy http.get("/report") { data.pdf.read(body).pageText(0).should contain("Quarterly earnings:") } Java http.get("/report", ((header, body) -> { data.pdf.read(body).pageText(0).should(contain("Quarterly earnings:")); })); Learn More about HTTP/body#pdf-response HTTP response

Read Bytes

byte[] pdfContent = pdfBinaryContent() Pdf pdf = data.pdf.read(pdfContent) pdf.pageText(0).should contain('Test text paragraph Test')