red6 / pdfcompare

A simple Java library to compare two PDF files
Apache License 2.0
220 stars 66 forks source link

Easier way to get differences found in pdf #38

Closed wuws closed 5 years ago

wuws commented 6 years ago

It's more a question or polite request - is there a way to recapture differences found in pdfs returned in Log by DiffImage.diffImages() method, so I can pass them to my exception message. Or can you return it in some method as String or something like that?

finsterwalder commented 6 years ago

Good idea! I will try to incorporate that. It will take some time, since I don't have much time for this project at the moment...

paulfkp commented 6 years ago

Great to hear that! thank you so much.

ravijammi commented 5 years ago

How about using JSONObject to capture the differences? We could return each difference mentioned in the Log by DiffImage.diffImages() then and combine all as a differences JSON. Which could be used in any way we want to.

Something like:

{ "differences":[ { "y1":51, "x1":425, "y2":76, "x2":1105, "page":1 }, { "y1":51, "x1":425, "y2":76, "x2":1105, "page":2 } ] }

To make it backward compatible, we could add an additional method to the PdfCompator class, which will return this differences json on a need by basis.

Just a thought :)

finsterwalder commented 5 years ago

Version 1.1.37 contains a new Method CompareResult.getDifferences(), which gives back a collection of PageArea objects. This could be serialized to json, if needed. But how about this for a start?