<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi all,<br>
<br>
before I started to write this mail I did a lot of research in the
web and also some research in the archives of the mailing list but I
did not find an appropriate topic.<br>
<br>
What is my problem:<br>
<br>
I try to auto-fill a PDF with editable form fields.<br>
Some of the fields are already pre-filled.<br>
In order to change a certain field, in a first attempt, I iterate
over all form fields and try to find a certain text field to be
changed (e.g. "Name").<br>
Afterwards, I static_cast the FormField to FormTieldText. <br>
For debugging reasons I check what is the current entry of the
FormField (using text()) and what is the new value after applying
setText().<br>
So far, this works fine. The value of the FormFieldText has been
changed. <br>
If I reload the document this is also shown in the viewer.<br>
However, when I save the document and open it again, it shows the
old value or empty fields, respectively.<br>
If I click onto the corresponding form fields, it shows the value, I
set the form field to and which I would expect, too. <br>
But printing the document, also gives the old values and I wonder
where do they come from and why they are displayed?<br>
<br>
Example code:<br>
<br>
Here is a small code snippet how I change the value of a
FormFieldText:<i><br>
<br>
if(m_doc->okToFillForm())<br>
{<br>
QList<Poppler::FormField*> formfieldlist =
m_doc->page(0)->formFields(); <br>
for(int i = 0; i < formfieldlist.count(); i++)<br>
{ <br>
Poppler::FormField* fieldI = listeFormularFelder[i];<br>
QString nameInListeFormularFelder = fieldI->name();<br>
<br>
if((fieldI->name() == "Name" && fieldI->type()
== formText)<br>
{ <br>
Poppler::FormFieldText* textfield =
static_cast<Poppler::FormFieldText*>(fieldI);<br>
QString currentText = textfield->text();<br>
<br>
if (!textfield->isReadOnly())<br>
{ <br>
textfield->setText("Heckmann");<br>
QString newText = textfield->text();
<br>
} <br>
} <br>
Q_FOREACH(DocumentObserver *obs, m_observers) <br>
{<br>
obs->reloadPage(); <br>
}<br>
}</i><br>
<i>}</i><br>
<br>
My code snippet to save the document:<br>
<i>QString fileName = QFileDialog::getSaveFileName(this, tr("Save
Copy"), QDir::homePath(), tr("PDF Documents (*.pdf)")); </i><br>
<i>if (fileName.isEmpty()) {<br>
return;<br>
} <br>
<br>
Poppler::PDFConverter *conv = m_doc->pdfConverter(); <br>
conv->setOutputFileName(fileName);<br>
conv->setPDFOptions(conv->pdfOptions() |
Poppler::PDFConverter::WithChanges);<br>
conv->convert();</i><br>
<br>
In attachment: The PDF I changed. (Old value was "Finder" which is
still displayed. New value is "Heckmann" which is shown when the
cursor is on the text field).<br>
<br>
I would be very happy if someone could tell me what I'm doing wrong
or what I'm missing respectively.<br>
<br>
Kind regards, <br>
Alexander<br>
<pre class="moz-signature" cols="72">--
Alexander Finder
Universität Bremen
Group of Computer Architecture
28359 Bremen, Germany</pre>
</body>
</html>