Great! Thanks for the answers and the fix!

Esteban
________________________________
De: Tilman Hausherr <thaush...@t-online.de>
Enviado: miƩrcoles, 16 de diciembre de 2020 11:26
Para: users@pdfbox.apache.org <users@pdfbox.apache.org>
Asunto: Re: getStringWidth fails with null pointer exception for (damaged?) 
PDType1CFont

Fixed in
https://issues.apache.org/jira/browse/PDFBOX-5048

thanks for the report and the reproducing code

Tilman

Am 16.12.2020 um 04:20 schrieb Esteban R:
> I get the following exception when I call getStringWidth:
>
> Exception in thread "main" java.lang.NullPointerException
>          at 
> org.apache.pdfbox.pdmodel.font.PDType1CFont.getStringWidth(PDType1CFo
> nt.java:348)
>          at TestGetStringWidth.main(TestGetStringWidth.java:18)
>
> Sample file: https://gofile.io/d/D0n3EJ
> Code to reproduce (full TestGetStringWidth.java at 
> https://gofile.io/d/ttajq7):
>
>          PDDocument doc = PDDocument.load(new File(args[0]));
>          PDPage p = doc.getPage(0);
>          PDFont f = p.getResources().getFont(COSName.getPDFName("F70"));
>          f.getStringWidth("Pa");
>
> Note: A previous exception is dumped while parsing the font so the font seems 
> to be corrupted (how to confirm? Adobe Reader doesn't complain about it):
>
> java.io.IOException: java.lang.NumberFormatException: For input string: ".2-"
>          at 
> org.apache.fontbox.cff.CFFParser.readRealNumber(CFFParser.java:421)
>          at org.apache.fontbox.cff.CFFParser.readEntry(CFFParser.java:278)
>          at org.apache.fontbox.cff.CFFParser.readDictData(CFFParser.java:255)
>          at 
> org.apache.fontbox.cff.CFFParser.parseType1Dicts(CFFParser.java:732)
>          at org.apache.fontbox.cff.CFFParser.parseFont(CFFParser.java:565)
>          at org.apache.fontbox.cff.CFFParser.parse(CFFParser.java:122)
>          at org.apache.fontbox.cff.CFFParser.parse(CFFParser.java:75)
>          at 
> org.apache.pdfbox.pdmodel.font.PDType1CFont.<init>(PDType1CFont.java:
> 102)
>          at 
> org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory
> .java:74)
>          ...
>
> I use pdfbox version 2.0.21 and java 1.8.0_271 in Windows 10 environment.
>
> Esteban Ruiz
>
>
>


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

Reply via email to