[poppler] Annotation creation using Poppler

Albert Astals Cid aacid at kde.org
Wed May 23 10:59:13 PDT 2012


El Divendres, 18 de maig de 2012, a les 17:03:28, Fabio D'Urso va escriure:
> On Friday, May 18, 2012 03:34:53 PM Francesco Gabbanini wrote:
> > I noticed that version 0.20 of Poppler has introduced the possibility of
> > adding, modifying and removing annotations from PDF documents. These
> > features seem to be available through the qt4 interface library as well.
> 
> Correct. Note that only a subset of what we promise to do is implemented
> (setters for some properties, notably timestamps and popup window, are
> noops).
> > I have read the qt4 interface documentation and I found that annotation
> > creation seems to be possible by calling the static method
> > Poppler::AnnotationUtils::createAnnotation(const QDomElement
> > &annElement), which returns a pointer to an Annotation.
> 
> It's one of the two possible ways. The other one is to use the constructor
> of the annotation type you want to create (eg new InkAnnotation) and use
> setters to set the properties.
> 
> > I was wondering what is that QDomElement & that has to be given as an
> > input to the method.
> 
> It's a undocumented format to describe the annotations. You can some get
> examples calling AnnotationUtils::storeAnnotation on existing annotations.
> If you have Okular installed, it's also the same format Okular uses to store
> user-created annotations internally (in ~/.kde/share/apps/okular/docdata/).
> > Is there some documentation around describing how to work with
> > annotations using the qt4 interface?
> > Or maybe, does anybody have a simple example on how to create
> > annotations in a PDF using the qt4 interface?
> 
> No full examples yet. In general, it goes like this:
>  Document* document = Document::load(inputfilename);
>  Page* pdfPage = document->page(pagenum); // 0-based
>  InkAnnotation *ann = new InkAnnotation();
>  // Set its properties here ...
>  pdfPage->addAnnotation(ann);
>  // ... or here (they both work)
>  PDFConverter *conv = document->pdfConverter();
>  conv->setOutputFileName(outputfilename);
>  conv->setPDFOptions(conv->pdfOptions() | PDFConverter::WithChanges);
>  conv->convert();
> 
> Supported annotation types are: Text, Line, Geom, Ink, Stamp, Highlight.
> Note that StampAnnotations are stored to file, but they're not rendered by
> poppler at the moment.
> 
> *IMPORTANT*:
> Oops! I forgot to make TextAnnotation ctor public. I'm attaching a patch.

Pushed, since this changes the ABI in MSVC it'll have to wait until poppler 
0.22

Albert

> 
> Fabio


More information about the poppler mailing list