[Android] PDFNet annotations compatibility

Hello,

I have to store annotations separately in xfdf file, after a user complete editing, the user can export pdf document with annotations, so I have to merge them:

File document = new File(mDocumentPath);
File annotations = new File(mAnnotationsPath);
if (annotations.exists()) {
    try {
        PDFDoc doc = new PDFDoc(new FileInputStream(document));
        FDFDoc fdf = FDFDoc.createFromXFDF(mAnnotationsPath);
        doc.fdfMerge(fdf);
        doc.flattenAnnotations(true);
        doc.save(mResultFilePath, SDFDoc.e_linearized, null);
        doc.close();
        fdf.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

The issue is: some 3rd party pdf viewers cannot display the annotations in the pdf file.



App name

|

Supported

|

Play Store

|

I changed the ‘flatten’ flag to false:

        doc.flattenAnnotations(false);

and it works, all these viewers display annotations (highlight, strikeout, underline, custom drawing) correctly.

But, unfortunately, the ‘note’ annotations aren’t working.
I see only a icon in the pdf file, but can’t read or edit the note (see attached file).

Could you help me? Perhaps, I’m doing something wrong.

Thanks.

Calling RefreshApperance will resolve this issue.

Annot.refreshAppearance();

See the following for more, including code to parse all annotations.

https://groups.google.com/d/msg/pdfnet-sdk/OhtqIGvBYx0/YTOOi9eDsNAJ
https://www.pdftron.com/pdfnet/samplecode/AnnotationTest.java.html