pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object
Date Thu, 11 Aug 2016 13:14:46 GMT
Hi,

> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yoav.ts@intango.com>:
> 
> Hi,
> 
> I am using PDFBox version 2.0.1 to dynamically update the fields of an
> existing PDF document. When I'm trying to fill one of the fields with a
> String that contains New Line character the following exception is thrown:
> 
> java.lang.IllegalArgumentException: U+000D ('controlCR') is not available
> in this font's encoding: StandardEncoding with differences
> at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:345)
> at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
> at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
> at
> org.apache.pdfbox.pdmodel.interactive.form.PlainText$Paragraph.getLines(PlainText.java:169)
> at
> org.apache.pdfbox.pdmodel.interactive.form.PlainTextFormatter.format(PlainTextFormatter.java:182)
> at
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:373)
> at
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceContent(AppearanceGeneratorHelper.java:237)
> at
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:144)
> at
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:263)
> at
> org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField.applyChange(PDTerminalField.java:225)
> at
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDTextField.java:218)
> at
> com.myadwise.db.dao.FinancialTransactionMgr.createInvoice(FinancialTransactionMgr.java:525)
> 
> The API call that I'm using to insert the string into the field is:
> 
> PDDocument pdfDocument = PDDocument.load(<PATH_TO_TEMPLATE_PDF_FILE); //PDF
> file was created as a template using Adobe DC
> 
> PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
> 
> acroForm.getField("invoice.to.address").setValue(billingAddress)

could you upload a sample form to a public location? 

BR
Maruan

> 
> 
> The last line is the one that throws the exception if the billingAddress
> String contains a '/n' or a New Line (or Carriage Return) character.
> I have searched for similar issues but couldn't find many references.
> 
> Any help would be appreciated!
> Thanks,
> Yoav


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message