[EMAIL PROTECTED] wrote:


Well here is how I am trying to calculate the page size


/******************************/
//font and text supplied before

Rectangle page = reader.getPageSize(0);
FontMetrics fontMetrics = getFontMetrics(font);
int width = fontMetrics.stringWidth(text);
int x_pos = (int)(page.width() - width)

Hmmmm does getPageSize() by any chance returns the PageSize in points?

PageSize return the PageSize in points, but the way you calculate the width of the String is odd because you are using Java Font Metrics and that isn't the same as PDF Font Metrics. You should create a BaseFont and use method getWidthPoint to get the width in points. A float is returned and it's quite accurate.
See http://itextdocs.lowagie.com/tutorial/fonts/styles/index.html
http://itextdocs.lowagie.com/docs/com/lowagie/text/pdf/BaseFont.html#getWidthPoint(java.lang.String,%20float)
br,
Bruno




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to