I don't know the iText Pdfgraphics2D code, so I can't offer any particular suggestions. However, I am using Java2D to layout text which is later rendered to PDF using, in part. iText resources.
I'm also using Java 1.5 and 1.6. Since 1.5, and even more in 1.6, Java2D can be directed to do its text measurement directly from a TrueType or Type1 font file. The key is to Font.createFont(..) using such a font file, and to derive fonts in different sizes from this font. Don't ask J2D to give you a font based on an AttributeMap which includes any of the "primary" attributes like size, style and weight, because it will then feel justified in giving you a synthesized font. There are a few gotchas and provisos, but with this approach you can layout text to the same dimensions that the PDF renderer sees. I would like to have a look at this in iText, but it is a question of finding the time; and, of course, it depends on having at least 1.5. Peter On Mon, 2006-12-18 at 12:00 +0100, NCA wrote: > I use the last version of iText ( 1.4.6 ). > The font used is "comic sans MS" and it's in the PDF (embedded) > The printing dimension is the JLabel's preferredSize ... > > Nicolas > > ----- Original Message ----- > From: "Paulo Soares" <[EMAIL PROTECTED]> > To: "Post all your questions about iText here" > <[email protected]> > Sent: Monday, December 18, 2006 11:44 AM > Subject: Re: [iText-questions] Swing and FontMapper problem > > > > If I remember well the size is calculated based on the awt size, no matter > > the BaseFont used. It may be another problem related to the printing > > dimensions you are giving that are smaller than printing to screen or you > > are using a very older iText version. > > > > Paulo > > > > ----- Original Message ----- > > From: "Bruno Lowagie (iText)" <[EMAIL PROTECTED]> > > To: "Post all your questions about iText here" > > <[email protected]> > > Sent: Monday, December 18, 2006 10:33 AM > > Subject: Re: [iText-questions] Swing and FontMapper problem > > > > > >> NCA wrote: > >> > >>> How can I use PdfGraphics2D to compute this ? ( I don't want to rewrite > >>> all the JComponents UI.getPreferredSize code ) > >>> Here is my code : > >> > >>> if ( fontMapper == null ) > >>> fontMapper = new DefaultFontMapper(); > >> > >> Please open the document in Adobe Reader and have a look > >> at the Fonts panel in the Document Properties window. > >> Do you see the font you are expecting, or was Helvetica > >> used instead? Maybe you need to write your own font mapper > >> so that the correct font is used. > >> Mapping Java fonts and actual fonts can be quite a burden. > >> br, > >> Bruno > >> > >> ------------------------------------------------------------------------- > >> Take Surveys. Earn Cash. Influence the Future of IT > >> Join SourceForge.net's Techsay panel and you'll get the chance to share > >> your > >> opinions on IT & business topics through brief surveys - and earn cash > >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > >> _______________________________________________ > >> 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/ > > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > your > > opinions on IT & business topics through brief surveys - and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > 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/ > > > > > > > > > ___________________________________________________________________________ > Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son > interface révolutionnaire. > http://fr.mail.yahoo.com > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > 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/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ 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/
