You have to calculate mod_x after having the final font size. Paulo
----- Original Message ----- From: "CG" <[EMAIL PROTECTED]> To: "'Post all your questions about iText here'" <[email protected]> Sent: Tuesday, September 05, 2006 4:27 PM Subject: [iText-questions] setHorizontalScaling > I'm trying to create a chunk of text such that it will match the size of a > classic rectangle. I'm having a problem with the font width. I am trying > to > properly use setHorizontalScaling to achieve the proper width. I must not > understand what it really does. Please advise. TIA! > > //text is a String > //font is a BaseFont > //fontSize is a float > > Rectangle boundingRectangle = new Rectangle(0,0,250,150); > > float mod_x = boundingRectangle.width() / font.getWidthPoint(text, > fontSize); > float mod_y = boundingRectangle.height() / (font.getAscentPoint(text, > fontSize) > - font.getDescentPoint(text, fontSize)); > > Chunk c = new Chunk(text); > Font modFont = new Font(font,fontSize * mod_y); > c.setFont(modFont) > c.setHorizontalScaling(mod_x); > ....... > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
