Easy but not direct. Get the width that the text would take if placed in a single line 
with the font size 1 and call it X. Let W be the width of the rectangle and H the 
height. Let the leading be L and the font size be S.

S = (W * H) / (L * X)

If the leading is the same as the font size the equation reduces to:

S = SQRT(W * H / X)

The actual font size will always be smaller that this because of the word and line 
breaks but it's a start. You must make several tries until the size fits.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Youssef Eldakar
> Sent: Thursday, July 08, 2004 11:59 AM
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] Fitting Text in a Rectangle
> 
> Is there an easy way to squeeze or expand text to fit a rectangle?
>  
> Youssef Eldakar
> Bibliotheca Alexandrina
> Shatby, Alexandria 21526
> Tel: +20-3-4839999
> Fax: +20-3-4879422
> E-mail: [EMAIL PROTECTED]
>  
> NHS^é[){([ZrAÚyj)-Vv~):ÚxUn6ØÖ_uÞÇ^rq^ÆÝb^j!yÞ
> +)àhÛØX0ZrHZ&7ØÉXX$Úzb{%lq zm?X(~zwXb?ר
> 
N¬HS^µé[)¢{(­ç[ÈZrAÚâyø§‚Äëj)âž-µéÝVœv­¸ž~)à±:Úx§€¶¬Uè°›¥Ën6õØŠÖ±é_uçÞÇ¢›^râq©^Æ«¶Éè½éݺbµÈ^²éæj×!yÙÞ
+’)àh®ÛŠØ±X¬ŠÜ0ÁZrHZµÊ&‰7±¶«ž²ØžÉŠX§‚X¬¶$ÞÆÚzËb¢{%ŠËl²‹«qçè®§zØm¶›?þX¬¶Ë(º·~Šàzw­þX¬¶ÏåŠËbú?Š×¶«ž²Øž

Reply via email to