JUnits entry for iText created PDF

I'm curious if anyone has any experience writing JUnits for PDF files generated in Java (especially iText). I did a quick google search and I could not find anything specific. What I have been able to do so far is to verify that the PDF has been generated, has a certain number of pages and the document is closed. But I could not verify the contents of the document. Can someone provide an example of what they have done in the past to achieve such a result? Or am I completely mistaken, and JUnits is an excess for my PDF files? Thanks

+5
source share
1 answer

Given that you are using Java, I am looking at PDFBox (Apache). What you are asking for is quite complicated, since your relayed PDF cannot be syntactically identical to your original. You may need to consider traveling around the world.

Documents such as PDFs can be fragile relative to comparison. If you find that the comparison fails, this may give little indication of where the failure occurs. A PDF document can be extremely complex (highly branched trees). You may need to look for canonicalization of the document to compare them (I do this for XML documents).

My guess is that a full test is redundant and that your current tests are most effective at a reasonable price.

UPDATE: PDFBox PDDocument.equals(PDDocument), . , ( ). , .

, - . - .

+2

All Articles