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!
FitTextBox but do not increase the fontsize |
Post Reply |
Author | |
rweetch
Senior Member Joined: 22 Feb 11 Status: Offline Points: 173 |
Post Options
Thanks(0)
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
|
|
rweetch
Senior Member Joined: 22 Feb 11 Status: Offline Points: 173 |
Post Options
Thanks(0)
|
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;
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi,
i've put it into the samples section ;-) Thanks :) |
|
Cheers,
Ingo |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store