Skip to main content
Participating Frequently
June 10, 2024
Answered

Show Form Buttons Only works in Acrobat Pro or Reader

  • June 10, 2024
  • 2 replies
  • 6442 views

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. 

This topic has been closed for replies.
Correct answer PDF Automation Station

Care to elaborate a little more on this for someone not fluent in Javascript?


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.

2 replies

JR Boulay
Community Expert
June 11, 2024

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):

https://www.abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/forcer-utilisation-pdf-avec-un-vrai-pdf-reader

https://www.abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/forcer-utilisation-pdf-avec-acrobat

 

Acrobate du PDF, InDesigner et Photoshopographe
PDF Automation Station
Community Expert
June 10, 2024

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;
}

 

mr_xaeroAuthor
Participating Frequently
June 10, 2024

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. 

mr_xaeroAuthor
Participating Frequently
June 11, 2024

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.


Care to elaborate a little more on this for someone not fluent in Javascript?