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. Fabio
From 7d0f313287e44d114d4a94054db705e5ee067429 Mon Sep 17 00:00:00 2001 From: Fabio D'Urso <[email protected]> Date: Fri, 18 May 2012 16:22:46 +0200 Subject: [PATCH] qt4: Make TextAnnotation ctor public --- qt4/src/poppler-annotation.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qt4/src/poppler-annotation.h b/qt4/src/poppler-annotation.h index ec792b5..6c8dbb7 100644 --- a/qt4/src/poppler-annotation.h +++ b/qt4/src/poppler-annotation.h @@ -305,6 +305,7 @@ class POPPLER_QT4_EXPORT TextAnnotation : public Annotation enum TextType { Linked, InPlace }; enum InplaceIntent { Unknown, Callout, TypeWriter }; + TextAnnotation( TextType type ); virtual ~TextAnnotation(); virtual SubType subType() const; @@ -363,7 +364,6 @@ class POPPLER_QT4_EXPORT TextAnnotation : public Annotation void setInplaceIntent( InplaceIntent intent ); private: - TextAnnotation( TextType type ); TextAnnotation( const QDomNode &node ); TextAnnotation( TextAnnotationPrivate &dd ); virtual void store( QDomNode &parentNode, QDomDocument &document ) const; -- 1.7.6.5
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
