PdfDocument pdf = new PdfDocument(new PdfWriter(DEST));
PdfMerger merger = new PdfMerger(pdf);
PdfDocument firstSourcePdf = new PdfDocument(new PdfReader(SRC1));
merger.merge(firstSourcePdf, 1, firstSourcePdf.getNumberOfPages());
PdfDocument secondSourcePdf = new PdfDocument(new PdfReader(SRC2));
merger.setCloseSourceDocuments(true).merge(secondSourcePdf, 1, secondSourcePdf.getNumberOfPages());
此JAVA代码正在合并两个pdf文件。 合并工作正常,但会出现警告。
“ [AWT-EventQueue-0]警告com.itextpdf.kernel.pdf.PdfPage-源文档具有AcroForm词典。您要复制的页面可能具有FormField,但不会被复制,因为您没有使用了任何IPdfPageExtraCopier“
我如何解决此警告?
答案 0 :(得分:1)
该异常说明缺少的内容。请参见tutorial的示例,并像这样修改您的代码段:
IPdfPageExtraCopier copier = new PdfPageFormCopier();
PdfDocument firstSourcePdf = new PdfDocument(new PdfReader(SRC1));
merger.merge(firstSourcePdf, 1, firstSourcePdf.getNumberOfPages(), copier);
PdfDocument secondSourcePdf = new PdfDocument(new PdfReader(SRC2));
merger.setCloseSourceDocuments(true).merge(secondSourcePdf, 1, secondSourcePdf.getNumberOfPages(), copier);