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

Warning pop up message when not filling form on acrobat

New Here ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

Hi! I'm trying to create a pop up warning when an user opens a PDF form with a different app other than Acrobat Reader or Acrobat DC.

 

So far I've dug up a lot in the Acrobat forums, but I haven't really found anything related.

 

I wrote the following JS code, but it won't run:

 

 

if (app.viewerVersion < 9) {
    app.alert("You must have Acrobat Reader 9.0 or higher to use this form.")
    this.closeDoc(true)
    }

 

 

If anyone has done something similar, please let me know how you did it or at least help me get in the right direction 🙂

TOPICS
Create PDFs , Edit and convert PDFs , General troubleshooting , How to , PDF forms

Views

3.6K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , May 15, 2020 May 15, 2020

I would include a message on the first page "This PDF form needs to be opened in Acrobat or the free Adobe Reader" and include a link to Reader. You could also create a layered PDF, with the top layer containing a big red warning with the same message. In Acrobat, set the warning layer properties to Never View & Never Print, so people using Acrobat & Reader will never see it. When the PDF is opened in Mac Preview or Safari, they will see the message. Unfortunately, some non-Adobe viewers (like C

...

Votes

Translate

Translate
Community Expert ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

Hi,

 

If you are not using Adobe Acrobat or Reader ( or if the user had JavaScript switched off ) Then you code above would not work as it would not be run, one way to handle this would be to have a field that is shown on the document by default, you could then use the code above with a slight modification may work.

 

if ( app.viewerVersion >= 9 ) {

this.getField("theWarningField").display = display.hidden;

}

 

The idea here is that when the file is opened in a supported version the JavaScript runs and hides the warning field, but when you open it in a non-supported then the warning field would not be hidden and the user would see it.

 

Regards

Malcolm

Votes

Translate

Translate

Report

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 ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

Hi Malcolm! 

 

You are absolutely right. I underlooked this problem and the possible solutions. But hopefully anyone else with the same question will be able to see your answer. I will be using yours and Luke's solutions for now. I may need to look for an alternative outside Acrobat to acomplish the desired form features I wan't. Thanks for the quick responses.

 

-Monti

Votes

Translate

Translate

Report

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 ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

Here's a layer based solution:

https://www.pdfscripting.com/public/Lite-Document-Security-Description.cfm

 

The idea is similar to Lukes, A layer (OCG) is used to obscure the page(s) in a PDF until. A document level script hides the layer based on some criteria. If PDF is opened in an application that does not support the layer JavaScript, then the layer remains in place. Simple and failsafe.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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 ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

I would include a message on the first page "This PDF form needs to be opened in Acrobat or the free Adobe Reader" and include a link to Reader. You could also create a layered PDF, with the top layer containing a big red warning with the same message. In Acrobat, set the warning layer properties to Never View & Never Print, so people using Acrobat & Reader will never see it. When the PDF is opened in Mac Preview or Safari, they will see the message. Unfortunately, some non-Adobe viewers (like Chrome) will respect the Never View layer properties, so it's not a perfect solution.

Votes

Translate

Translate

Report

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 ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

"I would include a message on the first page "This PDF form needs to be opened in Acrobat or the free Adobe Reader" and include a link to Reader."

This is useless since PDF Readers that don't support AcroForms don't support JavaScript too, so this alert will never be displayed.

 

But you're right for the rest, adding a hidden layer is the most efficient tip to avoid the form to be opened in a low-end PDF reader.

(And you know what? It works in AdobeSigned PDFs too)

 

I put your message as the best answer.

 

Votes

Translate

Translate

Report

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 ,
Dec 10, 2022 Dec 10, 2022

Copy link to clipboard

Copied

I added a layer, all the text covered by the new layer but all the buttons/checkboxes remain displaying above the new layer (see attached photo). 

Is there a way to hide all buttons as well?

Thnak you

Votes

Translate

Translate

Report

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 ,
Dec 12, 2022 Dec 12, 2022

Copy link to clipboard

Copied

"Is there a way to hide all buttons as well?"

No.

Form fields don't rely on a layer, they float over all other elements.

You should use a form field instead of a layer, if you can't read French copy-paste this URL in Google Translate to learn how to do:

https://www.abracadabrapdf.net/?p=6148

 

If you want your PDF to be opened with Acrobat only you must use this killer tip:

https://www.abracadabrapdf.net/?p=72142

 

Votes

Translate

Translate

Report

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 ,
Dec 12, 2022 Dec 12, 2022

Copy link to clipboard

Copied

I really like JR's solution!  

 

However, any visual element in a PDF, including fields and annotations, can be attached to an OCG layer. There's just no tool in Acrobat for doing this.  But it probably wouldn't matter anyway because if the viewer doesn't understand layers, of course it's not going to hide the fields if the layer is turned off.  

For the layer solution, the best approach for form fields is to make them all hidden. Then use a document script to unhide them. However, it's not fail safe because viewer behavior is unknown. Crappy viewers may show fields that are explicitly hidden. And that is of course the problem with crappy vierwers.  

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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 ,
Dec 13, 2022 Dec 13, 2022

Copy link to clipboard

Copied

 

For the layer solution, the best approach for form fields is to make them all hidden. Then use a document script to unhide them. However, it's not fail safe because viewer behavior is unknown. Crappy viewers may show fields that are explicitly hidden. And that is of course the problem with crappy vierwers.  


By @Thom Parker

 

Yes, it doesn't work well, especially with Apple Preview, for the reason you suspect.

 

Other approaches:
- make 3x3 pixel fields placed in a corner of the page and use JavaScript to place and size them. But the more fields you have, the more laborious it is.
- place the fields on a template page and use JavaScript to spawn it using the bOverlay parameter to overlaid on the page.

Votes

Translate

Translate

Report

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 ,
Dec 13, 2022 Dec 13, 2022

Copy link to clipboard

Copied

LATEST

The page template overlay solution seems like the best one for the OCG layer method of obscuring content 🙂  

If a viewer supports both OCG layers and Page Templates, then that viewer Rocks!!  And is worthy enough to display a PDF form.  

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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