[poppler] Filled text field data not visible in saved document

Alexander Finder final at informatik.uni-bremen.de
Tue Jun 12 04:03:00 PDT 2012


Hi all,

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.

What is my problem:

I try to auto-fill a PDF with editable form fields.
Some of the fields are already pre-filled.
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").
Afterwards, I static_cast the FormField to FormTieldText.
For debugging reasons I check what is the current entry of the FormField 
(using text()) and what is the new value after applying setText().
So far, this works fine. The value of the FormFieldText has been changed.
If I reload the document this is also shown in the viewer.
However, when I save the document and open it again, it shows the old 
value or empty fields, respectively.
If I click onto the corresponding form fields, it shows the value, I set 
the form field to and which I would expect, too.
But printing the document, also gives the old values and I wonder where 
do they come from and why they are displayed?

Example code:

Here is a small code snippet how I change the value of a FormFieldText:/

if(m_doc->okToFillForm())
{
   QList<Poppler::FormField*> formfieldlist = m_doc->page(0)->formFields();
   for(int i = 0; i < formfieldlist.count(); i++)
   {
     Poppler::FormField* fieldI = listeFormularFelder[i];
     QString nameInListeFormularFelder = fieldI->name();

     if((fieldI->name() == "Name" && fieldI->type() == formText)
     {
       Poppler::FormFieldText* textfield = 
static_cast<Poppler::FormFieldText*>(fieldI);
       QString currentText = textfield->text();

       if (!textfield->isReadOnly())
       {
         textfield->setText("Heckmann");
          QString newText = textfield->text();
        }
     }
     Q_FOREACH(DocumentObserver *obs, m_observers)
     {
       obs->reloadPage();
      }
   }/
/}/

My code snippet to save the document:
/QString fileName = QFileDialog::getSaveFileName(this, tr("Save Copy"), 
QDir::homePath(), tr("PDF Documents (*.pdf)")); /
/if (fileName.isEmpty()) {
     return;
   }

     Poppler::PDFConverter *conv = m_doc->pdfConverter();
     conv->setOutputFileName(fileName);
     conv->setPDFOptions(conv->pdfOptions() | 
Poppler::PDFConverter::WithChanges);
     conv->convert();/

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).

I would be very happy if someone could tell me what I'm doing wrong or 
what I'm missing respectively.

Kind regards,
Alexander

-- 
Alexander Finder
Universität Bremen
Group of Computer Architecture
28359 Bremen, Germany

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20120612/a9ebd6ad/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pdf
Type: application/pdf
Size: 104755 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20120612/a9ebd6ad/attachment-0001.pdf>


More information about the poppler mailing list