Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Show Form Buttons Only works in Acrobat Pro or Reader

New Here ,
Jun 10, 2024 Jun 10, 2024

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. 

TOPICS
How to , PDF forms
5.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
Jun 10, 2024 Jun 10, 2024

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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2024 Jun 11, 2024

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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2024 Jun 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;
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2024 Jun 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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2024 Jun 10, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2024 Jun 10, 2024

I was able to locate the Document Javascripts and input that code in there.  When I open the PDF in Chrome or Safari, the buttons are still shown when they shouldn't be.  Ideas? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2024 Jun 10, 2024

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? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2024 Jun 10, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2024 Jun 10, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2024 Jun 11, 2024

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2024 Jun 11, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2024 Jun 11, 2024

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2024 Jun 11, 2024

User error.  [Enter] acts like a carriage return.  [Command] + [Enter] works and gives me data now. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2024 Jun 11, 2024
LATEST

Correct.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2024 Jun 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-p...

https://www.abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/forcer-utilisation-p...

 


Acrobate du PDF, InDesigner et Photoshopographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines