Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Bug in FontFactoryImp

Janis Achenbach

2007-06-13

Replies:

Hi,
if html is <font size="10.0ptf"/>

10.0ptf gets parsed in Float.parseFloat(value + "f") in FontFactoryImp :

    if ((value = attributes.getProperty(ElementTags.SIZE)) != null) {
       size = Float.parseFloat(value + "f");
    }

This leads to NumberFormatException:

java.lang.NumberFormatException: For input string: "10.0ptf"
 at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
 at java.lang.Float.parseFloat(Unknown Source)
 at com.lowagie.text.FontFactoryImp.getFont (FontFactoryImp.java:289)
 at com.lowagie.text.FontFactory.getFont (FontFactory.java:170)
 at com.lowagie.text.Chunk.<init>(Chunk.java:303)

Therefor you should rather use a method like some lines above

size = Markup.parseLength(value);

By the way. Bruno: How are your proceedings an refactoring PdfDocument
and indentation bugs?

Cheers Janis.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.