Hello everyone,
Altough my problem seems simple, I really can't find the right answer, so here I am
I shall describe what I want to do and the ways I tried to do it, so please if someone encountered similar situation - your advice would be very appreciated.
What I want to do:
1. Create a PDF form with LiveCycle Designer ES (8.2).
2. Import form data from simple XML file to fill some single line text fields.
3. If the imported data is too long to fill inside the text field, I want to truncate it and add "..." to its end.
Example:
1. I have a text field "Company", which is this long --> [ ].
2. I import the name of the company, let's say "Super Technologies".
3. In the printed page it should look like this --> [Super Te... ] and NOT [Super Techno] or [Super Techn+]. <-- that "plus" is added by Acrobat when form data doesn't fit in.
Looks simple, eh? The problem is that Text Field's property "Limit length to visible area" only works when typing using keyboard, the text field's event "full" doesn't trigger when importing form data.
My first ideas to solve this:
I was thinking of writing script for Text Field's "validate" event, and whenever the form data was too big to fit, the script would truncate it and add "...". The problem is - i don't know how to "ask the field" this question "Are you full?". The only way to do it, is when the length of the field is set to fixed number of characters -- but this doesn't do any good, because when importing data it cuts the data and my script can't tell if I need to add "..." or the text fits in nicely (Another problem is that texts "mama" and "lili" - are both 4 characters long, but the width is very different)
Your ideas would help me a lot!
Message title was edited to better reflect the problem by: MS VTEX
Views
Replies
Total Likes
You are right ...those setting for length are only available when the user is typing in their input. You coould use limit length but that will only solve part of your issue. If you know how many chars will appear in the field before it is full you could add code like this to the DocReady event. This example assume that the max number of chars that will fit in a field is 21.
if (this.rawValue.length > 18){
this.rawValue = this.rawValue.substring(0,18) + "...";
}
Views
Replies
Total Likes
Thanks for providing some help. Indeed, if I set the legth to fixed width, your sample works, but as I said, this doesn't suit me (it's not me, but my boss, who's trying to make the job perfect ). BTW, DocReady event doesn't fit here, as it fires only once and not after I load my XML data.
Just to give more information: inside "Acrobat and PDF Library API Reference" there is this C function PDEFontSumWidths, which translates the given string in a given font into "length in points". By doing like PDEFontSumWidths(Helvetica, "abrakadabra") --- it pops me a number of how long this string would look... Is there anything like it in JavaScript? Is there a way to call Acrobat API C functions from LiveCycle Designer? Google showed really poor results here...
Views
Replies
Total Likes