Text Box with Lines
Copy link to clipboard
Copied
How can I create a fillable text box with lines?
Copy link to clipboard
Copied
Explain what you mean by "create a fillable text box with lines"
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
I want to create a text box that has lines in it example:
____________________________________________
____________________________________________
____________________________________________
So that when you type it the words are above the line like on a piece of paper.
Copy link to clipboard
Copied
The Appearance tab on the Form Field Properties window provides an option for an "Underline" on the field. I do not find this option very useful. Espcially since its only good for single line fields.
It is much better to add the lines to the PDF Page, then place the form fields over the lines.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thank you, I tried something like that but as I type and move to the next line the spacing changes. By the time i get to the 4th or 5th sentences the lines are in the middle of my sentences.
Heres and example of what happens:
Copy link to clipboard
Copied
Yes, you have to set the font size to exacty match the spacing of the lines. It's tricky but doable. You can use decimal numbers for the font size. For example, you can set a font size of 10.86 points.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
The underlines date from paper forms, you have to change the paradigm.
Users do not need those lines because it is not possible to write crookedly in a digital form, so just use a color (white) to hide lines that are on the layout.
🙂
Acrobate du PDF, InDesigner et Photoshopographe
Copy link to clipboard
Copied
Hi JR,
I like your way of thinking!! Unfortunately I run into this all the time. The paper mindset will be with us for a while. Customers insist on having lines for multiline inputs. We need to change this to using a box for multiline.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Hi Thom
I also have customers like yours.
In this case I leave the background transparent so that the lines are displayed, I place a script in an onFocus Action which changes the background in white as soon as the user starts the input, and a script in an onBlur Action which checks if the field as been filled. If so, it remains white, if not it becomes transparent again.
😉
Acrobate du PDF, InDesigner et Photoshopographe
Copy link to clipboard
Copied
Nice Solution! I will keep this in mind. Thanks JR 🙂
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Would you share your javascript with me please?
Copy link to clipboard
Copied
Ex3535 :
// ON FOCUS
if (event.target.value == event.target.defaultValue) {
event.target.value = "";
event.target.textColor = color.black;;
}
// ON BLUR
if (event.target.value == "") {
event.target.value = event.target.defaultValue;
event.target.textColor = color.ltGray;
}
Acrobate du PDF, InDesigner et Photoshopographe
Copy link to clipboard
Copied
I am truly grateful for this! Trying it now. THANK YOU ♥
Copy link to clipboard
Copied
I tried the javascript you gave me above. Sorry I am new to java - what values, if any, do I need to change in order to apply this to my text box? The background is not filling with white when I type in it. It currently stays transparent.
Am I doing this right? Thanks so much for your time.
Copy link to clipboard
Copied
You must change the fillColor, not the textColor.
Copy link to clipboard
Copied
I didn't change anything at all. So I'm not sure where to insert the value. I placed the action just as you gave it to me, because I thought it was complete. I'm sorry for any miscommunication.
I've been playing around with various insertion points and am having a hard time. I want the text box to be white if they type in it, and transparenet if they just want to print and fill in manually. Am I asking the wrong questions? I was pretty good at HTML at one time, but it's been a while and java is something I've never attempted to learn well.
Any advice you could share would be humbly appreciated.
Copy link to clipboard
Copied
Oh, sorry I thought I was replying to @JR Boulay
Copy link to clipboard
Copied
You can use this as 'On Blur' action (remove other scripts):
event.target.fillColor = (event.target.value == "") ? color.transparent : color.white;
If the field is empty, fill color will be transparent and if there is value in the field, fill color will be white.
Copy link to clipboard
Copied
@Nesa Nurani THANK YOU! That worked perfectly.
You saved me SO much work... Blessings to you.

