red6 / pdfcompare

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

Return compare result as java.io.File #55

Closed jLemmings closed 5 years ago

jLemmings commented 5 years ago

Hi there

First of all thanks for working on this! I'm currently writing a little project which accepts two PDF's through a REST service and returns the result. What I'm struggling with is to return the result.pdf as a file.

Consulting the API there isn't any way to get this done. What are your suggestions to do this? Should I temporarily store it?

Thanks

finsterwalder commented 5 years ago

The current implementation relies in storing data to a file on disk. So yes, the currently easiest solution is to store the file to disk and then serve it from there.

Instead of writing to a file, one could change the implementation to allow for using an OutputStream, which would make this more flexible. Would that help?

It's more complicated in the case of CompareResults with Overflow, which stores temporary files and merges them at the end of the compare. The merge result could be written to an OutputStream as well, but I don't know if that's a good idea. When the OutputStream is in memory, one might run into memory problems again...

finsterwalder commented 5 years ago

I just release version 1.1.38, which contains a new method: CompareResult.writeTo(OutpoutStream). Maybe that helps. :-)