Copy link to clipboard
Copied
Hi Everyone,
I am looking for a way to run a JS when a document is opened (or when a specific page is opened). For example this will be used to ensure some fields are appropriately hidden but will be made visible when the form is completed.
Is there a way to do this?
Thank you in advance for any help and direction!
George
Copy link to clipboard
Copied
Thanks Gilad D (try67), your last suggestions took me in the right direction. Also, just as you earlier posted, it's pretty straight forward to find where to place document level scripts in Acrobat Pro DC - just as you mentioned. It's different in the version X.
Here is the generic script I ended up modifying ....
function doMyscript() {
// Code goes here
}
// Call the function
doMyscript();
And here is the working script...
function HideSignatureFields()
{ this.getField("SupervisorSignature").display = display.hidden;
this.getField("GenCounselingStudentSignature").display = display.hidden;
this.getField("PDSignature").display = display.hidden;
this.getField("ValidateFormFeedback").display = display.hidden;
}
HideSignatureFields();
Thanks again!
Best, George
Copy link to clipboard
Copied
You can use a doc-level script to run code when the file is opened (Tools - JavaScript - Document JavaScripts), and a page's Page Open event to run code each time the page is viewed (right-click the page in the Pages panel, select Properties, Actions).
Copy link to clipboard
Copied
It looks like I will need to wait until tomorrow to see where to access these windows: I'm working from home today, and I'm using Acrobat Pro X (v10). At work, I have Acrobat Pro DC. I cannot locate those areas. Where might I look for them in Pro X?
What would generic Open File and Page Open event scripts look like?
And yet again, thank you Gilad D so much for continuing to provide direction and advice.
Best,
George
Copy link to clipboard
Copied
It's pretty much the same in both versions, although it's a bit harder to find under DC.
Not sure what you mean by "generic script"... What do you want that script to do?
If you just want to test it you can use something like this:
app.alert("Hi!");
Copy link to clipboard
Copied
By generic script, I wanted to be sure I understand how to trap an appropriate event at the level of document or page. I'm not familiar with what events are available at these levels, so I am not confident of how to set up the script. I am looking for general directions that would be something like this...
When a document opens
do this
maybe this too
End
When a page is opened
do this
and this
End
It would be great to get a list of available events I can use 🙂
Specifically, what I want to do is when the form is opened, I want to run this:
this.getField("SupervisorSignature").display = display.hidden;
this.getField("GenCounselingStudentSignature").display = display.hidden;
this.getField("PDSignature").display = display.hidden;
this.getField("ValidateFormFeedback").display = display.hidden;
As before Gilad, thank you for taking the time to help!
Best,
George
Copy link to clipboard
Copied
You don't "trap" them. You simply need to place the code in the right locations (the ones I described earlier) and they'll be automatically executed when those events occur.
Copy link to clipboard
Copied
Thanks Gilad D (try67), your last suggestions took me in the right direction. Also, just as you earlier posted, it's pretty straight forward to find where to place document level scripts in Acrobat Pro DC - just as you mentioned. It's different in the version X.
Here is the generic script I ended up modifying ....
function doMyscript() {
// Code goes here
}
// Call the function
doMyscript();
And here is the working script...
function HideSignatureFields()
{ this.getField("SupervisorSignature").display = display.hidden;
this.getField("GenCounselingStudentSignature").display = display.hidden;
this.getField("PDSignature").display = display.hidden;
this.getField("ValidateFormFeedback").display = display.hidden;
}
HideSignatureFields();
Thanks again!
Best, George

