[poppler] annotations survive in saveas copy AFTER removing them

Albert Astals Cid aacid at kde.org
Wed Jul 19 20:38:05 UTC 2017


El divendres, 14 de juliol de 2017, a les 17:35:54 CEST, Jannick va escriure:
> Dear All,
> 
> 
> 
> my code snip below suggests that 'a.pdf' is copied to 'b.pdf' AFTER
> 
> removing all annotations of a.pdf. However, b.pdf still contains all
> 
> annotations seen in a.pdf.
> 
> 
> 
> Am I missing something obvious here?

Is removeAnnot returning true or false?

Cheers,
  Albert

> 
> 
> 
> Thanks,
> 
> J.
> 
> 
> 
> // main.cpp:
> 
> #include <stdio.h>
> 
> #include <stdlib.h>
> 
> #include <PDFDoc.h>
> 
> #include <GlobalParams.h>
> 
> 
> 
> 
> 
> int main(int argc, char** argv)
> 
> {
> 
>     const char* f_in = "test_in.pdf";
> 
>     const char* f_out= "test_out.pdf";
> 
> 
> 
>     GooString gf_in(f_in);
> 
>     GooString gf_out(f_out);
> 
>     globalParams = new GlobalParams();
> 
>     PDFDoc * doc = new PDFDoc(&gf_in);
> 
>     if ( doc->isOk() )
> 
>     {
> 
>         int i_pages = doc->getNumPages();
> 
>         for ( int i_page = 1; i_page <= i_pages; i_page++ )
> 
>         {
> 
>             Page * page = doc->getPage(i_page);
> 
>             if( page )
> 
>             {
> 
>                 Annots * annots = page->getAnnots();
> 
>                 int n_annots = annots->getNumAnnots();
> 
>                 for ( int i_annot = 0; i_annot < n_annots ; i_annot++ )
> 
>                     annots->removeAnnot(annots->getAnnot(i_annot));
> 
>             }
> 
>         }
> 
>         doc->saveAs(&gf_out,writeForceRewrite);
> 
>         delete doc;
> 
>     }
> 
>     else
> 
>     {
> 
>         fprintf(stderr, "error when opening '%s'\n", f_in);
> 
>     }
> 
>     delete globalParams;
> 
>     return 0;
> 
> }




More information about the poppler mailing list