> On 28 May 2015, at 03:38, Johanneke Lamberink <[email protected]> 
> wrote:
> 
> Thanks for explaining!
> 
> Using a Helvetica.ttf file I was able to solve the error about 8-bit code
> points. Apparently the PDType1Font.HELVETICA does not include all
> characters that are supported by Helvectica.

That's right, in PDF you're always accessing a font via an Encoding, which is 
typically smaller than the font itself and usually pre-dates Unicode.

> The new line is now handled before calling showText().

Great!

-- John

> Johanneke Lamberink
> 
> 
> 
> 
> 
> Op 28/5/15 01:05 schreef John Hewson <[email protected]>:
> 
>> 
>>> On 27 May 2015, at 03:38, Johanneke Lamberink
>>> <[email protected]> wrote:
>>> 
>>> Hi,
>>> 
>>> The string with the U+000A (LF) is retrieved by calling
>>> PDAnnotation.getContents().
>>> I expected to be able to use the String returned by that method in
>>> PDPageContentStream.showText(), but apparently that is not the case.
>>> 
>>> Thanks.
>> 
>> If there¹s an appearance stream (AP) for the field then that will take
>> precedence over the
>> Contents. If there¹s not, then it¹s always possible that the Contents is
>> using glyphs which
>> are missing in the font. PDF doesn¹t understand newlines anyway, so an LF
>> character in
>> the text would need to be handled at some higher level than showText().
>> Indeed, LF is not
>> even present in WinAnsiEncoding which is why you¹re seeing an error when
>> using
>> PDType1Font.HELVETICA.
>> 
>> ‹ John
>> 
>>> 
>>> Johanneke Lamberink
>>> 
>>> Onior Group B.V.
>>> Jan Pieterszoon Coenstraat  7
>>> 2595 WP Den Haag
>>> The Netherlands
>>> Office: +31 70 799 94 85     Mobile: + 31 6 23 76 76 45
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Op 27/5/15 12:28 schreef Andreas Lehmkühler <[email protected]>:
>>> 
>>>> Hi,
>>>> 
>>>>> Johanneke Lamberink <[email protected]> hat am 27. Mai
>>>>> 2015
>>>>> um
>>>>> 10:52 geschrieben:
>>>>> 
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> When writing a given String to a PDF I am encountering the following
>>>>> stacktraces in the logging:
>>>>> 
>>>>> 
>>>>> Caused by: java.lang.IllegalArgumentException: No glyph for U+000A in
>>>>> font
>>>>> Helvetica
>>>>>       at
>>>>> 
>>>>> org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:320)
>>>>>       at 
>>>>> org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:282)
>>>>>       at
>>>>> 
>>>>> 
>>>>> org.apache.pdfbox.pdmodel.PDPageContentStream.showText(PDPageContentStr
>>>>> ea
>>>>> m.java:358)
>>>>> 
>>>>> and:
>>>>> 
>>>>> 
>>>>> 
>>>>> Caused by: java.lang.IllegalArgumentException: This font type only
>>>>> supports
>>>>> 8-bit code points
>>>>>       at
>>>>> 
>>>>> org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:311)
>>>>>       at 
>>>>> org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:282)
>>>>>       at
>>>>> org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:311)
>>>>> 
>>>>> I am not sure if this is a problem in my choice of font, my use of the
>>>>> api, or
>>>>> the encoding done by pdfbox.
>>>>> 
>>>>> Can anyone explain to me what it is that is going wrong here?
>>>> U+000A sounds like line feed. Does your string contain any newline
>>>> characters
>>>> like CR or LF? You have to remove those, as you have to manage line
>>>> breaks
>>>> yourself.
>>>> 
>>>>> Thanks :)
>>>>> 
>>>>> 
>>>>> Johanneke Lamberink
>>>> 
>>>> BR
>>>> Andreas Lehmkühler
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to