Why doesn't the text color of an annotation appear correctly when importing from XFDF?

72 views
Skip to first unread message

Aaron

unread,
Oct 9, 2014, 8:24:34 PM10/9/14
to pdfne...@googlegroups.com
Q:

I've imported an annotation with a custom color (i.e., specified in the annotation's default appearance) from an XFDF document.  But the custom colour doesn't show up.  Why?

A:

You need to call RefreshAppearance on the annotation:


PDFDoc doc((input_path + "test.pdf").c_str());
doc.InitSecurityHandler();
FDFDoc fdf_doc2(FDFDoc::CreateFromXFDF(
        (input_path + "test.xfdf").c_str()));
doc.FDFMerge(fdf_doc2);
doc.RefreshFieldAppearances();

for (PageIterator itr = doc.GetPageIterator();
     itr.HasNext();
     itr.Next())
{
  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()) continue;
    annot.RefreshAppearance();
  }
}

doc.Save((output_path + "test_merged.pdf").c_str(),
  SDFDoc::e_linearized, 0);
Reply all
Reply to author
Forward
0 new messages