The new-line character is "\n", not "/n"... And maybe it will work with
"\r", instead.

On Thu, Aug 11, 2016 at 3:14 PM, Maruan Sahyoun <[email protected]>
wrote:

> Hi,
>
> > Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <[email protected]>:
> >
> > 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to