as Duane pointed out XFA is different than a "regular" AcroForm. If it's a 
static XFA form the XFA fields are represented in AcroForms. If it's a dynamic 
XFA form - well then you need to extract the XFA xml content, modify it and put 
it back in to get the changes. One would need a sample of the PDF to help you 
further.

Kind regards

Maruan Sahyoun

Am 19.11.2012 um 23:14 schrieb Duane Nickull <[email protected]>:

> Yeah, XFA is harder.  PDFBox has a getXFA() function but we had to write
> our own libraries to work with XFA as PDFBox only returned a PDXFA object.
> You also have to feed it an argument of an org.apache.pdfbox.cos.COSBase
> object.  
> 
> It is important to look closely at the PDFBox source if you plan to get
> this XFA back and work with it.  XFA should come as a chunk of XML and
> then you have to parse that DOM and find the node you want to modify.
> AFAIK, there are no code samples or tutorials on how to do this on the
> market. 
> 
> Duane Nickull
> 
> ***********************************
> Technoracle Advanced Systems Inc.
> Consulting and Contracting; Proven Results!
> i.  Neo4J, PDF, Java, LiveCycle ES, Flex, AIR, CQ5 & Mobile
> b. http://technoracle.blogspot.com
> t.  @duanechaos
> "Don't fear the Graph!  Embrace Neo4J"
> 
> 
> 
> 
> 
> 
> On 2012-11-19 1:08 PM, "Maruan Sahyoun" <[email protected]> wrote:
> 
>> Hi there,
>> 
>> the form is a XFA form which you can tell from the #pageSet construct.
>> This denominates fields within a master page of a form. A master page is
>> a concept used within XFA to serve as a "background" holding logos,
>> static fields. etc. Dependent on the form this master page may not be
>> used within the form. In addition the field might be hidden. How did you
>> test if the field doesn't contain any value after you set it?
>> 
>> Using the field txtFirstName alone is not a complete reference to the
>> form field as this is a child within applicationPrepaid.#pageSet Š. so
>> the error is correct.
>> 
>> Maruan Sahyoun
>> 
>> Am 19.11.2012 um 17:42 schrieb Duane Nickull
>> <[email protected]>:
>> 
>>> Can you send me the form? There are many types of PDF forms.  Acroforms
>>> are easiest but there are FDF, XFDF and XFA as well.
>>> 
>>> Duane Nickull
>>> ***********************************
>>> Technoracle Advanced Systems Inc.
>>> Consulting and Contracting; Proven Results!
>>> i.  Neo4J, PDF, Java, LiveCycle ES, Flex, AIR, CQ5 & Mobile
>>> b. http://technoracle.blogspot.com
>>> t.  @duanechaos
>>> "Don't fear the Graph!  Embrace Neo4J"
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On 2012-11-19 4:19 AM, "Milan Stojanovic" <[email protected]>
>>> wrote:
>>> 
>>>> I have a PDF file with some form fields that I need to fill in from
>>>> Java
>>>> code. I use PDFBox library for this, and this code:
>>>> 
>>>> PDDocument pdfDoc =
>>>> PDDocument.load("C:\\Users\\igor\\Desktop\\test.pdf");PDDocumentCatalog
>>>> docCatalog = pdfDoc.getDocumentCatalog();PDAcroForm acroForm =
>>>> docCatalog.getAcroForm();PDField field =
>>>> 
>>>> acroForm.getField("applicationPrepaid[0].#pageSet[0].Pagina1[0].txtFirst
>>>> Na
>>>> me[0]");if
>>>> (field != null) {
>>>>  field.setValue("Milan");} else {
>>>>  System.err.println("No field found with name:" +
>>>> "applicationPrepaid[0].#pageSet[0].Pagina1[0].txtFirstName[0]");}
>>>> pdfDoc.save("C:\\Users\\igor\\Desktop\\testout.pdf");
>>>> pdfDoc.close();
>>>> 
>>>> The PDF is not created by me, so I don't know what type of form the
>>>> file
>>>> uses (if I understand correctly, there are FDF and XFA forms). Since
>>>> the
>>>> PDF is not created by me, I used this tool
>>>> http://support.persits.com/pdf/demo_formfields.asp to find out the
>>>> names
>>>> of
>>>> the form fields, and it gave me this:
>>>> 
>>>> applicationPrepaid[0].#pageSet[0].Pagina1[0].txtFirstName[0]
>>>> 
>>>> When I use this long field name, I don't get any errors, but the
>>>> resulting
>>>> PDF does not contain the value I put in the field. I thought that maybe
>>>> there was something wrong with the field name, so I used Pdftk
>>>> tool<http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/>which
>>>> gave me just txtFirstName for the field name. But when I use just
>>>> that, I
>>>> get the No field found with name: txtFirstName error. Help?
>>> 
>>> 
>> 
> 
> 

Reply via email to