我有一个 XFDF 文件包含一些注释但不包含字段,我想知道它是否能够使用 PDFBox 将这些注释导入 PDF 文件我尝试在 Acrobat Reader DC 中将 XFDF 导入 PDF 并成功显示导入的注释。然而,通过在 PDAcroForm 中使用函数 importFDF 显示注释并不成功。它只导入字段而不导入注释。下面是我的样本 XFDF <?xml version="1.0" encoding="UTF-8" ?><xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"><fields /><annots> <ink page="0" rect="414.755559,308.987191,564.755559,365.356617" color="#000000" flags="print" name="a74a6f8a-4149-d913-6ee6-34ba434bc254" title="annotationTest" subject="Signature" date="D:20190808175939+08'00'" creationdate="D:20190808175827+08'00'"> <inklist> <gesture>415.23,342.9;415.23,342.9;417.62,345.77;422.4,349.11;441.98,357.24;456.79,361.53;470.17,364.88;471.12,364.88;471.6,362.97;468.74,355.8;464.44,346.25;456.79,333.35;440.07,314.72;432.91,310.9;429.56,309.46;429.09,309.46;427.65,312.81;427.65,316.15;429.09,319.02;432.91,322.36;445.81,324.27;454.41,323.8;463,320.45;472.56,317.11;488.32,315.2;499.31,315.68;505.52,318.06;509.82,320.45;514.12,322.36;514.6,322.36;515.55,322.36;517.94,322.36;526.06,322.36;530.36,322.36;535.14,322.36;539.44,322.36;541.83,322.36;542.78,322.36;543.26,322.36;544.69,322.36;546.6,322.84;548.51,322.84;549.47,322.84;550.42,323.8;552.34,325.23;553.29,325.71;554.25,326.66;554.72,327.14;556.63,328.1;559.98,329.05;564.28,330.48</gesture> </inklist> </ink>或推荐的任何其他图书馆?非常感谢。
1 回答
月关宝盒
TA贡献1772条经验 获得超5个赞
加载 xfdf 文件后,从 FDAnnotation 中获取 COSObject,然后使用它创建 PDAnnotation
PDAnnotation pdfannot = PDAnnotation.createAnnotation(fdfannot.getCOSObject());
然后添加到页面
List<PDAnnotation> pdfannots = new ArrayList<PDAnnotation>;
pdfannots.add(pdfannot);
page.setAnnotations(pdfannots);
保存它,你会看到PDF上的注释
添加回答
举报
0/150
提交
取消