[poppler] annotations survive in saveas copy AFTER removing them

Jannick thirdedition at gmx.net
Sat Jul 15 00:05:43 UTC 2017


On Fri, 14 Jul 2017 12:42:49 -0400, Pierre-Luc Samuel wrote:

Cher Pierre-Luc,

> When you get to the second half of the list, getAnnot(x) probably fails
> because you don't have as many items in the list.  You should either
traverse
> the annotation list in reverse order (from n_annots to 0), or always
remove
> annotation 0 in your "for" loop.

Thanks - this is really intriguing. But my 'stupid and simple' input pdf has
just one 
page with one single annotation, such that the reversed transition is
ultimately
equal to the forward one.

To be on the safe side I just double-checked: unfortunately your suggestion
does not solve the issue.

Moreover, the function Annots::removeAnnot() should essentially do the job -

BTW regardless of the transversal order as far I can see. But actually it
does not
do it for some reason.

poppler/Annot.cc:7200:
GBool Annots::removeAnnot(Annot *annot) {
  int idx = -1;
  // Search annot and determine its index
  for (int i = 0; idx == -1 && i < nAnnots; i++) {
    if (annots[i] == annot) {
      idx = i;
    }
  }
  if (idx == -1) {
    return gFalse;
  } else {
    --nAnnots;
    memmove( annots + idx, annots + idx + 1, sizeof(annots[0]) * (nAnnots -
idx) );
    annot->decRefCnt();
    return gTrue;
  }
}

> Pierre-Luc

Any further help appreciated!

Merci,
J.



More information about the poppler mailing list