The Graphics2D export to PDF regarding fonts has a bit
of problems because Java is not very consistent with
the font dimensions. I could never figure out where it
gets the height values for the sanserif font if the
values come from Arial, for example.
In any case I would like to see a small, complete
program that I could run here.
Best Regards,
Paulo Soares
--- "Dr._Bernhard_S�nder" <[EMAIL PROTECTED]>
wrote:
> 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
>
>
************************************************************************
> ***************************************
>
> Dr. Bernhard S�nder
> AMS GmbH
> Heinrich-Heine-Str. 5
> D-09557 Floeha
> Germany
>
> Phone: +49 (3726) 78 81 - 18
> Fax: +49 (3726) 78 81 - 12
> e-mail: <mailto:[EMAIL PROTECTED]>
> [EMAIL PROTECTED]
>
>
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions