You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Dick Martin <rt...@nycap.rr.com> on 2017/11/09 15:17:04 UTC

saveXFDF doesn't include values?

Hi,
Using PDFBox 2.0.8 (and other versions), the saveXFDF method of FDFDocument
doesn't include the form field values in the resulting XFDF file.  Running
the same code with the save method for FDF output, the values are
included.  See examples below from the same code (except save method) and
the same PDF file.

Is this expected behavior?  Is this a known issue?  I could workaround this
by altering the PrintFields example to construct an XFDF file but would
hope that saveXFDF would behave like save.

I can provide the code and PDF file if needed but given the behavior of the
save method, I suspect that wouldn't be needed.
Thanks.  And thanks for producing PDFBox.  It's a great library.
Dick Martin

*Output from save method of FDFDocument*
7 0 obj
<<
/T (Primary Care Physician)
/V (Dr. Somebody)
>>
endobj


*Output from saveXFDF method of FDFDocument*
<field name="Primary Care Physician">
</field>

Re: saveXFDF doesn't include values?

Posted by Tilman Hausherr <TH...@t-online.de>.
I don't know much about that part... I looked in the source code and 
found this:

     public void writeXML(Writer output) throws IOException
     {
         output.write("<field name=\"" + getPartialFieldName() + "\">\n");
         Object value = getValue();
         if (value != null)
         {
             if (value instanceof COSString)
             {
                 output.write("<value>" + escapeXML(((COSString) 
value).getString()) + "</value>\n");
             }
             else if (value instanceof COSStream)
             {
                 output.write("<value>" + escapeXML(((COSStream) 
value).toTextString()) + "</value>\n");
             }
         }
         String rt = getRichText();
         if (rt != null)
         {
             output.write("<value-richtext>" + escapeXML(rt) + 
"</value-richtext>\n");
         }
         List<FDFField> kids = getKids();
         if (kids != null)
         {
             for (FDFField kid : kids)
             {
                 kid.writeXML(output);
             }
         }
         output.write("</field>\n");
     }

Makes me wonder what type the value has. Can you upload the PDF 
somewhere and tell what code you're using?

Tilman




Am 09.11.2017 um 16:17 schrieb Dick Martin:
> Hi,
> Using PDFBox 2.0.8 (and other versions), the saveXFDF method of FDFDocument
> doesn't include the form field values in the resulting XFDF file.  Running
> the same code with the save method for FDF output, the values are
> included.  See examples below from the same code (except save method) and
> the same PDF file.
>
> Is this expected behavior?  Is this a known issue?  I could workaround this
> by altering the PrintFields example to construct an XFDF file but would
> hope that saveXFDF would behave like save.
>
> I can provide the code and PDF file if needed but given the behavior of the
> save method, I suspect that wouldn't be needed.
> Thanks.  And thanks for producing PDFBox.  It's a great library.
> Dick Martin
>
> *Output from save method of FDFDocument*
> 7 0 obj
> <<
> /T (Primary Care Physician)
> /V (Dr. Somebody)
> endobj
>
>
> *Output from saveXFDF method of FDFDocument*
> <field name="Primary Care Physician">
> </field>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org