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

Maruan Sahyoun commented on PDFBOX-1616:
----------------------------------------

I tried with a sample code similar to 

            PDFont font = PDTrueTypeFont.loadTTF(doc, fontfile);
            PDPageContentStream contentStream = new 
PDPageContentStream(doc,page,true,true);
            contentStream.beginText();
            contentStream.setFont(font, 12);
            contentStream.moveTextPositionByAmount(100, 700);
            contentStream.drawString("8900146484");
            contentStream.endText();
            contentStream.close();

and it works fine testing with different fonts (internal and TrueType) as well 
as generating a new doc and appending to an existing doc.

So I think in order to be more helpful we'd need a sample PDF and the code 
snippet you are using to reproduce the issue.

BR
Maruan 

                
> NumberFormatException i CMapParser.parseNextToken()
> ---------------------------------------------------
>
>                 Key: PDFBOX-1616
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1616
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 1.8.1
>            Reporter: Thomas Fossum
>
> When using PDType1Font (any of the 14 fonts available), and adding text with 
> contentStream.drawString(), we get a NumberformatException for string with 9 
> characters, ex. "123456789" or "abcdefghi"
> Stacktrace:
> Caused by: java.lang.NumberFormatException: For input string: "8900146484"
>         at 
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
>         at java.lang.Integer.parseInt(Integer.java:495)
>         at java.lang.Integer.<init>(Integer.java:677)
>         at 
> org.apache.fontbox.cmap.CMapParser.parseNextToken(CMapParser.java:541)
>         at org.apache.fontbox.cmap.CMapParser.parse(CMapParser.java:119)
>         at org.apache.pdfbox.pdmodel.font.PDFont.parseCmap(PDFont.java:603)
>         at 
> org.apache.pdfbox.pdmodel.font.PDSimpleFont.extractToUnicodeEncoding(PDSimpleFont.java:458)
>         at 
> org.apache.pdfbox.pdmodel.font.PDSimpleFont.determineEncoding(PDSimpleFont.java:426)
>         at org.apache.pdfbox.pdmodel.font.PDFont.<init>(PDFont.java:194)
>         at 
> org.apache.pdfbox.pdmodel.font.PDSimpleFont.<init>(PDSimpleFont.java:88)
>         at 
> org.apache.pdfbox.pdmodel.font.PDType0Font.<init>(PDType0Font.java:65)
>         at 
> org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:108)
>         at 
> org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:203)
>         at org.apache.pdfbox.pdmodel.PDResources.addFont(PDResources.java:588)
>         at org.apache.pdfbox.pdmodel.PDResources.addFont(PDResources.java:574)
>         at 
> org.apache.pdfbox.pdmodel.edit.PDPageContentStream.setFont(PDPageContentStream.java:308)
> Issue https://issues.apache.org/jira/browse/PDFBOX-1225 handles a similar 
> error: An attempt to Integer.parseString() is made with a value > 
> Integer.MAX_VALUE.
> Line 541 in CMAPParser.java should probably use Long datatype.
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to