Speed up iterating through all annotations in a document?


We have a PDF with 500 pages, and 100 annotations per page. We find iterating through all the annotations slow. Is there a faster way to create a set of annotations?

PageIterator itr = pdfDocument.GetPageIterator();
Page page = itr.Current();
int num_annots = page.GetNumAnnots();

for (int i=0; i<num_annots; ++i)
Annot annot = page.GetAnnot(i);


Yes, you can use multi-threading. Just make sure to call PDFDoc.LockRead and PDFDoc.UnlockRead on each thread, and have each thread operate on a different page.

Otherwise, no there isn’t any other shortcut.