<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>When you get to the second half of the list, <span lang="EN-US">getAnnot(x)
probably fails because you don't have as many items in the
list. </span> You should either traverse the annotation list in
reverse order (from n_<span lang="EN-US">annots to 0), or always
remove annotation 0 in your "for" loop.<br>
</span></p>
<p><span lang="EN-US">Pierre-Luc<br>
</span></p>
<br>
<div class="moz-cite-prefix">On 17-07-14 11:35 AM, Jannick wrote:<br>
</div>
<blockquote type="cite"
cite="mid:007101d2fcb6$e26198a0$a724c9e0$@gmx.net">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Dear All,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">my code snip below
suggests that ‘a.pdf’ is copied to ‘b.pdf’ AFTER<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">removing all annotations
of a.pdf. However, b.pdf still contains all <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">annotations seen in
a.pdf.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Am I missing something
obvious here?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">J.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">// main.cpp:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#include <stdio.h><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#include
<stdlib.h><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#include
<PDFDoc.h><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">#include
<GlobalParams.h><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">int main(int argc,
char** argv)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">{<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> const char* f_in =
"test_in.pdf";<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> const char* f_out=
"test_out.pdf";<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> GooString
gf_in(f_in);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> GooString
gf_out(f_out);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> globalParams = new
GlobalParams();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> PDFDoc * doc = new
PDFDoc(&gf_in);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> if ( doc->isOk()
)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> int i_pages =
doc->getNumPages();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> for ( int i_page
= 1; i_page <= i_pages; i_page++ )<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> Page * page
= doc->getPage(i_page);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> if( page )<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> Annots *
annots = page->getAnnots();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> int
n_annots = annots->getNumAnnots();<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> for (
int i_annot = 0; i_annot < n_annots ; i_annot++ )<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">
annots->removeAnnot(annots->getAnnot(i_annot));<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">
doc->saveAs(&gf_out,writeForceRewrite);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> delete doc;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> else<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> fprintf(stderr,
"error when opening '%s'\n", f_in);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> delete globalParams;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> return 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">}<o:p></o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
poppler mailing list
<a class="moz-txt-link-abbreviated" href="mailto:poppler@lists.freedesktop.org">poppler@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/poppler">https://lists.freedesktop.org/mailman/listinfo/poppler</a>
</pre>
</blockquote>
<br>
</body>
</html>