red6 / pdfcompare

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

Add exclusions via API and without config file #31

Closed rweisleder closed 6 years ago

rweisleder commented 6 years ago

Currently it is necessary to create a config file to define exclusions. It would be useful to add exclusions directly without a config file.

Example:

// ignores a single page
withIgnore(int page)

// ignores an area on all pages
withIgnore(String x1, String y1, String x2, String y2)

// ignores an area on a single page
withIgnore(int page, String x1, String y1, String x2, String y2)

Should it be named "withIgnore" or "withExclusion"?

Ebsy commented 6 years ago

In which situations would this be useful? Genuine question. The config file makes it much more flexible to define exclusions rather than having it 'hard coded'.

rweisleder commented 6 years ago

We have a use case where the user wants to compare files from the production system with files from a stage system. So they define some information like

Those data are stored in and read from a file or a database into domain objects. So it would be easier to write (and maintain) method calls against an API instead of depending on a file-based API.

Yes, the current apporach is very flexible. But with the above use case I have to convert my domain object into a config file, call withIgnore(InputStream) and let pdfcompare parse the file again.

finsterwalder commented 6 years ago

Makes sense... It shouldn't be such a big deal to add such a feature. But I don't have a lot of time for the project at the moment... Maybe you can take a look at the project and see, whether you can create a pull request?

rweisleder commented 6 years ago

It shouldn't be such a big deal to add such a feature.

I'll work on this one on the next days.

finsterwalder commented 6 years ago

I just took a quick look and added a simple method to do this: new PdfComparator(a, b) .with(new Exclusion(1, 230, 350, 450, 420))

finsterwalder commented 6 years ago

Version 1.1.33 contains the feature and should land in maven central during the next couple of hours.