Hi,
> Am 26.08.2015 um 06:00 schrieb Tolen Miller <[email protected]>:
>
> I uploaded my PDF again, if someone wants to see if they can get all of the
> fields to return: http://1drv.ms/1PRKZsI
>
> After looking at the sample provided by Maruan, I noticed that I was not
> passing in a File object, when calling the PDDocument.load() method. Doing
> so, I now get the same result from Maruan's code (in eclipse).
>
> Now I am unsure how to get *all* of the fields from the PDAcroForm. I am
> trying to get a collection of the fields, so I can loop through them. When
> I add this code:
>
> List<PDField> pdfFields = form.getFields();
> for (PDField field : pdfFields) {
> System.out.println("PDF Field Full Name: ".concat(field
> .getFullyQualifiedName()));
> }
>
as there is only one 'root' field you have to get it's kids and process the
field tree down. Take a look at org.apache.pdfbox.examples.fdf.PrintFields of
how to do that.
BR
Maruan
>
> I get the same single field name ("RPA[0]"). Am I using this correctly or
> is there something else I am missing?
>
> On Tue, Aug 25, 2015 at 3:16 PM Tolen Miller <[email protected]> wrote:
>
>> After looking at the sample provided by Maruan, I noticed that I was not
>> passing in a File object, when calling the PDDocument.load() method. Doing
>> so, I now get the same result from Maruan's code (in eclipse).
>>
>> Now I am unsure how to get *all* of the fields from the PDAcroForm. I am
>> trying to get a collection of the fields, so I can loop through them. When
>> I add this code:
>>
>> List<PDField> pdfFields = form.getFields();
>> for (PDField field : pdfFields) {
>> System.out.println("PDF Field Full Name: ".concat(field
>> .getFullyQualifiedName()));
>> }
>>
>>
>> I get the same single field name ("RPA[0]"). Am I using this correctly or
>> is there something else I am missing?
>>
>>
>>
>> On Tue, Aug 25, 2015 at 8:42 AM, Tolen Miller <[email protected]>
>> wrote:
>>
>>> I'm sorry Maruan. My email client did not show me your response, when I
>>> looked at it yesterday. Now (in gmail) I can see your response below mine.
>>>
>>> Allow me to respond to your questions: I am using PDFBox version 1.8.10,
>>> so I utilized your suggested PDAcroForm.getXFA() and it did return null.
>>> This is expected, as I created the PDF in LiveCycle as a "Static PDF."
>>>
>>> My intention is to store a template (linked previously) on the server's
>>> disk and have server side code run and call PDFBox's API. My implementation
>>> would loop through the fields in the document being passed (no sql db) and
>>> ideally look for field name based matches using PDAcroForm.getField() and
>>> if a match is found on the pdf, set the value.
>>>
>>>
>>> On Mon, Aug 24, 2015 at 12:36 AM, Maruan Sahyoun <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>>> Am 24.08.2015 um 09:15 schrieb Tolen Miller <[email protected]>:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I am trying to load a fillable pdf file I created (using LiveCycle),
>>>> but cannot seem to get a hold of the fields. Is there anything obviously
>>>> wrong with the code below or could it be my form?
>>>>>
>>>>> PDDocument pdfDoc = new PDDocument();
>>>>> String fileTemplate =
>>>> "D:\\PDFTemplates\\RPA_Template_Test.pdf";
>>>>>
>>>>> try {
>>>>> pdfDoc = PDDocument.load(fileTemplate);
>>>>> PDDocumentCatalog docCatalog =
>>>> pdfDoc.getDocumentCatalog();
>>>>> PDAcroForm pdfTemplate = docCatalog.getAcroForm();
>>>>> pdfDoc.getNumberOfPages();
>>>>> List<PDField> pdfFields = pdfTemplate.getFields();
>>>>
>>>> if there is a PDAcroForm but there are no fields it's very likely a
>>>> dynamic XFA form. If you are using PDFBox 2.0.0 you can use
>>>> PDAcroForm.xfaIsDynamic(). If that returns true then you have a dynamic XFA
>>>> form. For PDFBox 1.8.x you can use PDAcroForm.getXFA(). If that is not null
>>>> and getFields() is empty again this means that you have a dynamic XFA form.
>>>> Dynamic XFA forms do not contain 'regular' AcroForm fields.
>>>>
>>>> What is it what you would like to do with the form?
>>>>
>>>> BR
>>>> Maruan
>>>>
>>>>
>>>>> System.out.println( pdfFields.isEmpty() ); //always
>>>> true
>>>>> …
>>>>>
>>>>> Thank you,
>>>>> Tolen Miller
>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]