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 86887189F3 for ; Sun, 3 May 2015 07:17:42 +0000 (UTC) Received: (qmail 18766 invoked by uid 500); 3 May 2015 07:17:42 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 18744 invoked by uid 500); 3 May 2015 07:17:42 -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 18729 invoked by uid 99); 3 May 2015 07:17:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 May 2015 07:17:42 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: message received from 54.76.25.247 which is an MX secondary for users@pdfbox.apache.org) Received: from [54.76.25.247] (HELO mx1-eu-west.apache.org) (54.76.25.247) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 May 2015 07:17:14 +0000 Received: from www168.your-server.de (www168.your-server.de [213.133.104.168]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 82F7B25340 for ; Sun, 3 May 2015 07:17:13 +0000 (UTC) Received: from [88.198.220.130] (helo=sslproxy01.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 1Yoo9J-0006Yj-3H for users@pdfbox.apache.org; Sun, 03 May 2015 09:17:13 +0200 Received: from [79.242.96.191] (helo=mbp001.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80) (envelope-from ) id 1Yoo9F-0006qG-O5 for users@pdfbox.apache.org; Sun, 03 May 2015 09:17:09 +0200 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Subject: Re: AcroForm orientation From: Maruan Sahyoun In-Reply-To: <5544AEB6.9030600@t-online.de> Date: Sun, 3 May 2015 09:17:04 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <5B2D9226-2C3E-4E77-B984-D993B826D9B5@fileaffairs.de> References: <335928104.920746616.1430310399236.JavaMail.root@zimbra65-e11.priv.proxad.net> <5544AEB6.9030600@t-online.de> 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/20409/Sun May 3 06:37:23 2015) X-Virus-Checked: Checked by ClamAV on apache.org Hi, > Am 02.05.2015 um 13:02 schrieb Tilman Hausherr = : >=20 > Am 29.04.2015 um 14:26 schrieb phiroc@free.fr: >>=20 >> Hello, >>=20 >> when you add an AcroForm to a document that has a 90 degree = orientation, does the form automatically have a 90 degree orientation? >>=20 >> What about it fields? >>=20 >> My problem with the code below is that the fields' data are printed = vertically instead of horizontally. >=20 > Seems not to be supported: > = http://stackoverflow.com/questions/16952710/filling-landscape-pdf-with-pdf= box I've created https://issues.apache.org/jira/browse/PDFBOX-2785 for that.=20= @ Philippe - could you attach your form to that issue so that we have a = sample as there are different ways that rotation can be defined. BR Maruan >=20 > Tilman >=20 >=20 >>=20 >> Many thanks. >>=20 >> Philippe >>=20 >>=20 >> // Loop through CSV lines and retrieve each line's data >> for (Map pdfLineTreeMap : = csvDataArrayList) { >>=20 >> // Retrieve template's catalog >> final PDDocumentCatalog templateCatalog =3D = PDDocument.load(pdfTemplateFilePath).getDocumentCatalog(); >> // Retrieve its acroForm >> final PDAcroForm templateAcroForm =3D = templateCatalog.getAcroForm(); >>=20 >> // Get all template PDF's pages >> final List templateCatalogPages =3D = templateCatalog.getAllPages(); >> // Get template document's first page >> final PDPage templateFirstPage =3D = templateCatalogPages.get(0); >> LOGGER.info("Template page rotation " + = templateFirstPage.getRotation()); >>=20 >> // Add first page to final doc with filled out = fields >> finalDoc.addPage(templateFirstPage); >> List pages =3D = finalDoc.getDocumentCatalog().getAllPages(); >> final int pageCount =3D pages.size(); >> final PDPage lastPage =3D pages.get(pageCount - = 1); >> LOGGER.info("last page rotation =3D " + = lastPage.getRotation()); >>=20 >> // Loop through PDF field names in = pdfLineTreeMap (this map was previously >> // created to store the CSV data; its keys are = equal to the >> // PDF field names) and set their respective = values in PDF >> for (String fieldName : pdfLineTreeMap.keySet()) = { >>=20 >> final String fieldValue =3D = pdfLineTreeMap.get(fieldName); >> // Try to retrieve the field in the = template's acroForm with the same name >> // as the column in csvDataArrayList >> final PDField pDField =3D = templateAcroForm.getField(fieldName); >>=20 >> // field with same name in CSV as in PDF = was found... >> if (pDField !=3D null) { >>=20 >> // Only circle non-empty = insertion codes >> if (fieldName.indexOf("INSERT") = >=3D 0 && fieldValue !=3D null && fieldValue.length() > 0) { >> circleField(pDField, = templateFirstPage); >> } >> // add increment to it's partial = name >> pDField.setPartialName(fieldName = + "-" + Integer.toString(csvLineCounter)); >> = pDField.setValue(fieldValue.trim()); >> //pDField.setReadonly(true); >>=20 >> finalDocFields.add(pDField); >> } >>=20 >> } // end for fieldName >>=20 >> // Page number is in templateAcroForm (but not = in pdfLineTreeMap) >> final PDField pDPageField =3D = templateAcroForm.getField("pagenumber"); >> if (pDPageField !=3D null) { >> pDPageField.setPartialName("pagenumber" = + Integer.toString(csvLineCounter)); >> = pDPageField.setValue(Integer.toString(csvLineCounter + 1)); >> //pDPageField.setReadonly(true); >> finalDocFields.add(pDPageField); >> } >>=20 >> // Stop at second CSV line for debugging !!!!! >> if (csvLineCounter =3D=3D 2) { >> break; >> } >>=20 >> ++csvLineCounter; >>=20 >> } // end for CSV Lines >>=20 >> // Create new form in final document >> final PDAcroForm finalDocAcroForm =3D new = PDAcroForm(finalDoc); >> // Set final document's form >> = finalDoc.getDocumentCatalog().setAcroForm(finalDocAcroForm); >> // Set form's fields >> finalDocAcroForm.setFields(finalDocFields); >> =09 >> // Save final doc >> finalDoc.save(finalDocFilePath); >> finalDoc.close(); >>=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