Copy link to clipboard
Copied
I am working on a simple PDF form that contains a handful of free text fields (of which some are required) and roughly twenty checkbox fields. There are also two buttons, a "Submit" and a "Reset". The "Submit" button is tied to a mouse up action which sends the entire form via email. I have noticed that the PDF form works and sends itself via email when accessed/opened via Acrobat Pro or Acrobat Reader. However, if the PDF is opened via a browser (Edge, Safari, Chrome, Firebox, etc.) the Submit button does not work and it will not send via email.
I am looking for ways to set the form to either a.) hide the buttons when opened outside of Acrobat Pro/Reader or b.) hide the form all together and display a message that the PDF will need to be opened in Acrobat Pro/Reader.
Any assistance in this would be greatfully appreciated as I am a newbie to creating PDFs that aren't just print outs and that my GoogleFu has resulted no worthy results.
Copy link to clipboard
Copied
You are supposed to hide the button in the properties. The code displays it if an Adobe viewer is used. If open in a web browser, the code probably won't be supported so the button won't display. If the code does work the button still won't display because the viewer is not one of the types in the script.
Copy link to clipboard
Copied
1) Replace "Button" with actual name of your button field in any scripts that follow.
2) Obtain the rect property of your field by running the following script in the console:
this.getField("Button").rect;
it should return 4 numbers separated by commas. Copy those numbers, including the commas.
3) Replace the line of code inside the curly brackets from script above with the following:
this.getField("Button").rect=[ ];
Paste the 4 numbers and commas between the square brackets in the code above.
4) In the console run the following script:
this.getField("Button").rect = [0,0,0,0];
After you run the code the button should disappear from view (programatically it is still there but its rectangle is an invisible speck in the bottom left corner of the page).
5) Save the file.
When you open the form with Adobe the button should appear where it belongs. When you open the form in a web browser the button won't be visible, including the hover. If you open your form with Adobe, don't save it without running the [0,0,0,0] script in the console first.
Copy link to clipboard
Copied
Add the following document level script that tests the application PDF viewer and changes the button to "visible but doesn't print" (or 'visible' if that's what you want). Then set the field to hidden and save the document. If it is opened with a non-Adobe PDF viewer the button will be hidden. Change "Button" to the name of your field of course.
if(app.viewerType=="Reader" || app.viewerType=="Exchange" || app.viewerType=="Exchange-Pro")
{
this.getField("Button").display=display.noPrint;
}
Copy link to clipboard
Copied
Please forgive me but where might I locate the "document level script"?
I am using Acrobat Pro 2024.002.20759.0 with the old UI enabled.
Copy link to clipboard
Copied
In the Tools Tab search JavaScript and then click Document JavaScripts. You can also move this tool to the regular toolbar by right-clicking the toolbar and selecting Customize Quick Tools.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I found that in order to hide the button using the code, you actually have to hide the button in the properties. Once hidden, it will not show in the other applications other than Acrobat and Reader. However this poses another issue since as the button is not visible it still allows for the area where the button is to be found by hovering over it with the mouse. Any ideas how to get that to stop?
Does the button just need to go away using another script?
Copy link to clipboard
Copied
You are supposed to hide the button in the properties. The code displays it if an Adobe viewer is used. If open in a web browser, the code probably won't be supported so the button won't display. If the code does work the button still won't display because the viewer is not one of the types in the script.
Copy link to clipboard
Copied
Add a line of code in the document level script that changes the rect of the button to what it actually is. Then use the console to set the rect of the button to [0,0,0,0] and save the document.
Copy link to clipboard
Copied
Care to elaborate a little more on this for someone not fluent in Javascript?
Copy link to clipboard
Copied
1) Replace "Button" with actual name of your button field in any scripts that follow.
2) Obtain the rect property of your field by running the following script in the console:
this.getField("Button").rect;
it should return 4 numbers separated by commas. Copy those numbers, including the commas.
3) Replace the line of code inside the curly brackets from script above with the following:
this.getField("Button").rect=[ ];
Paste the 4 numbers and commas between the square brackets in the code above.
4) In the console run the following script:
this.getField("Button").rect = [0,0,0,0];
After you run the code the button should disappear from view (programatically it is still there but its rectangle is an invisible speck in the bottom left corner of the page).
5) Save the file.
When you open the form with Adobe the button should appear where it belongs. When you open the form in a web browser the button won't be visible, including the hover. If you open your form with Adobe, don't save it without running the [0,0,0,0] script in the console first.
Copy link to clipboard
Copied
So this whole thing is starting to frustrate me as I have found the console but it was not in the location shown in the website example. There is no where to run that script in the console. I can only assume that I am doing something wrong or that it is due to the fact that I am on a Mac. Both are quite possible.
Do I need to input that script in the document like the other? If so, how do I call upon it via this console? (see attachment)
Copy link to clipboard
Copied
User error. [Enter] acts like a carriage return. [Command] + [Enter] works and gives me data now.
Copy link to clipboard
Copied
Correct.
Copy link to clipboard
Copied
The easiest way is to place your form in a PDF Portfolio.
Otherwise you can use these great tips (copy-paste the URL in Google Translate if you can't read French):
Find more inspiration, events, and resources on the new Adobe Community
Explore Now