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 🙂
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
...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
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
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.
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.
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.
Copy link to clipboard
Copied
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
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.
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.
Copy link to clipboard
Copied
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.