Import annotations (XFDF) to PDF

343 views Asked by At

I have created a sample program to try to import XFDF to PDF using the Aspose library. The program can be run without exception, but the output PDF does not include any annotations. Any suggestions to solve this problem?

Update - 2014-12-12

I have also sent the issue to Aspose. They can reproduce the same problem and logged a ticket PDFNEWJAVA-34609 in their issue tracking system.

Following is my sample program:

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

There are 0 answers