After merging XFDF data the annotations that appear depend on what software is being used?

Question:

I use the following code to merge XFDF data (annotations) into a PDF.

FDFDoc fdf_doc = FDFDoc.createFromXFDF("XFDF File Path"); fdf_doc.save("FDF File Path"); PDFDoc pdoc = new PDFDoc("PDF File Path"); pdoc.initSecurityHandler(); pdoc.fdfMerge(fdf_doc); pdoc.save("PDF File Output Path", SDFDoc.e_linearized, null); pdoc.close();

But I see the following in different PDF viewers.

Chrome browser, few markups are not visible like Cloud, Polygon, Polyline, Arrow and Line.
Mozilla browser, no markups are visible.
IE browser, all markups are visible properly.

Answer:

PDF annotations are made of two parts — a high level “specification” of the annotation’s type, location, colors, and so on; and a low-level “appearance stream” (AP) made up of PDF page content. The second part is not only optional, but may even be ignored by some PDF readers. Each PDF viewer is free to generate its own appearance streams based on the annotation’s specification; this is how the PDF format is able to support custom annotation types.

After FDFMerge the annotations do not have appearances (AP) defined, so it is up to each viewer to handle them. For instance Chrome only shows annotations with an AP, while Safari on the other hand always ignores the AP.

To add the appearance please change your code to.

FDFDoc fdf_doc = FDFDoc.createFromXFDF("XFDF File Path");
fdf_doc.save("FDF File Path");
PDFDoc pdoc = new PDFDoc("PDF File Path");
pdoc.initSecurityHandler();
pdoc.fdfMerge(fdf_doc);
pdoc.refreshFieldAppearances(); // <<<<<<<<< create AP entries
pdoc.save("PDF File Output Path", SDFDoc.e_linearized, null);
pdoc.close();