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!
How to determine if text will fit in memo |
Post Reply |
Author | |
waynefulcher
Senior Member Joined: 23 Jun 08 Location: United States Status: Offline Points: 99 |
Post Options
Thanks(0)
Posted: 18 May 18 at 2:34AM |
I have a memo field on a prebuilt PDF form. I want to determine if some text will fit in the memo when being printed.
Is there an easy way to do this? if not is there a long drawn out way to do this? From my searching and writing test code there is no way to know if the text will all fit in a memo field. My long drawn out way always comes up short due to a lack of information that I can't seem to get using QPDF library. I perform the following steps: 1. Open the PDF file with the memo field. 2. Get the memo field's font, text size, width and height. 3. Call the SelectFont() method for the font ID used by memo 4. SetTextSize to the TextSize used by memo field. 4. I then loop through text one word at a time calling GetTextWidth(). 5. Once words no longer fit I add 1 to my line count and start over with the last word that didn't fit. 6. Once I am done I try to determine if the combined height of all lines would fit within the height of the memo. There are several problems with trying to do this manually but to keep this post focused on a single issue I will only list the main problem. There is no way to get the vertical line space a memo uses "between lines" so all I know that I can do to compute the height of all lines of text would be to do: totalHeight := (PDF.GetTextHeight * LineCount) ; This results in a smaller number than it would if you added in line spacing. I searched and there is no way to get this line spacing value as far as I can find. Any help would be greatly appreciated. Thanks Wayne |
|
rweetch
Senior Member Joined: 22 Feb 11 Status: Offline Points: 173 |
Post Options
Thanks(1)
|
would an approach like this help?
|
|
waynefulcher
Senior Member Joined: 23 Jun 08 Location: United States Status: Offline Points: 99 |
Post Options
Thanks(0)
|
WOW, I must have spent 8 hours working on this problem yesterday and thought I read every method from the docs like 3 times..... Somehow I never saw the method GetWrappedTextHeight().
Dang that was easy, thanks for the pointer. |
|
rweetch
Senior Member Joined: 22 Feb 11 Status: Offline Points: 173 |
Post Options
Thanks(0)
|
there's just so much in there it's easy to miss the wood for the trees.
|
|
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