pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JZ Q <ccna2c...@gmail.com>
Subject Questions regarding PDFMergerUtility
Date Sat, 09 Mar 2019 16:18:57 GMT
Hi everyone,

I used the following code fragment to merge over 100 one-page pdf file into
a single PDF file; then try to remove the original one page files. But it
seems like the PDFmerger utility still holds the handle to the original
file. Why? How to fix it?

Thanks.


PDFMergerUtility PDFmerger = new PDFMergerUtility();
File mergeFile = new File(outputDir, "Envelopes-" +
MyFileUtil.getStringAsTodayYYYYMMDD() + ".pdf");
PDFmerger.setDestinationFileName(mergeFile.getAbsolutePath());

for (File output : pdfFiles) {
PDFmerger.addSource(output);
}
PDFmerger.mergeDocuments(null);

// remove:
for (File output : pdfFiles) {
boolean rt = output.delete();
if (!rt) {
System.out.println("Failed to delete " + output.toString());
}
}



-- 
Best Wishes,
Jason

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message