Home > Mobile >  pdfbox git merge example. Where the final merged file is stored?
pdfbox git merge example. Where the final merged file is stored?

Time:09-13

I want to use the pdfbox library for java to merge thousands of small pdf files. Looking for an example I found one on the pdfbox site and specifically in the examples it has(PDFMergerExample). But where the final merged file is saved?

CodePudding user response:

It's just a class, not a complete sample... The entry method returns an InputStream, from there you can read the result and store ist to e.g. a file.

public InputStream merge(final List<RandomAccessRead> sources) throws IOException

https://www.baeldung.com/convert-input-stream-to-a-file

CodePudding user response:

In the example the destination is set here:

pdfMerger.setDestinationStream(mergedPDFOutputStream);

you can change this to

pdfMerger.setDestinationStream(filename);
  • Related