PDFBoxを使用して多くのPDFファイルを1つにマージしたいのですが、これが私がやったことです:
PDDocument document = new PDDocument();
for (String pdfFile: pdfFiles) {
PDDocument part = PDDocument.load(pdfFile);
List<PDPage> list = part.getDocumentCatalog().getAllPages();
for (PDPage page: list) {
document.addPage(page);
}
part.close();
}
document.save("merged.pdf");
document.close();
pdfFiles
は、すべてのPDFArrayList<String>
ファイルを含む です。
上記を実行していると、常に次のようになります。
org.apache.pdfbox.exceptions.COSVisitorException: Bad file descriptor
私は何か間違ったことをしていますか?それを行う他の方法はありますか?