Hello,
Issue:
The PdfGraphics2D.drawString() method doesn't support fonts with a
TextAttribute.WIDTH setting that does not equal 1.0f.
History:
Most of the reports that I need to render are based on output originally
designed for a line printer with a 10, 12, 16.66 or 17.75 cpi width
font. Using the TextAttribute.WIDTH attribute and a mono-spaced True
Type font I am scaling the font height and width to do stuff like make a
font that is 8 points high by 16.66 cpi wide.
I was using Book and Pageable objects to render the reports to a printer
or a preview component on the screen. When I added code to render the
Pageable objects to a PdfGraphics2D object the output looked horrible
because the TextAttribute.WIDTH font settings was ignored by the
PdfGraphics2D.drawString() method.
Using the PdfGraphics2D.drawGlyphVector() would produce the correct
output, but size of the PDF output and the amount of memory required to
render a large report without throwing an OutOfMemoryError was
unacceptable.
Solution:
Using itext-src-2.0.2 release, and I added the following lines to
PdfGraphics2D.java at line 374 (before "double width = 0;" of
PdfGraphics2D.drawString() method.)
Float fontTextAttributeWidth = (Float)
font.getAttributes().get(TextAttribute.WIDTH);
fontTextAttributeWidth = (fontTextAttributeWidth == null)
? TextAttribute.WIDTH_REGULAR
: fontTextAttributeWidth;
cb.setHorizontalScaling(100.0f / fontTextAttributeWidth);
John Hellerud
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/