You can do it like this:

        PDDocument doc = PDDocument.load(new File("Attachment.pdf"));
        PDAcroForm acroform = doc.getDocumentCatalog().getAcroForm();
        acroform.getField("table.0.firstName").setValue("FirstName");
        acroform.getField("table.1.lastName").setValue("LastName");
        doc.save(new File("Attachment-filled.pdf"));

BR
Maruan

 
> Here's the catch:  I may have another file to attach that has a
> continuation of the table in the first file.  I put the examples of the
> main file and the attachment here:  http://www.filedropper.com/acrobatdc_2
>  and here:  http://www.filedropper.com/attachment
> 
> On Tue, Jan 7, 2020 at 12:10 PM Maruan Sahyoun <sahy...@fileaffairs.de>
> wrote:
> 
> > thx - but I was hoping to get a sample with the table like structure you
> > were talking about.
> > 
> > From what I got you should
> > - create fields named row<n>.field e.g. row1.brand, row2.brand ..
> > - get to the fields by using the fully qualified name
> > getField("row1.brand")
> > - set the fields value
> > 
> > BR
> > Maruan
> > 
> > 
> > 
> > 
> > > Here is the URL to get to my test PDF document:
> > > http://www.filedropper.com/acrobatdc
> > > 
> > > On Tue, Jan 7, 2020 at 10:32 AM Maruan Sahyoun <sahy...@fileaffairs.de>
> > > wrote:
> > > 
> > > > if they have the same fully qualified name they will share the same
> > value.
> > > > You need to give them individual names e.g. by
> > > > wrapping the fields in individual parents.
> > > > 
> > > > Could you upload the PDF template in question to a shared hoster so I
> > can
> > > > take a look. Might be easier for me to understand what
> > > > the issue is. I think I got it from your descriptiopn but I might be
> > wrong.
> > > > BR
> > > > Maruan
> > > > 
> > > > 
> > > > > Exactly.  That's the tricky part.  How can I name them individually
> > when
> > > > > the names on the template are static?
> > > > > 
> > > > > On Tue, Jan 7, 2020 at 9:43 AM Maruan Sahyoun <
> > sahy...@fileaffairs.de>
> > > > > wrote:
> > > > > 
> > > > > > if you have mutiple fields but you give them the same name then
> > this
> > > > will
> > > > > > be the same field with multiple occurences (widgets).
> > > > > > If you set the value all occurences will have the same value. To
> > treat
> > > > > > them individually you need to name them individually.
> > > > > > 
> > > > > > BR
> > > > > > Maruan
> > > > > > 
> > > > > > > Yes, that's the naming hierarchy that's discussed here:
> > > > > > > 
> > https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/naming.pdf
> > > > > > > I have done that with a fixed number of form fields.  But, I
> > have to
> > > > take
> > > > > > > it a step further.  I need to reuse the PDF form multiple times.
> > > > This
> > > > > > > means that there will be multiple fields that have the same name.
> > > > If I
> > > > > > > reuse the form fields that have the same name on two different
> > pages,
> > > > > > then
> > > > > > > any values that I set in fields with the same names will be set
> > to
> > > > the
> > > > > > same
> > > > > > > values.  I tried this out with a two simple text fields with the
> > same
> > > > > > > name.  When I type a value into either text field, that value is
> > > > > > > automatically set in the other text field.
> > > > > > > 
> > > > > > > On Tue, Jan 7, 2020 at 9:16 AM Maruan Sahyoun <
> > > > sahy...@fileaffairs.de>
> > > > > > > wrote:
> > > > > > > 
> > > > > > > > Ahen you enter the field names with a period "." as a
> > separator in
> > > > > > Acrobat
> > > > > > > > the name before the separator will be the parent.
> > > > > > > > 
> > > > > > > > So you could call the fields of the first row row1.firstname,
> > > > > > > > row1.lastname  ... second row becomes row2.firstname,
> > > > > > > > row2.lastname ...  or row[0].firstname, row[1].firstname ...
> > > > (Please
> > > > > > note
> > > > > > > > that although that might look like an array notation
> > > > > > > > it's only part of the name).
> > > > > > > > 
> > > > > > > > To access the field you could either use the fully qualified
> > name
> > > > e.g.
> > > > > > > > "row1.lastname". Or if you'd like to go by "row" you
> > > > > > > > could call getField with "row1! and the use getChildren() to
> > get
> > > > the
> > > > > > > > direct child field.
> > > > > > > > 
> > > > > > > > BR
> > > > > > > > Maruan
> > > > > > > > 
> > > > > > > > 
> > > > > > > > In addition naming and position
> > > > > > > > 
> > > > > > > > 
> > > > > > > > > I have created a form template using Adobe Acrobat Pro DC.
> > It's
> > > > just
> > > > > > > > rows
> > > > > > > > > of form fields arranged in a grid.
> > > > > > > > > 
> > > > > > > > > On Tue, Jan 7, 2020 at 8:55 AM Maruan Sahyoun <
> > > > > > sahy...@fileaffairs.de>
> > > > > > > > > wrote:
> > > > > > > > > 
> > > > > > > > > > You can nest form fields. How do you generate the form
> > > > template?
> > > > > > > > > > BR
> > > > > > > > > > Maruan
> > > > > > > > > > 
> > > > > > > > > > > Hi all,
> > > > > > > > > > > 
> > > > > > > > > > > Thanks in advance for your help.
> > > > > > > > > > > 
> > > > > > > > > > > Is there a way to group form fields (i.e. subclasses of
> > > > PDField)
> > > > > > into
> > > > > > > > > > rows,
> > > > > > > > > > > sort of like grouping HTML elements in a <div>?  My
> > > > requirement
> > > > > > is to
> > > > > > > > > > > prefill a PDF file with rows of form fields in Acrobat
> > Pro
> > > > DC,
> > > > > > and
> > > > > > > > then
> > > > > > > > > > use
> > > > > > > > > > > PDFBox to fill in the rows of fields with data from Java
> > > > > > objects.  I
> > > > > > > > also
> > > > > > > > > > > have to be able to reuse the same PDF file to add more
> > rows
> > > > of
> > > > > > data
> > > > > > > > until
> > > > > > > > > > > the data runs out.
> > > > > > > > > > > 
> > > > > > > > > > > I've searched the mailing list, and couldn't find it.
> > > > > > > > > > > 
> > > > > > > > > > > Thanks,
> > > > > > > > > > > Rob
> > > > > > > > > > --
> > > > > > > > > > Maruan Sahyoun
> > > > > > > > > > 
> > > > > > > > > > FileAffairs GmbH
> > > > > > > > > > Josef-Schappe-Straße 21
> > > > > > > > > > 40882 Ratingen
> > > > > > > > > > 
> > > > > > > > > > Tel: +49 (2102) 89497 88
> > > > > > > > > > Fax: +49 (2102) 89497 91
> > > > > > > > > > sahy...@fileaffairs.de
> > > > > > > > > > www.fileaffairs.de
> > > > > > > > > > 
> > > > > > > > > > Geschäftsführer: Maruan Sahyoun
> > > > > > > > > > Handelsregister: AG Düsseldorf, HRB 53837
> > > > > > > > > > UST.-ID: DE248275827
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > ---------------------------------------------------------------------
> > > > > > > > > > To unsubscribe, e-mail:
> > users-unsubscr...@pdfbox.apache.org
> > > > > > > > > > For additional commands, e-mail:
> > users-h...@pdfbox.apache.org
> > > > > > > > > > 
> > > > ---------------------------------------------------------------------
> > > > > > > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> > > > > > > > For additional commands, e-mail: users-h...@pdfbox.apache.org
> > > > > > > > 
> > > > > > > > 
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> > > > > > For additional commands, e-mail: users-h...@pdfbox.apache.org
> > > > > > 
> > > > > > 
> > > > 
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> > > > For additional commands, e-mail: users-h...@pdfbox.apache.org
> > > > 
> > > > 
> > --
> > Maruan Sahyoun
> > 
> > FileAffairs GmbH
> > Josef-Schappe-Straße 21
> > 40882 Ratingen
> > 
> > Tel: +49 (2102) 89497 88
> > Fax: +49 (2102) 89497 91
> > sahy...@fileaffairs.de
> > www.fileaffairs.de
> > 
> > Geschäftsführer: Maruan Sahyoun
> > Handelsregister: AG Düsseldorf, HRB 53837
> > UST.-ID: DE248275827
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> > For additional commands, e-mail: users-h...@pdfbox.apache.org
> > 
> > 
-- 
Maruan Sahyoun

FileAffairs GmbH
Josef-Schappe-Straße 21
40882 Ratingen

Tel: +49 (2102) 89497 88
Fax: +49 (2102) 89497 91
sahy...@fileaffairs.de
www.fileaffairs.de

Geschäftsführer: Maruan Sahyoun
Handelsregister: AG Düsseldorf, HRB 53837
UST.-ID: DE248275827


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

Reply via email to