You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Yoav Tsoref <yo...@intango.com> on 2016/08/11 12:56:26 UTC

Unable to Set a String containing New Line Character into PDFBox PDTextField Object

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)


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

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Yoav Tsoref <yo...@intango.com>.
Probably. Removing the \r did the work

> On 11 Aug 2016, at 22:14, Gilad Denneboom <gi...@gmail.com> wrote:
> 
> So your original code had "\r\n" as the line-break?
> 
>> On Thu, Aug 11, 2016 at 6:22 PM, Yoav Tsoref <yo...@intango.com> wrote:
>> 
>> Thank you very much!!!
>> I did a quick test of removing only the \r and it is working for me good.
>> 
>> Thank you.
>> Yoav
>> 
>>> On 11 Aug 2016, at 19:10, Maruan Sahyoun <sa...@fileaffairs.de> wrote:
>>> 
>>> OK - was able to reproduce the issue. If you use \r for line breaking it
>> will not work. Same for combination with \r\n. You need to use \n alone.
>>> 
>>> I've created https://issues.apache.org/jira/browse/PDFBOX-3461 to
>> improve that in a future release.
>>> 
>>> Currently you need to make sure that control characters other than \n
>> are stripped out prior to setting the field value.
>>> 
>>> BR
>>> 
>>> Maruan
>>> 
>>> 
>>> 
>>>> Am 11.08.2016 um 17:36 schrieb Yoav Tsoref <yo...@intango.com>:
>>>> 
>>>> The field is set as multiline. The font is declared in the PDF -
>> Helvetica. I'm not changing the font programmatically...
>>>> 
>>>>> On 11 Aug 2016, at 17:43, Gilad Denneboom <gi...@gmail.com>
>> wrote:
>>>>> 
>>>>> Is the field set as multiline? Also, what font are you using for the
>> text
>>>>> in that field?
>>>>> 
>>>>>> On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com>
>> wrote:
>>>>>> 
>>>>>> Hi,
>>>>>> I placed the PDF template at:
>>>>>> https://drive.google.com/file/d/0B__NK1_
>> B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>>>>> VVVYUJhVk04/view?usp=sharing
>>>>>> <https://drive.google.com/file/d/0B__NK1_
>> B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>>>>> VVVYUJhVk04/view?usp=sharing>
>>>>>> (in this shared folder
>>>>>> <https://drive.google.com/folderview?id=0B__NK1_
>> B6ccjUXRSZVdpSEkyYzg&usp=
>>>>>> sharing>
>>>>>> )
>>>>>> 
>>>>>> You are right regarding the \n of course, this is my mistake. But I
>> am not
>>>>>> generating the \n character in the String, it is generated correctly
>> ("\n")
>>>>>> because it is generated from the keyboard (from the user input).
>>>>>> I tried with \n and \r. "\r" throws an exception that the
>> ('controlLF') is
>>>>>> missing.
>>>>>> 
>>>>>> Thanks,
>>>>>> Yoav
>>>>>> 
>>>>>> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
>>>>>> gilad.denneboom@gmail.com>
>>>>>> wrote:
>>>>>> 
>>>>>>> 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 <
>> sahyoun@fileaffairs.de>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>>> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> --
>>>>>> 
>>>>>> <http://intango.com/>
>>>>>> 
>>>>>> 
>>>>>> *Yoav Tsoref**R&D Projects Manager*
>>>>>> T: +972.3.533.0760 | M: +972.54.227.7208
>>>>>> E: yoav.ts@intango.com | Skype: yoav.ts
>>>>>> www.intango.com
>>>>>> <https://www.facebook.com/Intango-855010531283314>
>>>>>> <https://www.linkedin.com/company/intango>
>>>>>> <https://twitter.com/IntangoMedia>
>>>>>> <https://plus.google.com/u/0/114134833470766396949/about>
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Gilad Denneboom <gi...@gmail.com>.
So your original code had "\r\n" as the line-break?

On Thu, Aug 11, 2016 at 6:22 PM, Yoav Tsoref <yo...@intango.com> wrote:

> Thank you very much!!!
> I did a quick test of removing only the \r and it is working for me good.
>
> Thank you.
> Yoav
>
> > On 11 Aug 2016, at 19:10, Maruan Sahyoun <sa...@fileaffairs.de> wrote:
> >
> > OK - was able to reproduce the issue. If you use \r for line breaking it
> will not work. Same for combination with \r\n. You need to use \n alone.
> >
> > I've created https://issues.apache.org/jira/browse/PDFBOX-3461 to
> improve that in a future release.
> >
> > Currently you need to make sure that control characters other than \n
> are stripped out prior to setting the field value.
> >
> > BR
> >
> > Maruan
> >
> >
> >
> >> Am 11.08.2016 um 17:36 schrieb Yoav Tsoref <yo...@intango.com>:
> >>
> >> The field is set as multiline. The font is declared in the PDF -
> Helvetica. I'm not changing the font programmatically...
> >>
> >>> On 11 Aug 2016, at 17:43, Gilad Denneboom <gi...@gmail.com>
> wrote:
> >>>
> >>> Is the field set as multiline? Also, what font are you using for the
> text
> >>> in that field?
> >>>
> >>>> On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com>
> wrote:
> >>>>
> >>>> Hi,
> >>>> I placed the PDF template at:
> >>>> https://drive.google.com/file/d/0B__NK1_
> B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
> >>>> VVVYUJhVk04/view?usp=sharing
> >>>> <https://drive.google.com/file/d/0B__NK1_
> B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
> >>>> VVVYUJhVk04/view?usp=sharing>
> >>>> (in this shared folder
> >>>> <https://drive.google.com/folderview?id=0B__NK1_
> B6ccjUXRSZVdpSEkyYzg&usp=
> >>>> sharing>
> >>>> )
> >>>>
> >>>> You are right regarding the \n of course, this is my mistake. But I
> am not
> >>>> generating the \n character in the String, it is generated correctly
> ("\n")
> >>>> because it is generated from the keyboard (from the user input).
> >>>> I tried with \n and \r. "\r" throws an exception that the
> ('controlLF') is
> >>>> missing.
> >>>>
> >>>> Thanks,
> >>>> Yoav
> >>>>
> >>>> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
> >>>> gilad.denneboom@gmail.com>
> >>>> wrote:
> >>>>
> >>>>> 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 <
> sahyoun@fileaffairs.de>
> >>>>> wrote:
> >>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>>> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>>
> >>>> <http://intango.com/>
> >>>>
> >>>>
> >>>> *Yoav Tsoref**R&D Projects Manager*
> >>>> T: +972.3.533.0760 | M: +972.54.227.7208
> >>>> E: yoav.ts@intango.com | Skype: yoav.ts
> >>>> www.intango.com
> >>>> <https://www.facebook.com/Intango-855010531283314>
> >>>> <https://www.linkedin.com/company/intango>
> >>>> <https://twitter.com/IntangoMedia>
> >>>> <https://plus.google.com/u/0/114134833470766396949/about>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> > For additional commands, e-mail: users-help@pdfbox.apache.org
> >
>

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Yoav Tsoref <yo...@intango.com>.
Thank you very much!!!
I did a quick test of removing only the \r and it is working for me good.

Thank you.
Yoav

> On 11 Aug 2016, at 19:10, Maruan Sahyoun <sa...@fileaffairs.de> wrote:
> 
> OK - was able to reproduce the issue. If you use \r for line breaking it will not work. Same for combination with \r\n. You need to use \n alone.
> 
> I've created https://issues.apache.org/jira/browse/PDFBOX-3461 to improve that in a future release.
> 
> Currently you need to make sure that control characters other than \n are stripped out prior to setting the field value.
> 
> BR
> 
> Maruan
> 
> 
> 
>> Am 11.08.2016 um 17:36 schrieb Yoav Tsoref <yo...@intango.com>:
>> 
>> The field is set as multiline. The font is declared in the PDF - Helvetica. I'm not changing the font programmatically...
>> 
>>> On 11 Aug 2016, at 17:43, Gilad Denneboom <gi...@gmail.com> wrote:
>>> 
>>> Is the field set as multiline? Also, what font are you using for the text
>>> in that field?
>>> 
>>>> On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com> wrote:
>>>> 
>>>> Hi,
>>>> I placed the PDF template at:
>>>> https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>>> VVVYUJhVk04/view?usp=sharing
>>>> <https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>>> VVVYUJhVk04/view?usp=sharing>
>>>> (in this shared folder
>>>> <https://drive.google.com/folderview?id=0B__NK1_B6ccjUXRSZVdpSEkyYzg&usp=
>>>> sharing>
>>>> )
>>>> 
>>>> You are right regarding the \n of course, this is my mistake. But I am not
>>>> generating the \n character in the String, it is generated correctly ("\n")
>>>> because it is generated from the keyboard (from the user input).
>>>> I tried with \n and \r. "\r" throws an exception that the  ('controlLF') is
>>>> missing.
>>>> 
>>>> Thanks,
>>>> Yoav
>>>> 
>>>> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
>>>> gilad.denneboom@gmail.com>
>>>> wrote:
>>>> 
>>>>> 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 <sa...@fileaffairs.de>
>>>>> wrote:
>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>>> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
>>>> 
>>>> 
>>>> 
>>>> --
>>>> 
>>>> <http://intango.com/>
>>>> 
>>>> 
>>>> *Yoav Tsoref**R&D Projects Manager*
>>>> T: +972.3.533.0760 | M: +972.54.227.7208
>>>> E: yoav.ts@intango.com | Skype: yoav.ts
>>>> www.intango.com
>>>> <https://www.facebook.com/Intango-855010531283314>
>>>> <https://www.linkedin.com/company/intango>
>>>> <https://twitter.com/IntangoMedia>
>>>> <https://plus.google.com/u/0/114134833470766396949/about>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
OK - was able to reproduce the issue. If you use \r for line breaking it will not work. Same for combination with \r\n. You need to use \n alone.

I've created https://issues.apache.org/jira/browse/PDFBOX-3461 to improve that in a future release.

Currently you need to make sure that control characters other than \n are stripped out prior to setting the field value.

BR

Maruan



> Am 11.08.2016 um 17:36 schrieb Yoav Tsoref <yo...@intango.com>:
> 
> The field is set as multiline. The font is declared in the PDF - Helvetica. I'm not changing the font programmatically...
> 
>> On 11 Aug 2016, at 17:43, Gilad Denneboom <gi...@gmail.com> wrote:
>> 
>> Is the field set as multiline? Also, what font are you using for the text
>> in that field?
>> 
>>> On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com> wrote:
>>> 
>>> Hi,
>>> I placed the PDF template at:
>>> https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>> VVVYUJhVk04/view?usp=sharing
>>> <https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>> VVVYUJhVk04/view?usp=sharing>
>>> (in this shared folder
>>> <https://drive.google.com/folderview?id=0B__NK1_B6ccjUXRSZVdpSEkyYzg&usp=
>>> sharing>
>>> )
>>> 
>>> You are right regarding the \n of course, this is my mistake. But I am not
>>> generating the \n character in the String, it is generated correctly ("\n")
>>> because it is generated from the keyboard (from the user input).
>>> I tried with \n and \r. "\r" throws an exception that the  ('controlLF') is
>>> missing.
>>> 
>>> Thanks,
>>> Yoav
>>> 
>>> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
>>> gilad.denneboom@gmail.com>
>>> wrote:
>>> 
>>>> 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 <sa...@fileaffairs.de>
>>>> wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>>> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
>>> 
>>> 
>>> 
>>> --
>>> 
>>> <http://intango.com/>
>>> 
>>> 
>>> *Yoav Tsoref**R&D Projects Manager*
>>> T: +972.3.533.0760 | M: +972.54.227.7208
>>> E: yoav.ts@intango.com | Skype: yoav.ts
>>> www.intango.com
>>> <https://www.facebook.com/Intango-855010531283314>
>>> <https://www.linkedin.com/company/intango>
>>> <https://twitter.com/IntangoMedia>
>>> <https://plus.google.com/u/0/114134833470766396949/about>
>>> 


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


Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

I did a quick test using PDFBox 2.0.3-SNAPSHOT with the folliwing lines of code:


		String billingAddress = "First line\nsecond line\nthird line";
		
		PDDocument pdfDocument = PDDocument.load(new File("invoice_template.pdf"));
		PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
		acroForm.getField("invoice.to.address").setValue(billingAddress);
		pdfDocument.save("invoice_template.pdfbox.pdf");
		pdfDocument.close();

Worked fine for me.

I need to do a quick test using 2.0.1 and 2.0.2 to verify if that was an issue with a previous version (from top of my had I can't remember a specific bug report).

BR
Maruan


> Am 11.08.2016 um 17:36 schrieb Yoav Tsoref <yo...@intango.com>:
> 
> The field is set as multiline. The font is declared in the PDF - Helvetica. I'm not changing the font programmatically...
> 
>> On 11 Aug 2016, at 17:43, Gilad Denneboom <gi...@gmail.com> wrote:
>> 
>> Is the field set as multiline? Also, what font are you using for the text
>> in that field?
>> 
>>> On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com> wrote:
>>> 
>>> Hi,
>>> I placed the PDF template at:
>>> https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>> VVVYUJhVk04/view?usp=sharing
>>> <https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>>> VVVYUJhVk04/view?usp=sharing>
>>> (in this shared folder
>>> <https://drive.google.com/folderview?id=0B__NK1_B6ccjUXRSZVdpSEkyYzg&usp=
>>> sharing>
>>> )
>>> 
>>> You are right regarding the \n of course, this is my mistake. But I am not
>>> generating the \n character in the String, it is generated correctly ("\n")
>>> because it is generated from the keyboard (from the user input).
>>> I tried with \n and \r. "\r" throws an exception that the  ('controlLF') is
>>> missing.
>>> 
>>> Thanks,
>>> Yoav
>>> 
>>> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
>>> gilad.denneboom@gmail.com>
>>> wrote:
>>> 
>>>> 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 <sa...@fileaffairs.de>
>>>> wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>>> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
>>> 
>>> 
>>> 
>>> --
>>> 
>>> <http://intango.com/>
>>> 
>>> 
>>> *Yoav Tsoref**R&D Projects Manager*
>>> T: +972.3.533.0760 | M: +972.54.227.7208
>>> E: yoav.ts@intango.com | Skype: yoav.ts
>>> www.intango.com
>>> <https://www.facebook.com/Intango-855010531283314>
>>> <https://www.linkedin.com/company/intango>
>>> <https://twitter.com/IntangoMedia>
>>> <https://plus.google.com/u/0/114134833470766396949/about>
>>> 


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


Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Gilad Denneboom <gi...@gmail.com>.
I just tried it with 2.0.2 and it worked... Maybe try to upgrade to that
version.

On Thu, Aug 11, 2016 at 5:36 PM, Yoav Tsoref <yo...@intango.com> wrote:

> The field is set as multiline. The font is declared in the PDF -
> Helvetica. I'm not changing the font programmatically...
>
> > On 11 Aug 2016, at 17:43, Gilad Denneboom <gi...@gmail.com>
> wrote:
> >
> > Is the field set as multiline? Also, what font are you using for the text
> > in that field?
> >
> >> On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com>
> wrote:
> >>
> >> Hi,
> >> I placed the PDF template at:
> >> https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
> >> VVVYUJhVk04/view?usp=sharing
> >> <https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
> >> VVVYUJhVk04/view?usp=sharing>
> >> (in this shared folder
> >> <https://drive.google.com/folderview?id=0B__NK1_
> B6ccjUXRSZVdpSEkyYzg&usp=
> >> sharing>
> >> )
> >>
> >> You are right regarding the \n of course, this is my mistake. But I am
> not
> >> generating the \n character in the String, it is generated correctly
> ("\n")
> >> because it is generated from the keyboard (from the user input).
> >> I tried with \n and \r. "\r" throws an exception that the
> ('controlLF') is
> >> missing.
> >>
> >> Thanks,
> >> Yoav
> >>
> >> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
> >> gilad.denneboom@gmail.com>
> >> wrote:
> >>
> >>> 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 <
> sahyoun@fileaffairs.de>
> >>> wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>>> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
> >>
> >>
> >>
> >> --
> >>
> >> <http://intango.com/>
> >>
> >>
> >> *Yoav Tsoref**R&D Projects Manager*
> >> T: +972.3.533.0760 | M: +972.54.227.7208
> >> E: yoav.ts@intango.com | Skype: yoav.ts
> >> www.intango.com
> >> <https://www.facebook.com/Intango-855010531283314>
> >> <https://www.linkedin.com/company/intango>
> >> <https://twitter.com/IntangoMedia>
> >> <https://plus.google.com/u/0/114134833470766396949/about>
> >>
>

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Yoav Tsoref <yo...@intango.com>.
The field is set as multiline. The font is declared in the PDF - Helvetica. I'm not changing the font programmatically...

> On 11 Aug 2016, at 17:43, Gilad Denneboom <gi...@gmail.com> wrote:
> 
> Is the field set as multiline? Also, what font are you using for the text
> in that field?
> 
>> On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com> wrote:
>> 
>> Hi,
>> I placed the PDF template at:
>> https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>> VVVYUJhVk04/view?usp=sharing
>> <https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
>> VVVYUJhVk04/view?usp=sharing>
>> (in this shared folder
>> <https://drive.google.com/folderview?id=0B__NK1_B6ccjUXRSZVdpSEkyYzg&usp=
>> sharing>
>> )
>> 
>> You are right regarding the \n of course, this is my mistake. But I am not
>> generating the \n character in the String, it is generated correctly ("\n")
>> because it is generated from the keyboard (from the user input).
>> I tried with \n and \r. "\r" throws an exception that the  ('controlLF') is
>> missing.
>> 
>> Thanks,
>> Yoav
>> 
>> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
>> gilad.denneboom@gmail.com>
>> wrote:
>> 
>>> 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 <sa...@fileaffairs.de>
>>> wrote:
>>> 
>>>> Hi,
>>>> 
>>>>> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
>> 
>> 
>> 
>> --
>> 
>> <http://intango.com/>
>> 
>> 
>> *Yoav Tsoref**R&D Projects Manager*
>> T: +972.3.533.0760 | M: +972.54.227.7208
>> E: yoav.ts@intango.com | Skype: yoav.ts
>> www.intango.com
>> <https://www.facebook.com/Intango-855010531283314>
>> <https://www.linkedin.com/company/intango>
>> <https://twitter.com/IntangoMedia>
>> <https://plus.google.com/u/0/114134833470766396949/about>
>> 

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Gilad Denneboom <gi...@gmail.com>.
Is the field set as multiline? Also, what font are you using for the text
in that field?

On Thu, Aug 11, 2016 at 3:46 PM, Yoav Tsoref <yo...@intango.com> wrote:

> Hi,
> I placed the PDF template at:
>  https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
> VVVYUJhVk04/view?usp=sharing
> <https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEO
> VVVYUJhVk04/view?usp=sharing>
> (in this shared folder
> <https://drive.google.com/folderview?id=0B__NK1_B6ccjUXRSZVdpSEkyYzg&usp=
> sharing>
> )
>
> You are right regarding the \n of course, this is my mistake. But I am not
> generating the \n character in the String, it is generated correctly ("\n")
> because it is generated from the keyboard (from the user input).
> I tried with \n and \r. "\r" throws an exception that the  ('controlLF') is
> missing.
>
> Thanks,
> Yoav
>
> On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <
> gilad.denneboom@gmail.com>
> wrote:
>
> > 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 <sa...@fileaffairs.de>
> > wrote:
> >
> > > Hi,
> > >
> > > > Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
> > >
> > >
> >
>
>
>
> --
>
> <http://intango.com/>
>
>
> *Yoav Tsoref**R&D Projects Manager*
> T: +972.3.533.0760 | M: +972.54.227.7208
> E: yoav.ts@intango.com | Skype: yoav.ts
> www.intango.com
> <https://www.facebook.com/Intango-855010531283314>
> <https://www.linkedin.com/company/intango>
> <https://twitter.com/IntangoMedia>
> <https://plus.google.com/u/0/114134833470766396949/about>
>

RE: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by "Stahle, Patrick" <pa...@te.com>.
Just off the top of my head whenever I wrote text into a PDF using PDFBox I had to remove carriage returns / line feeds and had to do the line breaks myself by moving the start position of the next line of text.  

-----Original Message-----
From: Yoav Tsoref [mailto:yoav.ts@intango.com] 
Sent: Thursday, August 11, 2016 9:47 AM
To: users@pdfbox.apache.org
Subject: Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Hi,
I placed the PDF template at:
 https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEOVVVYUJhVk04/view?usp=sharing
<https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEOVVVYUJhVk04/view?usp=sharing>
(in this shared folder
<https://drive.google.com/folderview?id=0B__NK1_B6ccjUXRSZVdpSEkyYzg&usp=sharing>
)

You are right regarding the \n of course, this is my mistake. But I am not generating the \n character in the String, it is generated correctly ("\n") because it is generated from the keyboard (from the user input).
I tried with \n and \r. "\r" throws an exception that the  ('controlLF') is missing.

Thanks,
Yoav

On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <gi...@gmail.com>
wrote:

> 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 
> <sa...@fileaffairs.de>
> wrote:
>
> > Hi,
> >
> > > Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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.form
> > > at(
> > 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
> >
> >
>



-- 

<http://intango.com/>


*Yoav Tsoref**R&D Projects Manager*
T: +972.3.533.0760 | M: +972.54.227.7208
E: yoav.ts@intango.com | Skype: yoav.ts
www.intango.com
<https://www.facebook.com/Intango-855010531283314>
<https://www.linkedin.com/company/intango>
<https://twitter.com/IntangoMedia>
<https://plus.google.com/u/0/114134833470766396949/about>

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Yoav Tsoref <yo...@intango.com>.
Hi,
I placed the PDF template at:
 https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEOVVVYUJhVk04/view?usp=sharing
<https://drive.google.com/file/d/0B__NK1_B6ccjVXgxekNLLUxKMzMyS0c5LTBEOVVVYUJhVk04/view?usp=sharing>
(in this shared folder
<https://drive.google.com/folderview?id=0B__NK1_B6ccjUXRSZVdpSEkyYzg&usp=sharing>
)

You are right regarding the \n of course, this is my mistake. But I am not
generating the \n character in the String, it is generated correctly ("\n")
because it is generated from the keyboard (from the user input).
I tried with \n and \r. "\r" throws an exception that the  ('controlLF') is
missing.

Thanks,
Yoav

On Thu, Aug 11, 2016 at 4:34 PM, Gilad Denneboom <gi...@gmail.com>
wrote:

> 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 <sa...@fileaffairs.de>
> wrote:
>
> > Hi,
> >
> > > Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
> >
> >
>



-- 

<http://intango.com/>


*Yoav Tsoref**R&D Projects Manager*
T: +972.3.533.0760 | M: +972.54.227.7208
E: yoav.ts@intango.com | Skype: yoav.ts
www.intango.com
<https://www.facebook.com/Intango-855010531283314>
<https://www.linkedin.com/company/intango>
<https://twitter.com/IntangoMedia>
<https://plus.google.com/u/0/114134833470766396949/about>

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Gilad Denneboom <gi...@gmail.com>.
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 <sa...@fileaffairs.de>
wrote:

> Hi,
>
> > Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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
>
>

Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

> Am 11.08.2016 um 14:56 schrieb Yoav Tsoref <yo...@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


Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
> Am 11.08.2016 um 17:53 schrieb John Hewson <jo...@jahewson.com>:
> 
> 
>> On 11 Aug 2016, at 05:56, Yoav Tsoref <yo...@intango.com> wrote:
>> 
>> 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)
> 
> Unfortunately this is what I'd expect. PDF doesn't have the concept of a newline character, and the current font doesn't contain one either.
> 
> We're currently in the planning by stage of introducing a new high-level text layout API, but it's some way off.
> 
> In the meantime, it seems like setText could be made to handle newlines with only minor changes - Maruan will likely have more to say here.

that's already taken care of in the current implementation. Maybe a bug in 2.0.1 - 2.0.2 and 2.0.3-SNAPSHOT work fine. Need to verify that.

BR
Maruan


> 
> -- John
> 
>> 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)
>> 
>> 
>> 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
> 


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


Re: Unable to Set a String containing New Line Character into PDFBox PDTextField Object

Posted by John Hewson <jo...@jahewson.com>.
> On 11 Aug 2016, at 05:56, Yoav Tsoref <yo...@intango.com> wrote:
> 
> 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)

Unfortunately this is what I'd expect. PDF doesn't have the concept of a newline character, and the current font doesn't contain one either.

We're currently in the planning by stage of introducing a new high-level text layout API, but it's some way off.

In the meantime, it seems like setText could be made to handle newlines with only minor changes - Maruan will likely have more to say here.

-- John

> 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)
> 
> 
> 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