<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Fabio,<br>
<br>
Sorry, I was specifying wrong coordinates...<br>
<br>
Now I am able to annotate a document using Poppler::LineAnnotation
objects (am I correct if I assume that coordinates are given as
percentages of the page size?) and to view them on various PDF
Viewers.<br>
<br>
I am also able to add Poppler::TextAnnotation's to a document. <br>
<br>
However they appear as an icon when I open the document (bot using
the poppler_qt4viewer distributed with Poppler and using Nitro PDF).
Are there settings that allow to view them "exploded", i.e, with
their associated text displayed on one the PDF page's sides?<br>
<br>
Thanks and best regards,<br>
Francesco.<br>
<br>
-------- Original Message --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject: </th>
<td>Re: [poppler] Annotation creation using Poppler</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date: </th>
<td>Thu, 24 May 2012 17:46:21 +0200</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">From: </th>
<td>Francesco Gabbanini <a class="moz-txt-link-rfc2396E" href="mailto:fgabbanini@gmail.com"><fgabbanini@gmail.com></a></td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">To: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:poppler@lists.freedesktop.org">poppler@lists.freedesktop.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Many thanks for your help Fabio!<br>
<br>
I have tryed to work on your example and wrote the following code:<br>
<br>
Poppler::LineAnnotation *ia = new
Poppler::LineAnnotation(Poppler::LineAnnotation::StraightLine);<br>
QLinkedList<QPointF> points;<br>
points.push_back(QPointF(50, 50));<br>
points.push_back(QPointF(150, 150));<br>
<br>
ia->setLinePoints(points);<br>
Poppler::Annotation::Style style;<br>
style.setColor(QColor(0, 0, 0));<br>
style.setWidth(4.0);<br>
ia->setStyle(style);<br>
<br>
Poppler::Page *p = _doc->page(npage);<br>
p->addAnnotation(ia);<br>
<br>
Poppler::PDFConverter *conv = _doc->pdfConverter();<br>
conv->setOutputFileName(QString("C:/Users/.../test.pdf"));<br>
conv->setPDFOptions(conv->pdfOptions() |
Poppler::PDFConverter::WithChanges);<br>
conv->convert();<br>
<br>
I then tried to open the document with Nitro PDF Professional.<br>
It seems that the annotation is there, because it is displayed by
Nitro PDF when I click on the "Comments" button, but I cannot see it
on the screen (I expected to see it drawn over the document).<br>
I also tried to open the PDF with the Chrome browser's internal
viewer, but the result is the same.<br>
<br>
Am I missing something?<br>
<br>
Thanks in advance,<br>
Francesco.<br>
<br>
<br>
<br>
On 18/05/2012 17:03, Fabio D'Urso wrote:
<blockquote cite="mid:BLU0-SMTP201887117E141FC3F5B9A36AF1E0@phx.gbl"
type="cite">
<pre wrap="">On Friday, May 18, 2012 03:34:53 PM Francesco Gabbanini wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap="">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).
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap="">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.
</pre>
<blockquote type="cite">
<pre wrap="">I was wondering what is that QDomElement & that has to be given as an
input to the method.
</pre>
</blockquote>
<pre wrap="">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/).
</pre>
<blockquote type="cite">
<pre wrap="">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?
</pre>
</blockquote>
<pre wrap="">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
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
poppler mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:poppler@lists.freedesktop.org">poppler@lists.freedesktop.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/poppler">http://lists.freedesktop.org/mailman/listinfo/poppler</a>
</pre>
</blockquote>
</body>
</html>