pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: Filling out PDPage forms
Date Tue, 21 Apr 2015 13:39:37 GMT
OK,

> Am 21.04.2015 um 15:04 schrieb phiroc@free.fr:
> 
> Hi,
> 
> unfortunately, once I have imported several copies of the source PDF form page into the
destination PDF, PDDocument.getDocumentCatalog().getAcroForm() returns null.
> 

so you have only imported the pages but not the AcroForm. If you import the AcroForm this
will only have the fields pointing to the source page. You need to create new fields from
the ones you have with unique names as I assume the fields on subsequent pages shall have
their own content.  There is a sample available at http://stackoverflow.com/questions/29371129/java-pdfbox-fill-out-pdf-form-append-it-to-pddocument-and-repeat/29417945#29417945
<http://stackoverflow.com/questions/29371129/java-pdfbox-fill-out-pdf-form-append-it-to-pddocument-and-repeat/29417945#29417945>

BR

Maruan


> 
> 
> ----- Mail original -----
> De: "Maruan Sahyoun" <sahyoun@fileaffairs.de>
> À: users@pdfbox.apache.org
> Envoyé: Mardi 21 Avril 2015 14:53:48
> Objet: Re: Filling out PDPage forms
> 
> Hi,
> 
>> Am 21.04.2015 um 12:35 schrieb phiroc@free.fr:
>> 
>> 
>> The source PDF contains a form which I need to make multiple copies of, in the destination
PDF.
>> 
>> I have adapted code found on Stack Overflow to retrieve the source PDF's first page:
>> 
>> PDPage firstPage = (PDPage) templatePDDocument.getDocumentCatalog().getAllPages().get(0);
>> ...
>> 
>> and then to import it into the destination PDF:
>> 
>> PDPage clonedPDPage = clonedDocument.importPage(firstPage);
>> ...
>> 
>> The destination PDF now contains several copies of the form.
>> 
>> I now need to fill out the forms with data from a CSV file.
>> 
>> How do I retrieve each page's form field, given that there's no PDPage.getAcroForm()
function?
> 
> AcroForms are not page related as a field can appear on multiple pages. You need to use
doc.getDocumentCatalog().getAcroForm() to retrieve the form.
> 
> 
> BR
> Maruan
> 
>> 
>> Cheers,
>> 
>> Philippe
>> 
>> 
>> ----- Mail original -----
>> De: phiroc@free.fr
>> À: users@pdfbox.apache.org
>> Envoyé: Mardi 21 Avril 2015 11:32:27
>> Objet: Copying PDPages
>> 
>> Hello,
>> 
>> I would like to copy several times the first page of a PDF document to another.
>> 
>> What is the best way to do this?
>> 
>> Many thanks.
>> 
>> Philippe
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message