[ 
https://issues.apache.org/jira/browse/PDFBOX-4643?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16931768#comment-16931768
 ] 

hailima edited comment on PDFBOX-4643 at 9/17/19 8:54 PM:
----------------------------------------------------------

Hi Tilman,

With the same sample code, i got problem with line feed:

The sample code:

public static void main (String args[]) {

try

{   PDDocument document = new PDDocument(); PDPage page = new 
PDPage(PDRectangle.A4); document.addPage(page); InputStream starWarsFontStream 
= PDFFonts.class.getResourceAsStream("/times.ttf");  PDFont font = 
PDType0Font.load(document,starWarsFontStream, false); float num = 
font.getStringWidth("atal period (pre-natal\n");   }

catch (Exception e)

{ e.printStackTrace(); }

}

}

 

Error code:

SLF4J: See [http://www.slf4j.org/codes.html#StaticLoggerBinder] for further 
details.

java.lang.IllegalArgumentException: No glyph for U+000A in font 
TimesNewRomanPSMT

at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:404)

at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:342)

 

any idea on how to fix it and thanks! --> it's due to line feed (U+000A)


was (Author: hailima):
Hi Tilman,

With the same sample code, i got problem with line feed:

The sample code:

public static void main (String args[]) {

try {

 

PDDocument document = new PDDocument();

PDPage page = new PDPage(PDRectangle.A4);

document.addPage(page);

InputStream starWarsFontStream = 
PDFFonts.class.getResourceAsStream("/times.ttf"); 

PDFont font = PDType0Font.load(document,starWarsFontStream, false);

float num = font.getStringWidth("atal period (pre-natal\n");

 

} catch (Exception e) {

e.printStackTrace();

}

}

}

 

Error code:

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.

java.lang.IllegalArgumentException: No glyph for U+000A in font 
TimesNewRomanPSMT

at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:404)

at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:342)

 

any idea on how to fix it and thanks!

> No glyph for U+2032 in font TimesNewRomanPSMT
> ---------------------------------------------
>
>                 Key: PDFBOX-4643
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4643
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.16
>            Reporter: hailima
>            Priority: Major
>
> I have the following Java codes for testing PDFBox (2.0.16) and got exception 
> for the unicode U+2032 (prime), but the font i use is "Time New Roman" which 
> should support the unicode, how to fix the issue? thanks
> {code}
> import java.io.InputStream;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.PDPage;
> import org.apache.pdfbox.pdmodel.common.PDRectangle;
> import org.apache.pdfbox.pdmodel.font.PDFont;
> import org.apache.pdfbox.pdmodel.font.PDType0Font;
> public class PDFFonts
> {
>     public static void main(String args[])
>     {
>         try
>         {
>             PDDocument document = new PDDocument();
>             PDPage page = new PDPage(PDRectangle.A4);
>             document.addPage(page);
>             InputStream starWarsFontStream = 
> PDFFonts.class.getResourceAsStream("/times-new-roman.ttf");
>             PDFont font = PDType0Font.load(document, starWarsFontStream, 
> false);
>             float num = font.getStringWidth("atal period (pre-na′tal");
>             System.out.println(num);
>         }
>         catch (Exception e)
>         {
>             e.printStackTrace();
>         }
>     }
> }
> {code}
> Here are exceptions:
> {noformat}
> java.lang.IllegalArgumentException: No glyph for U+2032 in font 
> TimesNewRomanPSMT
> at 
> org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:404)
> at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:342)
> at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:323)
> at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:352)
> at com.hma.eng.PDFFonts.main(PDFFonts.java:34)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

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

Reply via email to