我想使用PDFBox将许多 PDF 文件合并为一个,这就是我所做的:
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();
包含所有 PDF 文件的pdfFiles
位置在哪里。ArrayList<String>
当我运行上述内容时,我总是得到:
org.apache.pdfbox.exceptions.COSVisitorException: Bad file descriptor
难道我做错了什么?还有其他方法吗?