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 6476A189C1 for ; Wed, 29 Apr 2015 12:27:36 +0000 (UTC) Received: (qmail 17527 invoked by uid 500); 29 Apr 2015 12:27:36 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 17504 invoked by uid 500); 29 Apr 2015 12:27:35 -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 17493 invoked by uid 99); 29 Apr 2015 12:27:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2015 12:27:35 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [54.76.25.247] (HELO mx1-eu-west.apache.org) (54.76.25.247) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2015 12:27:08 +0000 Received: from smtp4-g21.free.fr (smtp4-g21.free.fr [212.27.42.4]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id B798027FF9 for ; Wed, 29 Apr 2015 12:26:46 +0000 (UTC) Received: from zimbra65-e11.priv.proxad.net (unknown [172.20.243.215]) by smtp4-g21.free.fr (Postfix) with ESMTP id D1C8C4C8064 for ; Wed, 29 Apr 2015 14:23:57 +0200 (CEST) Date: Wed, 29 Apr 2015 14:26:39 +0200 (CEST) From: phiroc@free.fr To: users@pdfbox.apache.org Message-ID: <335928104.920746616.1430310399236.JavaMail.root@zimbra65-e11.priv.proxad.net> In-Reply-To: <1499203560.920741338.1430310229057.JavaMail.root@zimbra65-e11.priv.proxad.net> Subject: AcroForm orientation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [217.69.22.197] X-Mailer: Zimbra 7.2.0-GA2598 (ZimbraWebClient - FF3.0 (Win)/7.2.0-GA2598) X-Authenticated-User: phiroc@free.fr X-Virus-Checked: Checked by ClamAV on apache.org Hello, when you add an AcroForm to a document that has a 90 degree orientation, does the form automatically have a 90 degree orientation? What about it fields? My problem with the code below is that the fields' data are printed vertically instead of horizontally. Many thanks. Philippe // Loop through CSV lines and retrieve each line's data for (Map pdfLineTreeMap : csvDataArrayList) { // Retrieve template's catalog final PDDocumentCatalog templateCatalog = PDDocument.load(pdfTemplateFilePath).getDocumentCatalog(); // Retrieve its acroForm final PDAcroForm templateAcroForm = templateCatalog.getAcroForm(); // Get all template PDF's pages final List templateCatalogPages = templateCatalog.getAllPages(); // Get template document's first page final PDPage templateFirstPage = templateCatalogPages.get(0); LOGGER.info("Template page rotation " + templateFirstPage.getRotation()); // Add first page to final doc with filled out fields finalDoc.addPage(templateFirstPage); List pages = finalDoc.getDocumentCatalog().getAllPages(); final int pageCount = pages.size(); final PDPage lastPage = pages.get(pageCount - 1); LOGGER.info("last page rotation = " + lastPage.getRotation()); // 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()) { final String fieldValue = 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 = templateAcroForm.getField(fieldName); // field with same name in CSV as in PDF was found... if (pDField != null) { // Only circle non-empty insertion codes if (fieldName.indexOf("INSERT") >= 0 && fieldValue != 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); finalDocFields.add(pDField); } } // end for fieldName // Page number is in templateAcroForm (but not in pdfLineTreeMap) final PDField pDPageField = templateAcroForm.getField("pagenumber"); if (pDPageField != null) { pDPageField.setPartialName("pagenumber" + Integer.toString(csvLineCounter)); pDPageField.setValue(Integer.toString(csvLineCounter + 1)); //pDPageField.setReadonly(true); finalDocFields.add(pDPageField); } // Stop at second CSV line for debugging !!!!! if (csvLineCounter == 2) { break; } ++csvLineCounter; } // end for CSV Lines // Create new form in final document final PDAcroForm finalDocAcroForm = new PDAcroForm(finalDoc); // Set final document's form finalDoc.getDocumentCatalog().setAcroForm(finalDocAcroForm); // Set form's fields finalDocAcroForm.setFields(finalDocFields); // Save final doc finalDoc.save(finalDocFilePath); finalDoc.close(); --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org