It would help if you followed up the answers instead of starting new
questions. If you look at fitsText() documentation you'll see that the
font size will never be greater than a certain value, that in your case
is word.getFontSize(). For what you are trying to do, fitting single
lines, fitsText() may not be the best option. Make the font size the
size of the word height. Control the width with
PdfContentByte.setHorizontalScaling().

Paulo

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of David Powell
> Sent: Monday, April 09, 2007 12:53 PM
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] HELP Using 
> PdfSignatureAppearance.fitText(...)
> 
> I am attempting to use PdfSignatureAppearance.fitText(...) method to
> get the best font size for the text so that it would fit exactly in
> its coordinate Rectangle, the method is returning a considerable
> smaller font size than expected. I change the 'runDirection' argument
> but it has no effect on the returned font size. Can anyone say what is
> causing this problem? See the code I am using below:
> 
> ...
> ...
> // OcrWord(String text, float llx, float lly, float urx, float ury,
> float fontSize)
> OcrWord word = new OcrWord("Centrifuge",397.38f, 306.42004f, 417.9f,
> 330.54004f,35.0f) ;
> BaseFont bf = BaseFont.createFont(BaseFont.TIMES_BOLD,
> BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
> Rectangle wordCoords = new
> Rectangle(word.getllx(),word.getlly(),word.geturx(),word.getury());
> float bestFontSize = PdfSignatureAppearance.fitText(new Font(bf),
> word.getText(), wordCoords, word.getFontSize(), 0);
> 
> cb.beginText();
> cb.setFontAndSize(bf, bestFontSize);
> cb.setTextMatrix(word.getllx(),word.getlly());
> cb.showText(word.getText());
> cb.endText();
> 
> ...
> 
> -- 
> Regards,
> David


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
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
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to