Print Page | Close Window

GetTextWidth for form field

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3186
Printed Date: 13 Dec 25 at 3:34PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: GetTextWidth for form field
Posted By: FLA
Subject: GetTextWidth for form field
Date Posted: 08 Oct 15 at 5:48PM
Hi,

I'm new to QuickPdf and have a problem with the following task :

- I've got three fields "as a group" in a customer PDF and the text i need to put in them is large, so i must fit in the three fields (field1, field2 and field3).

The text is an enumeration like : item1, item2, item3, item4, item5, item6, item7, ...

I need to parse this text to the 3 fields depending on the fields width

ex :
Field1 : item1, item2, item3,
Field2 : item4, item5, item6,
Field3 : item7

I made something to do the job with iteration such as
GetTextWidth("item1, item2, item3, item4, item5, item6, item7") --> too long for field1 
GetTextWidth("item1, item2, item3, item4, item5, item6")            --> too long for field1
GetTextWidth("item1, item2, item3, item4, item5")                       --> too long for field1
GetTextWidth("item1, item2, item3, item4")                                  --> too long for field1
GetTextWidth("item1, item2, item3") < Field1.width                      --> so OK for field1

and so on..for field2 and field3

It's ok even if there is often enough space to put an extra item on each field (1)

In my case GetFormFieldTextSize(field1) = 10 and FontSize() return 0.
Is there a way to set the FontSize() ?
How the GetTextWidth(string) works because FontSize() return 0 ?

(1) : Is there another function to do this test more accuratly ?

Have you got an idea or a tip to enhance my job ?

If i've got a bigger string to fit, I'd like to iterate and reduce the font size by decrement to finally fit the three fields...but how to test the string width with smaller font ?

Thanks in advance



Replies:
Posted By: Ingo
Date Posted: 17 Oct 15 at 7:12PM
Hi FLA,

Perhaps that "FontSize" returns 0 depends on the used font?:
http://www.debenu.com/docs/pdf_library_reference/FontSize.php

Yes. You can set the textsize:
http://www.debenu.com/docs/pdf_library_reference/SetTextSize.php

GetTextWidth won't work in your case 'cause it's based on "FontSize":
http://www.debenu.com/docs/pdf_library_reference/GetTextWidth.php

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: FLA
Date Posted: 19 Oct 15 at 9:07AM
Hi,

I've found a solution here : http://www.debenu.com/kb/converting-pixels-and-inches-to-postscript-points/

I needed to convert pixels to points to do my job.

Thanks



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk