|
Hi Using the iText version 1.01
returned FontMetrics getHeight() give wrong
values back. E.g. on Windows XP a font of size 9 returns a height of 7 instead
of expected 12. In version 0.98 I do not remember this problem. Drawing of string
is done in the right size, so lines are too close together using the height
value for line separation. Usecase is: Document pdfDoc = new Document(PageSize.A4.rotate()); pdfDoc.open(); PdfWriter
writer = com.lowagie.text.pdf.PdfWriter.getInstance(pdfDoc, new FileOutputStream(exportFile)); PdfContentByte pdfContentByte = writer.getDirectContent(); PdfTemplate pdfTemplate = pdfContentByte.createTemplate(imageWidth, imageHeight); DefaultFontMapper mapper = new DefaultFontMapper(); mapper.insertDirectory("c:\\windows\\fonts"); Graphics2D g2D = pdfTemplate.createGraphics(imageWidth, imageHeight, mapper); JComponent jc = some JComponent derived customized component jc.print(g2D); ….. in jc: void printComponent(Graphics g)
{ ((Graphics2D)g)).setFont(getFont()); FontMetrics �fm = g2.getFontMetrics(); int yOff = fm.getHeight(); } Depending on the pixelsize on Windows there is a factor of 96/72 = 1.25
between font size and number of pixel. To get the right height information I
have to multiply the returned value two times with 1.25. Do you divide instead
of multiplying the font size to calculate the height? (It’s only a guess) By the way we are using iText as an optional export possibility in our application
jBEAM. jBEAM was just presented on the Sun Swing
Sightings No 17. Has somebody an explanation
for this behaviour, or is it just a bug. Thank you Bernhard *************************************************************************************************************** AMS GmbH Heinrich-Heine-Str.
5 D-09557 Floeha Germany Phone:�� +49 (3726) 78 81 - 18 Fax:������ +49 (3726) 78 81 - 12 e-mail:��� [EMAIL PROTECTED] |
- Re: [iText-questions] PDF-FontMetrics give wrong value... Dr. Bernhard S�nder
- Re: [iText-questions] PDF-FontMetrics give wrong ... Paulo Soares
