Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - FitTextBox but do not increase the fontsize
  FAQ FAQ  Forum Search   Register Register  Login Login

FitTextBox but do not increase the fontsize

 Post Reply Post Reply
Author
Message
rweetch View Drop Down
Senior Member
Senior Member


Joined: 22 Feb 11
Status: Offline
Points: 173
Post Options Post Options   Thanks (0) Thanks(0)   Quote rweetch Quote  Post ReplyReply Direct Link To This Post Topic: FitTextBox but do not increase the fontsize
    Posted: 15 Jun 16 at 7:20PM
The FitTextBox method allows you to specify the option to expand the font size (add 1000 to the options argument) so that the text fills the space available.

What I want to do is reduce the font size so the text always displays (without wrapping) in the space available, but not to ever increase the font's size.

An example would be an address, if it fits the area with the current font size then fine, leave it as it is. However if it doesn't fit, reduce the fontsize until it does.

Thanks 
Back to Top
rweetch View Drop Down
Senior Member
Senior Member


Joined: 22 Feb 11
Status: Offline
Points: 173
Post Options Post Options   Thanks (0) Thanks(0)   Quote rweetch Quote  Post ReplyReply Direct Link To This Post Posted: 17 Jun 16 at 3:12PM
I couldn't see how to do this using the methods, so rolled my own and added it to my TDebenuPDFLibrary Helper. Here's the code if you are interested:


procedure TsmDebenuPDFLibraryHelper.DrawDownScaledText(const aText: string; const X, Y aWidth, aHeight: Double);
var lTextSize, lStartSize: Double;
begin

  lStartSize := GetTextSize;
  lTextSize := lStartSize;

  if GetWrappedTextHeight(aWidth, aText) > aHeight then
  begin
    
     lTextSize := lStartSize;

    repeat

       lTextSize := lTextSize * 0.95;

       SetTextSize(lTextSize);

       until (GetWrappedTextHeight(aWidth, aText) <= aHeight);

  end;

  DrawWrappedText(X, Y, aWidth, aText);

   if lTextSize < lStartSize then
      SetTextSize(lStartSize);

end;
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jun 16 at 9:07AM
Hi,

i've put it into the samples section ;-)
Thanks :)

Cheers,
Ingo

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store