将注释(XFDF)导入PDF

时间:2014-12-11 10:09:33

标签: aspose.pdf

我创建了一个示例程序,尝试使用Aspose库将XFDF导入PDF。该程序可以毫无例外地运行,但输出PDF不包含任何注释。有什么建议可以解决这个问题吗?

更新 - 2014-12-12

我也把问题发给了Aspose。他们可以重现相同的问题,并在问题跟踪系统中记录了一张 PDFNEWJAVA-34609 的票据。

以下是我的示例程序:

public static void main(String[] args) {

    final String ROOT  = "C:\\PdfAnnotation\\";
    final String sourcePDF = "hackermonthly-issue.pdf";
    final String destPDF = "output.pdf";
    final String sourceXFDF = "XFDFTest.xfdf";

    try
    {
        // Specify the path of license file
        License lic = new License();
        lic.setLicense(ROOT + "Aspose.Pdf.lic");
        //create an object of PdfAnnotationEditor class
        PdfAnnotationEditor editor = new PdfAnnotationEditor();
        //bind input PDF file
        editor.bindPdf(ROOT + sourcePDF);
        //create a file stream for input XFDF file to import annotations
        FileInputStream fileStream = new FileInputStream(ROOT + sourceXFDF);
        //create an enumeration of all the annotation types which you want to import
        //int[] annType = {AnnotationType.Ink };
        //import annotations of specified type(s) from XFDF file
        //editor.importAnnotationFromXfdf(fileStream, annType);
        editor.importAnnotationFromXfdf(fileStream);
        //save output pdf file
        editor.save(ROOT + destPDF);

    } catch (Exception e) {
        System.out.println("exception: " + e.getMessage());
    }

}

0 个答案:

没有答案