Annotations do not appear when viewing PDF in Chrome

40 views
Skip to first unread message

Ryan

unread,
Jul 23, 2015, 8:42:18 PM7/23/15
to PDFTron PDFNet SDK
Q:
After merging XFDF file containing annotations, the new annotations do not appear in Chrome browser.

--------------------------------------------------------------
A:

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();
   
}
}


Reply all
Reply to author
Forward
0 new messages