You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Bharat Bhatt <bh...@gmail.com> on 2017/06/14 04:37:00 UTC
Text width calculation
Hi,
I am using PDFBOX 2.0.4 api, and using PDType1Font.HELVETICA font.
So when calculating text width using
String text = "Tipo Identificación";
PDFont pdFont = PDType1Font.HELVETICA;
float width = (pdFont.getStringWidth(text) / 1000F)* 12f;
Getting error
Caused by: java.lang.IllegalArgumentException: U+FFFD ('.notdef') is not
available in this font Helvetica (generic: ArialMT) encoding:
WinAnsiEncoding
But same code work on Linux server.
How to resolve this and make system independent?
How to support other languages?
Thanks,
Bharat
Re: Text width calculation
Posted by Bharat Bhatt <bh...@gmail.com>.
Hi Attila,
So when you use "UTF-8" exception is not coming. Is it correct?
Thanks,
Bharat
On Wed, Jun 14, 2017 at 2:21 PM, Attila Kiss <ki...@gmail.com>
wrote:
> I was able to get this exception when I save the source file first in
> Eclipse with default encoding (Cp1250), then I change the encoding to
> UTF-8. After the encoding changed, the character 'ó' changed to this ->
> '�' and the exception was thrown. So the problem could be around the source
> file encoding? Maybe. Just a guess.
> Attila
>
> 2017-06-14 10:20 GMT+02:00 Tilman Hausherr <TH...@t-online.de>:
>
>> It works for me on windows 7 and windows 10.
>>
>> Current version is 2.0.6.
>>
>> Tilman
>>
>> Am 14.06.2017 um 06:37 schrieb Bharat Bhatt:
>>
>>> Hi,
>>>
>>> I am using PDFBOX 2.0.4 api, and using PDType1Font.HELVETICA font.
>>> So when calculating text width using
>>>
>>> String text = "Tipo Identificación";
>>> PDFont pdFont = PDType1Font.HELVETICA;
>>> float width = (pdFont.getStringWidth(text) / 1000F)* 12f;
>>>
>>> Getting error
>>> Caused by: java.lang.IllegalArgumentException: U+FFFD ('.notdef') is not
>>> available in this font Helvetica (generic: ArialMT) encoding:
>>> WinAnsiEncoding
>>>
>>> But same code work on Linux server.
>>>
>>> How to resolve this and make system independent?
>>>
>>> How to support other languages?
>>>
>>>
>>> Thanks,
>>> Bharat
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>
Re: Text width calculation
Posted by Attila Kiss <ki...@gmail.com>.
I was able to get this exception when I save the source file first in
Eclipse with default encoding (Cp1250), then I change the encoding to
UTF-8. After the encoding changed, the character 'ó' changed to this -> '�'
and the exception was thrown. So the problem could be around the source
file encoding? Maybe. Just a guess.
Attila
2017-06-14 10:20 GMT+02:00 Tilman Hausherr <TH...@t-online.de>:
> It works for me on windows 7 and windows 10.
>
> Current version is 2.0.6.
>
> Tilman
>
> Am 14.06.2017 um 06:37 schrieb Bharat Bhatt:
>
>> Hi,
>>
>> I am using PDFBOX 2.0.4 api, and using PDType1Font.HELVETICA font.
>> So when calculating text width using
>>
>> String text = "Tipo Identificación";
>> PDFont pdFont = PDType1Font.HELVETICA;
>> float width = (pdFont.getStringWidth(text) / 1000F)* 12f;
>>
>> Getting error
>> Caused by: java.lang.IllegalArgumentException: U+FFFD ('.notdef') is not
>> available in this font Helvetica (generic: ArialMT) encoding:
>> WinAnsiEncoding
>>
>> But same code work on Linux server.
>>
>> How to resolve this and make system independent?
>>
>> How to support other languages?
>>
>>
>> Thanks,
>> Bharat
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
Re: Text width calculation
Posted by Tilman Hausherr <TH...@t-online.de>.
It works for me on windows 7 and windows 10.
Current version is 2.0.6.
Tilman
Am 14.06.2017 um 06:37 schrieb Bharat Bhatt:
> Hi,
>
> I am using PDFBOX 2.0.4 api, and using PDType1Font.HELVETICA font.
> So when calculating text width using
>
> String text = "Tipo Identificación";
> PDFont pdFont = PDType1Font.HELVETICA;
> float width = (pdFont.getStringWidth(text) / 1000F)* 12f;
>
> Getting error
> Caused by: java.lang.IllegalArgumentException: U+FFFD ('.notdef') is not
> available in this font Helvetica (generic: ArialMT) encoding:
> WinAnsiEncoding
>
> But same code work on Linux server.
>
> How to resolve this and make system independent?
>
> How to support other languages?
>
>
> Thanks,
> Bharat
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org