red6 / pdfcompare

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

Allow for a difference in percent per page via API #64

Closed rsilva2 closed 4 years ago

rsilva2 commented 4 years ago

Any way we can set this difference in percentage via the API, I have JUnit tests and would like some pdfs to allow different percentages.

Also having a hard time figuring out gradle to allow the application.conf file to be added to the build from the test sources folder to be used in my unit tests, any help on that would be great, but just being able to set the percentage difference through code would solve my issue. Thanks.

finsterwalder commented 4 years ago

You can do that with: Environment env = new SimpleEnvironment(); env.setAllowedDiffInPercent(5.0); new PdfComparator(...).setEnvironment(env).compare()

application.conf needs to be on the classpath root. Anything that is on the classpath will do. src/test/resources/application.conf should work.

finsterwalder commented 4 years ago

Actually I will rename setEnvironment to withEnvironment, so setEnvironment will be deprecated.

finsterwalder commented 4 years ago

Please use version 1.1.44 and see the updated README.md for usage.

rsilva2 commented 4 years ago

thanks it's working great.