How do I read / write PDF annotations to a separate file?


I’m currently trying to write out all of the annotations to a file separate from the PDF so the annotations can be managed separately from the report. I’m able to iterate through all of the pages and find all of the annotations, but when I try to write to a file, I’m not seeing what I expected. What is the best way to save all of the annotations to a separate file?

PDFDoc currentReport = mPDFView.GetDoc();

PageIterator itr = currentReport.GetPageIterator();

string annotationFilePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, “annotationfile.dat”);

StdFile outfile = new StdFile(annotationFilePath, StdFileOpenMode.e_append_mode);

using (FilterWriter fwriter = new FilterWriter(outfile))


for (; itr.HasNext(); itr.Next())


pdftron.PDF.Page page = itr.Current();

int pageAnnots = page.GetNumAnnots();

for (int i = 0; i < pageAnnots; i++)


IAnnot a = itr.Current().GetAnnot(i);

pdftron.SDF.Obj o = a.GetSDFObj();







Actually PDFNet offers a much simpler way to serialize / load annotations to/from PDF :slight_smile: This is shown in FDF sample project (the snippet should also be part of WinRT SDK):

e.g. in C#:

For example:

using (FDFDoc doc_annots = pdfdoc.FDFExtract(PDFDoc.ExtractFlag.e_annots_only)){



You can also load/merge annotations from XFDF into PDF:

using (FDFDoc fdf = new FDFDoc(FDFDoc.CreateFromXFDF(“annots.xfdf”)) {



XFDF is an open format for annotation interchange and is now part of ISO32000 (for old spec which is separate from PDF spec please see

For more info on recent additions to this api (e.g. save/load xfdf from a string) please see: