Annotations do not appear when viewing PDF in Chrome

Question:

After merging XFDF file containing annotations, the new annotations do not appear in Chrome browser.

Answer:

The Chrome PDF viewer will not generate default appearances for annotations that are missing an explicit one. The following code will run through all the annotations, and generate appearances for those that are missing them. Hopefully a future addition of Chrome PDF viewer will be able to generate these as most other PDF readers do.

PageIterator itr = doc.GetPageIterator();
for (; itr.HasNext(); itr.Next())
{
System.Console.WriteLine("Page {0:d}: ", itr.GetPageNumber());

Page page = itr.Current();
int num_annots = page.GetNumAnnots();
for (int i=0; i<num_annots; ++i)
{
Annot annot = page.GetAnnot(i);
if (annot.IsValid() == false) continue;
if (annot.GetAppearance() == null) annot.RefreshAppearance();
}
}

As of PDFNet 8.0 there is a single API call you can make now after calling FDFMerge that will take care of generating appearances only for those annotations that need it.

PDFDoc.RefreshAnnotAppearances

https://www.pdftron.com/api/PDFTronSDK/dotnet/pdftron.PDF.PDFDoc.html#pdftron_PDF_PDFDoc_RefreshAnnotAppearances_pdftron_PDF_RefreshOptions_

If you are using FDFUpdate to apply the annotations, you will still need to call PDFDoc.RefreshAnnotAppearances otherwise the annotations do not appear on Chrome.

The documentation for FDFUpdate also states this: