You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Croe.David" <cr...@inside-online.de> on 2016/05/25 08:14:27 UTC

unable to calculate text width

Dear all,

i'm trying to replace and center a text in a pdf which has been created by phantomjs.

I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %:

Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard
       at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411)
       at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
       at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
       at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)


in PDCIDFontType2:
isEmbedded is true
parent.getCMap().getName() is Identity-H
cmap is null
cid is -1



a closer look with pdfdebugger , this is the toUnicode:

/CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <FFFF>
endcodespacerange
2 beginbfrange
<0000> <0000> <0000>
<0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020> <006D> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B> <007A> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ]
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
end
end

how to calculate the width or fix the problem ?

best regards,
   David Croé
____________________________________________________________

[https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]<http://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres-2016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres>
Danke an unsere Kunden für die Wahl zum Anbieter des Jahres 2016!
Kontaktieren Sie uns hier<http://www.inside-online.de/de/kontaktieren.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres> und erfahren Sie, warum uns unsere Kunden
zum Anbieter des Jahres gewählt haben.
Gerne sprechen wir auch über Ihr E-Learning-Projekt!
____________________________________________________________

Re: unable to calculate text width

Posted by Tilman Hausherr <TH...@t-online.de>.
What version and code did you use? I used this:


import java.io.IOException;
import java.net.URL;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.font.PDFont;

public class Buir
{
     public static void main(String[] args) throws IOException
     {
         PDDocument doc = PDDocument.load(new 
URL("http://www.buir.de/ABCD.pdf").openStream());
         PDPage page = doc.getPage(0);
         PDFont font = 
page.getResources().getFont(COSName.getPDFName("F1"));
         float w = font.getStringWidth("%");
         System.out.println("w: " + w);
         doc.close();
     }
}

output:


w: 833.0



Tilman

Am 06.06.2016 um 08:17 schrieb Croe.David:
> Hi,
>
> this is a pretty simple example created with powerpoint:
> it displays the '%' Sign but pdfbox isn't able to calculate the width:
>
> http://www.buir.de/ABCD.pdf
>
> best regards,
>    David
>
>
> -----Urspr�ngliche Nachricht-----
> Von: John Hewson [mailto:john@jahewson.com]
> Gesendet: Dienstag, 31. Mai 2016 17:21
> An: users@pdfbox.apache.org
> Betreff: Re: unable to calculate text width
>
>
>> On 30 May 2016, at 23:57, Croe.David <cr...@inside-online.de> wrote:
>>
>> Thanks for reply,
>>
>> the pdf looks correct in pdf debugger and reader, thus if it can display the "%" sign why pdfbox can't calculate the width ?
>> It lacks a part in the puzzle.
>> How to determine if it\u2019s a subset ?
>>
>> The toUnicode seems to have the character "%" .. 0025 ...
>> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054>
> Hmm, post the PDF online somewhere and I\u2019ll take a look.
>
>> thanks,
>> David
>>
>>
>>
>> -----Urspr�ngliche Nachricht-----
>> Von: John Hewson [mailto:john@jahewson.com]
>> Gesendet: Montag, 30. Mai 2016 18:52
>> An: users@pdfbox.apache.org
>> Betreff: Re: unable to calculate text width
>>
>>
>>> On 25 May 2016, at 01:14, Croe.David <cr...@inside-online.de> wrote:
>>>
>>> Dear all,
>>>
>>> i'm trying to replace and center a text in a pdf which has been created by phantomjs.
>>>
>>> I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %:
>>>
>>> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard
>>>       at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411)
>>>       at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>>>       at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
>>>       at
>>> org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
>>>
>>>
>>> in PDCIDFontType2:
>>> isEmbedded is true
>>> parent.getCMap().getName() is Identity-H cmap is null cid is -1
>>>
>>>
>>>
>>> a closer look with pdfdebugger , this is the toUnicode:
>>>
>>> /CIDInit /ProcSet findresource begin
>>> 12 dict begin
>>> begincmap
>>> /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >>
>>> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def
>>> 1 begincodespacerange
>>> <0000> <FFFF>
>>> endcodespacerange
>>> 2 beginbfrange
>>> <0000> <0000> <0000>
>>> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043>
>>> <0054> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020>
>>> <006D> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B>
>>> <007A> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ]
>>> endbfrange endcmap CMapName currentdict /CMap defineresource pop end
>>> end
>>>
>>> how to calculate the width or fix the problem ?
>> As Tilman has suggested, this font is likely a subset and does not contain that symbol. You may be able to configure phantoms to not subset fonts, I believe that it uses CUPS-PDF for this.
>>
>> \u2014 John
>>
>>> best regards,
>>>   David Cro�
>>> ____________________________________________________________
>>>
>>> [https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]<ht
>>> t
>>> p://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres-
>>> 2
>>> 016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-
>>> A
>>> nbieter-des-Jahres> Danke an unsere Kunden f�r die Wahl zum Anbieter
>>> des Jahres 2016!
>>> Kontaktieren Sie uns
>>> hier<http://www.inside-online.de/de/kontaktieren.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres> und erfahren Sie, warum uns unsere Kunden zum Anbieter des Jahres gew�hlt haben.
>>> Gerne sprechen wir auch �ber Ihr E-Learning-Projekt!
>>> ____________________________________________________________
>>
>> ---------------------------------------------------------------------
>> 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
>>
>
> ---------------------------------------------------------------------
> 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
>


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


AW: unable to calculate text width

Posted by "Croe.David" <cr...@inside-online.de>.
Hi,

this is a pretty simple example created with powerpoint:
it displays the '%' Sign but pdfbox isn't able to calculate the width: 

http://www.buir.de/ABCD.pdf

best regards,
  David


-----Ursprüngliche Nachricht-----
Von: John Hewson [mailto:john@jahewson.com] 
Gesendet: Dienstag, 31. Mai 2016 17:21
An: users@pdfbox.apache.org
Betreff: Re: unable to calculate text width


> On 30 May 2016, at 23:57, Croe.David <cr...@inside-online.de> wrote:
> 
> Thanks for reply,
> 
> the pdf looks correct in pdf debugger and reader, thus if it can display the "%" sign why pdfbox can't calculate the width ?
> It lacks a part in the puzzle.
> How to determine if it’s a subset ?
> 
> The toUnicode seems to have the character "%" .. 0025 ...
> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054>

Hmm, post the PDF online somewhere and I’ll take a look.

> thanks,
> David
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: John Hewson [mailto:john@jahewson.com]
> Gesendet: Montag, 30. Mai 2016 18:52
> An: users@pdfbox.apache.org
> Betreff: Re: unable to calculate text width
> 
> 
>> On 25 May 2016, at 01:14, Croe.David <cr...@inside-online.de> wrote:
>> 
>> Dear all,
>> 
>> i'm trying to replace and center a text in a pdf which has been created by phantomjs.
>> 
>> I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %:
>> 
>> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard
>>      at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411)
>>      at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>>      at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
>>      at
>> org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
>> 
>> 
>> in PDCIDFontType2:
>> isEmbedded is true
>> parent.getCMap().getName() is Identity-H cmap is null cid is -1
>> 
>> 
>> 
>> a closer look with pdfdebugger , this is the toUnicode:
>> 
>> /CIDInit /ProcSet findresource begin
>> 12 dict begin
>> begincmap
>> /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> 
>> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def
>> 1 begincodespacerange
>> <0000> <FFFF>
>> endcodespacerange
>> 2 beginbfrange
>> <0000> <0000> <0000>
>> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> 
>> <0054> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020> 
>> <006D> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B> 
>> <007A> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ] 
>> endbfrange endcmap CMapName currentdict /CMap defineresource pop end 
>> end
>> 
>> how to calculate the width or fix the problem ?
> 
> As Tilman has suggested, this font is likely a subset and does not contain that symbol. You may be able to configure phantoms to not subset fonts, I believe that it uses CUPS-PDF for this.
> 
> — John
> 
>> best regards,
>>  David Croé
>> ____________________________________________________________
>> 
>> [https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]<ht
>> t
>> p://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres-
>> 2 
>> 016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-
>> A
>> nbieter-des-Jahres> Danke an unsere Kunden für die Wahl zum Anbieter
>> des Jahres 2016!
>> Kontaktieren Sie uns
>> hier<http://www.inside-online.de/de/kontaktieren.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres> und erfahren Sie, warum uns unsere Kunden zum Anbieter des Jahres gewählt haben.
>> Gerne sprechen wir auch über Ihr E-Learning-Projekt!
>> ____________________________________________________________
> 
> 
> ---------------------------------------------------------------------
> 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
> 


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






Re: unable to calculate text width

Posted by John Hewson <jo...@jahewson.com>.
> On 30 May 2016, at 23:57, Croe.David <cr...@inside-online.de> wrote:
> 
> Thanks for reply,
> 
> the pdf looks correct in pdf debugger and reader, thus if it can display the "%" sign why pdfbox can't calculate the width ?
> It lacks a part in the puzzle.
> How to determine if it’s a subset ?
> 
> The toUnicode seems to have the character "%" .. 0025 ...
> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054>

Hmm, post the PDF online somewhere and I’ll take a look.

> thanks,
> David 
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: John Hewson [mailto:john@jahewson.com] 
> Gesendet: Montag, 30. Mai 2016 18:52
> An: users@pdfbox.apache.org
> Betreff: Re: unable to calculate text width
> 
> 
>> On 25 May 2016, at 01:14, Croe.David <cr...@inside-online.de> wrote:
>> 
>> Dear all,
>> 
>> i'm trying to replace and center a text in a pdf which has been created by phantomjs.
>> 
>> I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %:
>> 
>> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard
>>      at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411)
>>      at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>>      at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
>>      at 
>> org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
>> 
>> 
>> in PDCIDFontType2:
>> isEmbedded is true
>> parent.getCMap().getName() is Identity-H cmap is null cid is -1
>> 
>> 
>> 
>> a closer look with pdfdebugger , this is the toUnicode:
>> 
>> /CIDInit /ProcSet findresource begin
>> 12 dict begin
>> begincmap
>> /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> 
>> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def
>> 1 begincodespacerange
>> <0000> <FFFF>
>> endcodespacerange
>> 2 beginbfrange
>> <0000> <0000> <0000>
>> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054> 
>> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020> <006D> 
>> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B> <007A> 
>> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ] endbfrange 
>> endcmap CMapName currentdict /CMap defineresource pop end end
>> 
>> how to calculate the width or fix the problem ?
> 
> As Tilman has suggested, this font is likely a subset and does not contain that symbol. You may be able to configure phantoms to not subset fonts, I believe that it uses CUPS-PDF for this.
> 
> — John
> 
>> best regards,
>>  David Croé
>> ____________________________________________________________
>> 
>> [https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]<htt
>> p://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres-2
>> 016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-A
>> nbieter-des-Jahres> Danke an unsere Kunden für die Wahl zum Anbieter 
>> des Jahres 2016!
>> Kontaktieren Sie uns 
>> hier<http://www.inside-online.de/de/kontaktieren.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres> und erfahren Sie, warum uns unsere Kunden zum Anbieter des Jahres gewählt haben.
>> Gerne sprechen wir auch über Ihr E-Learning-Projekt!
>> ____________________________________________________________
> 
> 
> ---------------------------------------------------------------------
> 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
> 


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


AW: unable to calculate text width

Posted by "Croe.David" <cr...@inside-online.de>.
Thanks for reply,

the pdf looks correct in pdf debugger and reader, thus if it can display the "%" sign why pdfbox can't calculate the width ?
It lacks a part in the puzzle.
How to determine if it’s a subset ?

The toUnicode seems to have the character "%" .. 0025 ...
 <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054>

thanks,
 David 
 


-----Ursprüngliche Nachricht-----
Von: John Hewson [mailto:john@jahewson.com] 
Gesendet: Montag, 30. Mai 2016 18:52
An: users@pdfbox.apache.org
Betreff: Re: unable to calculate text width


> On 25 May 2016, at 01:14, Croe.David <cr...@inside-online.de> wrote:
> 
> Dear all,
> 
> i'm trying to replace and center a text in a pdf which has been created by phantomjs.
> 
> I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %:
> 
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard
>       at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411)
>       at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>       at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
>       at 
> org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
> 
> 
> in PDCIDFontType2:
> isEmbedded is true
> parent.getCMap().getName() is Identity-H cmap is null cid is -1
> 
> 
> 
> a closer look with pdfdebugger , this is the toUnicode:
> 
> /CIDInit /ProcSet findresource begin
> 12 dict begin
> begincmap
> /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> 
> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def
> 1 begincodespacerange
> <0000> <FFFF>
> endcodespacerange
> 2 beginbfrange
> <0000> <0000> <0000>
> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054> 
> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020> <006D> 
> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B> <007A> 
> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ] endbfrange 
> endcmap CMapName currentdict /CMap defineresource pop end end
> 
> how to calculate the width or fix the problem ?

As Tilman has suggested, this font is likely a subset and does not contain that symbol. You may be able to configure phantoms to not subset fonts, I believe that it uses CUPS-PDF for this.

— John

> best regards,
>   David Croé
> ____________________________________________________________
> 
> [https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]<htt
> p://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres-2
> 016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-A
> nbieter-des-Jahres> Danke an unsere Kunden für die Wahl zum Anbieter 
> des Jahres 2016!
> Kontaktieren Sie uns 
> hier<http://www.inside-online.de/de/kontaktieren.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres> und erfahren Sie, warum uns unsere Kunden zum Anbieter des Jahres gewählt haben.
> Gerne sprechen wir auch über Ihr E-Learning-Projekt!
> ____________________________________________________________


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






Re: unable to calculate text width

Posted by John Hewson <jo...@jahewson.com>.
> On 25 May 2016, at 01:14, Croe.David <cr...@inside-online.de> wrote:
> 
> Dear all,
> 
> i'm trying to replace and center a text in a pdf which has been created by phantomjs.
> 
> I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %:
> 
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard
>       at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411)
>       at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>       at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
>       at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
> 
> 
> in PDCIDFontType2:
> isEmbedded is true
> parent.getCMap().getName() is Identity-H
> cmap is null
> cid is -1
> 
> 
> 
> a closer look with pdfdebugger , this is the toUnicode:
> 
> /CIDInit /ProcSet findresource begin
> 12 dict begin
> begincmap
> /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def
> /CMapName /Adobe-Identity-UCS def
> /CMapType 2 def
> 1 begincodespacerange
> <0000> <FFFF>
> endcodespacerange
> 2 beginbfrange
> <0000> <0000> <0000>
> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020> <006D> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B> <007A> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ]
> endbfrange
> endcmap
> CMapName currentdict /CMap defineresource pop
> end
> end
> 
> how to calculate the width or fix the problem ?

As Tilman has suggested, this font is likely a subset and does not contain that symbol. You may be able to configure phantoms to not subset fonts, I believe that it uses CUPS-PDF for this.

— John

> best regards,
>   David Croé
> ____________________________________________________________
> 
> [https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]<http://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres-2016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres>
> Danke an unsere Kunden für die Wahl zum Anbieter des Jahres 2016!
> Kontaktieren Sie uns hier<http://www.inside-online.de/de/kontaktieren.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres> und erfahren Sie, warum uns unsere Kunden
> zum Anbieter des Jahres gewählt haben.
> Gerne sprechen wir auch über Ihr E-Learning-Projekt!
> ____________________________________________________________


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


Re: unable to calculate text width

Posted by Tilman Hausherr <TH...@t-online.de>.
Is the font a subset?

Tilman

Am 25.05.2016 um 10:14 schrieb Croe.David:
> Dear all,
>
> i'm trying to replace and center a text in a pdf which has been created by phantomjs.
>
> I'm not sure if it's a problem within phantomjs or pdfbox, but I get following exception while calculating the text width of a string starting with Symbol %:
>
> Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0025 in font TimesNewRomanStandard
>         at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411)
>         at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:351)
>         at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
>         at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:315)
>
>
> in PDCIDFontType2:
> isEmbedded is true
> parent.getCMap().getName() is Identity-H
> cmap is null
> cid is -1
>
>
>
> a closer look with pdfdebugger , this is the toUnicode:
>
> /CIDInit /ProcSet findresource begin
> 12 dict begin
> begincmap
> /CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def
> /CMapName /Adobe-Identity-UCS def
> /CMapType 2 def
> 1 begincodespacerange
> <0000> <FFFF>
> endcodespacerange
> 2 beginbfrange
> <0000> <0000> <0000>
> <0001> <0024> [<0025> <004E> <0041> <004D> <0045> <003A> <0043> <0054> <0052> <0062> <0065> <0073> <0074> <0061> <006E> <0064> <0020> <006D> <0069> <0066> <006F> <006C> <0067> <0072> <0050> <0075> <006B> <007A> <0068> <0055> <004B> <0044> <00FC> <0042> <0079> <0070> ]
> endbfrange
> endcmap
> CMapName currentdict /CMap defineresource pop
> end
> end
>
> how to calculate the width or fix the problem ?
>
> best regards,
>     David Cro
> ____________________________________________________________
>
> [https://www.inside-online.de/mail/footer/anbieter_des_jahres.jpg]<http://www.inside-online.de/de/pressemeldungen-news/anbieter-des-jahres-2016.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres>
> Danke an unsere Kunden fr die Wahl zum Anbieter des Jahres 2016!
> Kontaktieren Sie uns hier<http://www.inside-online.de/de/kontaktieren.html?utm_source=Signatur&utm_medium=E-Mail&utm_campaign=Signatur-Anbieter-des-Jahres> und erfahren Sie, warum uns unsere Kunden
> zum Anbieter des Jahres gewhlt haben.
> Gerne sprechen wir auch ber Ihr E-Learning-Projekt!
> ____________________________________________________________
>


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