These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Indenting the first line of a text box

FlintlockFreedom
Registered: Mar 15 2011
Posts: 4
Answered

Hi everyone,
I've got a form with a text box that needs to be indented on the first line. This is because the answer space is multiple line, but part of the directions are on the same row as the first line of the text box. Is there a way to format it so that they wont overlap each other and still be able to use that first line?
Thanks!

My Product Information:
Acrobat Standard 10.0.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Accepted Answer
Yes, using the keystroke event a script can monitor and modify the keystrokes that the user enters. This includes deleting and overwriting existing text. The script could for example refuse to allow text modification in the first 50 characters. A script can also modify all the text when the user "commits" the entry back to the field. So even if the user overwrites the direction text, a script could restore and reformat the text right before it's committed to the field. Many standard line and paragraph formatting options can be applied with Rich text.

Be warned, this is very tricky coding.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
thomp wrote:
The script could for example refuse to allow text modification in the first 50 characters.
Hi thomp,
can you say moreā€¦?
(It's for another purpose).
Thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Sure, the event.selStart and event.selEnd properties indicate the location of text change. Setting event.rc to false aborts the keystroke event, so that the change never takes place. So this code rejects all data entry inside 50 characters.

if(!event.willCommmit) event.rc = (event.selStart > 50);

Of course there is a less obvious issue that I haven't addressed. If the field rejects entry at a point inside 50 characters, then how exactly do you get the initial text into the field? The answer is with the default field value. The default value has to be entered before the script is added to the field. Then, when the form is reset it is set to the default text. However, in order to change the default text the script has to be disabled. Or a better way would be to modify the script so that changes are allow when "event.selStart < 0", which corresponds to a reset condition.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
Thanks Thomp, this is real info !

:-)