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 CEAA2DF92 for ; Fri, 12 Oct 2012 06:04:07 +0000 (UTC) Received: (qmail 46984 invoked by uid 500); 12 Oct 2012 06:04:07 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 46540 invoked by uid 500); 12 Oct 2012 06:04:02 -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 46503 invoked by uid 99); 12 Oct 2012 06:04:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2012 06:04:00 +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: domain of EChang@bonafide.com designates 65.203.133.78 as permitted sender) Received: from [65.203.133.78] (HELO mail.bonafide.com) (65.203.133.78) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2012 06:03:56 +0000 Received: from ex2007.BONAFIDE.COM ([172.18.88.58]) by ex2007.BONAFIDE.COM ([172.18.88.58]) with mapi; Thu, 11 Oct 2012 23:03:35 -0700 From: Eugene Chang To: "users@pdfbox.apache.org" , Joe Lee Date: Thu, 11 Oct 2012 23:03:46 -0700 Subject: RE: Font being changed after form field is set Thread-Topic: Font being changed after form field is set Thread-Index: Ac2n9Dx0nEpKcffOSAqUTjizPbaKPgASpx7A Message-ID: References: <51323DC3B3CE2949954A661DF3B64C6621F8363FD1@COLOMAILSERVER.coloservices.net> <51323DC3B3CE2949954A661DF3B64C6621F83D0C4C@COLOMAILSERVER.coloservices.net> <1349989540.10714.YahooMailNeo@web110010.mail.gq1.yahoo.com> In-Reply-To: <1349989540.10714.YahooMailNeo@web110010.mail.gq1.yahoo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org I tried, but it does not solve the problem. Thanks anyway. -----Original Message----- From: Joe Lee [mailto:joe_h_lee@yahoo.com]=20 Sent: Thursday, October 11, 2012 2:06 PM To: users@pdfbox.apache.org Subject: Re: Font being changed after form field is set Please check this attached Email information. I have similar problem as you= rs. Try to apply the patch stated in PDFBOX-1402 bug report. It helps my pr= oblem to some degree but not fully fix the problem. Joe Lee ---------------------------------------------------------------------------= ---------- =A0 [=A0https://issues.apache.org/jira/browse/PDFBOX-1419?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1= 3469564#comment-13469564=A0]=A0 Will May commented on PDFBOX-1419: ---------------------------------- This is a duplicate of PDFBOX-1402. The current implementation doesn't hand= le zero font size (which means 'auto' font size) and multi-line text boxes = correctly (it also doesn't break long lines either). The patch I've attached to the PDFBOX-1402 doesn't position the text or sel= ect the correct font size perfectly but is a significantly better than the = current implementation. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 > PDField.setValue is not behave correctly > ---------------------------------------- > >=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Key: PDFBOX-1419 >=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 URL:=A0https://issues.apache.org/jira/brow= se/PDFBOX-1419 >=A0 =A0 =A0 =A0 =A0 =A0 Project: PDFBox >=A0 =A0 =A0 =A0 =A0 Issue Type: Bug >=A0 =A0 =A0 =A0 =A0 Components: Writing >=A0 =A0 Affects Versions: 1.7.0 >=A0 =A0 =A0 =A0 Environment: JavaEE 1.6 project developed under Window sys= tem, will deploy to Unix Weblogic server >=A0 =A0 =A0 =A0 =A0 =A0 Reporter: Joe Lee > > Use a template PDF file to write value into different fields (type of PDT= extbox, PDCheckbox, PDChoiceField). The PDTextbox displays either very larg= e font or not show anything. If click into the field, it displays correctly= . Click outside the field, it reverts back to the wrong display. The same l= ogic of code works well with iText library. The code similar to: >=A0 =A0 =A0 =A0 =A0 =A0=A0 >=A0 =A0 =A0 =A0 =A0 =A0 PDFTemplate =3D PDDocument.load("myTemplate.pdf"); >=A0 =A0 =A0 =A0 =A0 =A0 PDDocumentCatalog docCatalog =3D PDFTemplate.getDo= cumentCatalog(); >=A0 =A0 =A0 =A0 =A0 =A0 PDAcroForm acroForm =3D docCatalog.getAcroForm(); >=A0 =A0 =A0 =A0 =A0 =A0 : >=A0 =A0 =A0 =A0 =A0 =A0 try { PDField pdField =3D acroForm.getField(field)= ; >=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pdField !=3D null) pdField.set= Value(value); >=A0 =A0 =A0 =A0 =A0 =A0 } catch(...){} >=A0 =A0 =A0 =A0 =A0 =A0 : ________________________________ From: Eugene Chang To: "users@pdfbox.apache.org" =20 Sent: Thursday, October 11, 2012 11:11 AM Subject: RE: Font being changed after form field is set =20 Hi, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 First I would like to thank Kishore for ans= wering my question, but I think I did not state my problem clearly. So I am= going to try one more time. 1.=A0 =A0 =A0 We have a predefined PDF form, with text fields in it. a.=A0 =A0 =A0 We used Adobe Acrobat Professional to create the PDF form. 2.=A0 =A0 =A0 The font set in the predefined fields are COURIER a.=A0 =A0 =A0 We choose COURIER because of its mono-spaced feature 3.=A0 =A0 =A0 We want to set the values in predefined form fields. So we used pdfbox 1.=A0 =A0 =A0 Load the pdf form 2.=A0 =A0 =A0 Set the value But the problem now is the original font got changed after setting the valu= e. The link Kishore referenced is trying to create new field with font and pla= ce it on the pdf, but our requirement is setting values on existing fields = and retain original font. The original files and tested file: http://www.2shared.com/document/auMD40In/PRP.html http://www.2shared.com/document/SdnqJEFO/forms26916.html The code: package lab; import java.io.File; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocumentCatalog; import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm; public class TestBed1 { =A0 =A0 public static void main(String[] args) { =A0 =A0 =A0 =A0 try { =A0 =A0 =A0 =A0 =A0 =A0 PDDocument pdfDocument =3D PDDocument.load("C:/Temp= /pdf/PRP.pdf"); =A0 =A0 =A0 =A0 =A0 =A0 PDDocumentCatalog docCatalog =3D pdfDocument.getDoc= umentCatalog(); =A0 =A0 =A0 =A0 =A0 =A0 PDAcroForm acroForm =3D docCatalog.getAcroForm(); =A0 =A0 =A0 =A0 =A0 =A0 acroForm.getField("officeAfterHourAndTollFree").set= Value( =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Phone: (805) 777-7666=A0 Fax: (805= ) 777-9876"); =A0 =A0 =A0 =A0 =A0 =A0 File file =3D File.createTempFile("forms", ".pdf"); =A0 =A0 =A0 =A0 =A0 =A0 pdfDocument.save(file.getCanonicalPath()); =A0 =A0 =A0 =A0 =A0 =A0 pdfDocument.close(); =A0 =A0 =A0 =A0 =A0 =A0 System.out.println(file.getCanonicalPath()); =A0 =A0 =A0 =A0 } catch (Exception e) { =A0 =A0 =A0 =A0 =A0 =A0 e.printStackTrace(); =A0 =A0 =A0 =A0 } =A0 =A0 } } Regards,