Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 110B717B93 for ; Tue, 21 Apr 2015 18:33:54 +0000 (UTC) Received: (qmail 33690 invoked by uid 500); 21 Apr 2015 18:33:53 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 33668 invoked by uid 500); 21 Apr 2015 18:33:53 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 33657 invoked by uid 99); 21 Apr 2015 18:33:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 18:33:53 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: message received from 54.191.145.13 which is an MX secondary for users@pdfbox.apache.org) Received: from [54.191.145.13] (HELO mx1-us-west.apache.org) (54.191.145.13) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Apr 2015 18:33:47 +0000 Received: from www168.your-server.de (www168.your-server.de [213.133.104.168]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 5317225F7A for ; Tue, 21 Apr 2015 18:30:55 +0000 (UTC) Received: from [88.198.220.132] (helo=sslproxy03.your-server.de) by www168.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.80.1) (envelope-from ) id 1YkcvX-0002ze-R5 for users@pdfbox.apache.org; Tue, 21 Apr 2015 20:29:43 +0200 Received: from [79.242.97.92] (helo=mbp001.fritz.box) by sslproxy03.your-server.de with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80) (envelope-from ) id 1YkcvU-0001P2-9j for users@pdfbox.apache.org; Tue, 21 Apr 2015 20:29:40 +0200 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Subject: Re: Filling out PDPage forms From: Maruan Sahyoun In-Reply-To: <1090365533.900561784.1429632909448.JavaMail.root@zimbra65-e11.priv.proxad.net> Date: Tue, 21 Apr 2015 20:29:36 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <720330A2-4E6B-4FA8-AF7C-B208446099C0@fileaffairs.de> References: <1090365533.900561784.1429632909448.JavaMail.root@zimbra65-e11.priv.proxad.net> To: users@pdfbox.apache.org X-Mailer: Apple Mail (2.2098) X-Authenticated-Sender: sahyoun@fileaffairs.de X-Virus-Scanned: Clear (ClamAV 0.98.5/20355/Tue Apr 21 12:36:31 2015) X-Virus-Checked: Checked by ClamAV on apache.org Hi, > Am 21.04.2015 um 18:15 schrieb phiroc@free.fr: >=20 >=20 > Hi Maruan, >=20 > I have tried importing the form using LayerUtility.importPageAsForm(), = into the destination PDF, as follows (sorry, Scala code, but = comprehensible). No, this will give you a page you can mount not another one - has = nothing to do with AcroForm. Did you follow the stack overflow post I mentioned? BR Maruan >=20 > However, the page is blank. >=20 > Is importPageAsForm the right method to import a form? >=20 > Cheers, >=20 > Philippe >=20 >=20 > -------------------------------------------------- > import org.apache.pdfbox.pdmodel._ > import org.apache.pdfbox.util._ > import org.apache.pdfbox.pdmodel.common.PDRectangle >=20 > object App { >=20 > def main(args: Array[String]) =3D { >=20 > val pathToPdfTemplateFile =3D = "D:\\dev\\ProjectData\\fillbundlelabelformData\\pdf\\template\\LO_Labels21= 0315_formulaire.pdf" > val pathToClonedFile =3D = "D:\\dev\\ProjectData\\fillbundlelabelformData\\pdf\\generated\\clone.pdf"= > =09 > val templatePDDocument =3D = PDDocument.load(pathToPdfTemplateFile) > val clonedDocument =3D new PDDocument > val pDPage =3D new PDPage(new PDRectangle(612, 792)) > clonedDocument.addPage(pDPage) > val aLayerUtility =3D new LayerUtility(clonedDocument) > val aPDXObjectForm =3D = aLayerUtility.importPageAsForm(templatePDDocument, 0) =20 > clonedDocument.save(pathToClonedFile) > clonedDocument.close > templatePDDocument.close > =09 > } >=20 > } > ---------------------------------------------------------- >=20 >=20 >=20 > ----- Mail original ----- > De: "Maruan Sahyoun" > =C3=80: users@pdfbox.apache.org > Envoy=C3=A9: Mardi 21 Avril 2015 15:39:37 > Objet: Re: Filling out PDPage forms >=20 > OK, >=20 >> Am 21.04.2015 um 15:04 schrieb phiroc@free.fr: >>=20 >> Hi, >>=20 >> unfortunately, once I have imported several copies of the source PDF = form page into the destination PDF, = PDDocument.getDocumentCatalog().getAcroForm() returns null. >>=20 >=20 > 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 = >=20 > BR >=20 > Maruan >=20 >=20 >>=20 >>=20 >> ----- Mail original ----- >> De: "Maruan Sahyoun" >> =C3=80: users@pdfbox.apache.org >> Envoy=C3=A9: Mardi 21 Avril 2015 14:53:48 >> Objet: Re: Filling out PDPage forms >>=20 >> Hi, >>=20 >>> Am 21.04.2015 um 12:35 schrieb phiroc@free.fr: >>>=20 >>>=20 >>> The source PDF contains a form which I need to make multiple copies = of, in the destination PDF. >>>=20 >>> I have adapted code found on Stack Overflow to retrieve the source = PDF's first page: >>>=20 >>> PDPage firstPage =3D (PDPage) = templatePDDocument.getDocumentCatalog().getAllPages().get(0); >>> ... >>>=20 >>> and then to import it into the destination PDF: >>>=20 >>> PDPage clonedPDPage =3D clonedDocument.importPage(firstPage); >>> ... >>>=20 >>> The destination PDF now contains several copies of the form. >>>=20 >>> I now need to fill out the forms with data from a CSV file. >>>=20 >>> How do I retrieve each page's form field, given that there's no = PDPage.getAcroForm() function? >>=20 >> AcroForms are not page related as a field can appear on multiple = pages. You need to use doc.getDocumentCatalog().getAcroForm() to = retrieve the form. >>=20 >>=20 >> BR >> Maruan >>=20 >>>=20 >>> Cheers, >>>=20 >>> Philippe >>>=20 >>>=20 >>> ----- Mail original ----- >>> De: phiroc@free.fr >>> =C3=80: users@pdfbox.apache.org >>> Envoy=C3=A9: Mardi 21 Avril 2015 11:32:27 >>> Objet: Copying PDPages >>>=20 >>> Hello, >>>=20 >>> I would like to copy several times the first page of a PDF document = to another. >>>=20 >>> What is the best way to do this? >>>=20 >>> Many thanks. >>>=20 >>> Philippe >>>=20 >>> = --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >>> For additional commands, e-mail: users-help@pdfbox.apache.org >>>=20 >>>=20 >>> = --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >>> For additional commands, e-mail: users-help@pdfbox.apache.org >>>=20 >>=20 >>=20 >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >> For additional commands, e-mail: users-help@pdfbox.apache.org >>=20 >>=20 >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >> For additional commands, e-mail: users-help@pdfbox.apache.org >>=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org