red6 / pdfcompare

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

Add difference percentages to CompareResult #108

Closed LennartKoot closed 3 years ago

LennartKoot commented 3 years ago

Saw #79 open for a while and decided to give a solution a try.

This PR will add Map<Integer, Double> getPageDiffsInPercent() to the CompareResult interface, exposing a collection of difference percentages mapped to their respective page index.

There is a special case in PageDiffCalculator where totalPixels can be zero. In this case I decided to return 0% when there are no differences, and 100% when there are differences, since there is nothing to calculate the percentage with. I'm not sure if this is the correct way to go, so please let me know if you have different ideas.

finsterwalder commented 3 years ago

Thanks a lot for taking the time to improve PdfCompare!

finsterwalder commented 3 years ago

Version 1.1.60 is released and should land in maven central during the next couple of hours.