Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to get rid of extra space at beginning of multiline field

I have a form with both one-line and multiline fields. The one-line fields are fine, and the multiline fields look fine in LCD. However, when I open the form in Acrobat Pro, each multiline field has a blank space already in it! I checked with a user, and the same thing happens when she opens the form in Reader.



I verified that this is a problem with multiline fields by changing a one-line field to multiline. As soon as I did, the extra space appeared in Pro & Reader.



Has anyone else had this problem, and if so, what did you do about it?



Thanks!



Kathryn
4 Replies
Well, folks, a bit more troubleshooting revealed both the cause of the problem and a workaround.



If you have a multiline field on a form, select it and go to the Object Palette, then click the Value tab. Then, click inside the Default field and you'll discover LCD has put an extra space there. Trouble is, if you delete it, LCD puts it right back in! I tried multiple times with more than one field. So this is the source of the extra space.



I thought the script fix would be pretty simple: in the Enter event of each multiline field, I just put the following:



if ($ == " ") then

$ = ""

endif



But the script didn't recognize the space put in the field by LCD. However, by using the encode function in FormCalc, I was able to convert the space to its URL encoded value. So this is the FormCalc function that ended up working:



var extraspace = $.rawValue

extraspace = encode(extraspace, "url")

if (extraspace == "%a0") then

$ = ""

endif



Hope this helps someone!



Kathryn
P. S. Since I had a number of multiline fields on my forms, I decided to venture into uncharted LCD territory and create a custom function which I could use as needed. What I thought would be a simple task ended up taking four hours. I'm posting what I discovered here in the hope that it may save someone else time 🙂



First of all, apparently you can't create reusable functions in FormCalc, but only in JavaScript. You have to store them in a Script Object in order to make them available to the fields in the form. (Create the script object by right-clicking on the form in Hierarchy View and choose Insert Script Object).



Converting the FormCalc function to JavaScript was an adventure. Long story short, this is what I ended up with:



function space_bug_fix(field_name, field_contents)

{

field_contents = escape(field_contents)

//escapes the space to its URL encoding (%20) so the script can recognize it



if (field_contents == "%20") {

xfa.resolveNode(field_name).rawValue = "";

//if the field contains only %20--in otherwords, the buggy space--delete it.

}

}



I spent a while trying to get getField() to work, but apparently it doesn't work in the LCD xfa environment. You have to use resolveNode().



Accessing the function was not straightforward either and also required use of the resolveNode function. This is the JavaScript I finally got to work:



xfa.resolveNode("form1..custom_functions").space_bug_fix(this.name, this.rawValue);



(custom_functions is the name I gave the script object). And as a reminder, the language in every event where this function is called has to be set to JavaScript.



Kathryn

Avatar

Level 2
Thank you. This function works great but I'm having trouble getting it to work when adding an instance of a repeating subform. The field in my original subform does not contain the extra space so the function is working, but when the user adds additional instances of the subform the field contained within the subform contains the extra space. Any ideas on a fix for this?
P Mathews,



I just tried it, and two things were necessary for me to get the buggy space script to work on a repeating subform (in my case, table rows):



1) Instead of calling the function from the enter event of the text field, I had to call it from the initialize event.



2) To add/remove rows, I used the script "Adding and removing table rows at runtime" on this page: http://www.adobe.com/devnet/livecycle/designer_scripting_samples.html.



BTW, I just discovered that the buggy space apparently only happens if the multi-line text field is in a table. I was just working on a form that happened to have two multi-line text fields outside a table, and neither one has the buggy space.



HTH!

Kathryn