Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7880225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:05:38+00:00 2026-06-03T04:05:38+00:00

I am curious if anyone has an experience in writing JUnits for PDFs generated

  • 0

I am curious if anyone has an experience in writing JUnits for PDFs generated in Java (especially by iText). I did a quick search on google and I could not find anything specific.
What I was able to do so far was checking that the PDF has been generated, has certain amount of pages and the document is closed. But I was unable to verify the content of the document. Can someone provide an example what they did in the past to achieve such result? Or am I completely wrong and JUnits for my PDFs are overkill?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:05:39+00:00Added an answer on June 3, 2026 at 4:05 am

    Given that you are using Java I wold look at PDFBox (Apache). What you are asking is quite challenging as your retransformed PDF may not be syntactically identical to your original. You may need to think of roundtripping.

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

    My guess is that a complete test is overkill and that your current tests are as good as possible at reasonable cost.

    UPDATE:
    I have checked PDFBox for PDDocument.equals(PDDocument) and there is no deep equals method. This suggests they haven’t found it worthwhile (it requires recursion over many subnodes). Also there are many real numbers so these will all have to be compared against a tolerance.

    The bitmap method may work for humans but is very sensitive to real-number problems – a rounding error will write a bit in a different pixel. It will almost certainly behave differently with a new OS version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm curious if anyone (with a bit of Valgrind experience) has an idea how
I was curious if anyone out there has experience getting the necessary legal documents
I'm curious to find out if anyone has some real world experience using Abinitio
I am curious if anyone has done a comparison between the different options out
I'm just curious to know if anyone has used (successfully) Fusion Charts with Open
Does anyone know any more details about google's web-crawler (aka GoogleBot)? I was curious
Curious if anyone has this problem: I save my (embedded) fonts in an external
Just curious if anyone has any opinions on throwing an exception in my overridden
I'm curious if anyone has applied workflow foundation to a DDD project and if
Just curious if anyone has had sufficient time with WinRT yet to understand whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.