Copy link to clipboard
Copied
I have a PDF that I'm making fill-able in Acrobat. There's a coment section, where I'm doing a multi-line text field. The PDF already has horizontal lines on it for filling it out by hand.
What I want to do is have a text field over this with a white background, so that when you fill it in on a PC the horizontal lines don't show up.But I still want people to be able to fill this out by hand after they print it if they want. So if this field is left empty I want to set it to be invisible/hidden, so that when you print it the lines would be there for writing stuff in.
I've found various forums saying this is possible with the following java script:
if(this.rawValue == null)
{
this.presence = "hidden";
}
But it doesn't seem to be working.
Can anyone who knows how to do this walk me through it step by step? Maybe I'm doing it wrong. I have Acrobat X Pro and Livecycle Designer ES2, but don't know if I need to do this in designer.
Thank you.
Copy link to clipboard
Copied
The code sample you are providing is for LiveCycle only and cannot be entered into any action in a form created with Acrobat.
With the form open, have you looked at the JavaScript console to see if there are any errors?
Copy link to clipboard
Copied
Is there any way to do this in Acrobat alone? I can use LiveCycle but I have a lot of PDF's to convert to fillable and it will take a bit longer If I have to edit each one with LiveCycle. I see there are ways to insert Javascript in acrobat but it seems to be in validation and calculation properties tabs for fields.
I did not notice any errors before but I will check again, thanks.
Copy link to clipboard
Copied
The following should work:
event.target.display = display.visible;
if(event.value == "")
{
event.target.display = display.hidden;
}
If you conditionally hide the form field, you may need to make the field visible at sometime. I prefer to force the field to visible and then let the conditional statement hide it if needed.
Copy link to clipboard
Copied
I'll give it a try, thanks.
My one question is, what would I set for the condition of the script in the drop down menu, if that's what it's called. I'm referring to the drop down menu in the script editor that has options like PreSave, PostSave, PrePrint, etc. For the case of wanting that text field to be hidden only if someone just opens the PDF and prints it right away, without filling in any forms.
EDIT - Doesn't seem to be working, though the option I selected from the drop down could be wrong.
I assumed that PrePrint from that drop down is what I'd want, so I entered the script you posted for the text field with the white background, and saved the file. After opening it in acrobat, when I go to print preview that field is still there and covers up the black lines, even though I have entered nothing in it.
Copy link to clipboard
Copied
PreSave, PostSave, PrePrint, etc. are available events when using LiveCycle Designer, not Acrobat. The script posted above is for use in Acrobat.
Copy link to clipboard
Copied
These events are also available for Acrobat files, but under different names (Document Will Save, Document Did Save, Document Will Print, etc.)
Copy link to clipboard
Copied
The point is the PDF should be edited in Acrobat, not LiveCycle Designer, unless it's an XFA form, in which case the code would be different.
Copy link to clipboard
Copied
Okay, this is going to be a really stupid question, but can someone walk me through step by step to insert that script into Acrobat X? There are multiple places I've found to do scripts, ranging from calculation or validation scripts, I'm not sure where to put this one.
Sorry, I rarely use Acrobat and almost never do scripting, hence the reason for the question.
Thank you guys for all the help so far!
Copy link to clipboard
Copied
A lot will depend upon the logic of the form.
How is the field populated?
If there is a custom calculation script I would incorporate it there. It is also possible to use the custom format script option or the validation script.
Copy link to clipboard
Copied
I would take a different approach as demonstrated in the following sample: http://acroscript.net/pdf/demos/multiLine_Demo1.pdf
It would be easiest to simply copy the field and paste it into your form. Otherwise, you can copy the various scripts that are in the Validate, On Focus, and On Blur events.
Copy link to clipboard
Copied
The field(s) I want to use this for will simply be text fields, like comment sections on applications and such. No calculations or formulas or anything.
Copy link to clipboard
Copied
The sample I posted is a multiline text field and it does what you want. When the field is blank, the background is transparent and the lines are displayed. But if any text has been entered, the lines are obscured by the white background of the field.
Copy link to clipboard
Copied
George, thank you for the sample, it seems to work for what I need.
I did have a follow-up question though. On some of these forms there are two lines to write in an answer, but on of the lines starts indented, so a single rectangular box will not cover both lines without covering up the question. See example below:
This is a test question, please explain:_____________________________________
___________________________________________________________________
I'm wondering, is there a way to make two text fields, one for each line, and when you fill up the field on the top line have the text wrap/start at the beginning of the second line? If not I will just do a single field for the bottom line, unless you guys have another solution.
Copy link to clipboard
Copied
No, there isn't a seamless way of using two separate fields for that, unfortunately.
Copy link to clipboard
Copied
Thank you for the quick reply, that is unfortunate.
Do you know of any other solution for the example that I posted or would I be best just using the bottom line for a text field?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now