Copy link to clipboard
Copied
Hi. Is there a code to add to a PDF form to prevent it from opening in a web browser? I have a form with password protections that are bypassed when the form is opened in a web browser due to the user not having a pdf reader installed.
You can try it with this code, but be aware it's not fool-proof. It could very well be that some PDF viewers are so bad they won't show the field at all, causing the underlying contents to be revealed...
if (app.viewerType=="Reader" || app.viewerType=="Exchange" || app.viewerType=="Exchange-Pro") {
this.getField("CoverField").display = display.hidden;
}
Copy link to clipboard
Copied
I got an idea from another post, but I don't know how to make it work. I created a read-only text field (visible but doesn't print) and expanded it over the entire page. The field states "You must have a PDF reader installed or print it to use this form". I need to know where to place a code similar to the 1 below to make the text field visible if the form is opened in a web browser and hidden if opened in a pdf reader.
if (app.viewerVersion < 9) {
this.getField("theWarningField").display = display.visible;
}
else if ( app.viewerVersion >= 9 ) {
this.getField("theWarningField").display = display.hidden;
}
Copy link to clipboard
Copied
You can try it with this code, but be aware it's not fool-proof. It could very well be that some PDF viewers are so bad they won't show the field at all, causing the underlying contents to be revealed...
if (app.viewerType=="Reader" || app.viewerType=="Exchange" || app.viewerType=="Exchange-Pro") {
this.getField("CoverField").display = display.hidden;
}
Copy link to clipboard
Copied
Thanks. This seems to work. I can't fully test it because a have a reader on my computer. However, I did a preview in a browser window and saw the field.
I ended up placing a dcument script:
if (app.viewerType=="Reader" || app.viewerType=="Exchange" || app.viewerType=="Exchange-Pro") {
this.getField("CoverField").display = display.hidden;
}
I also added the following script under document actions > Document Will Close so that the field reapears for the next user:
if (app.viewerType=="Reader" || app.viewerType=="Exchange" || app.viewerType=="Exchange-Pro") {
this.getField("CoverField").display = display.noPrint;
}
Copy link to clipboard
Copied
Well, it seems I have a problem with this. If I go to close it, then, hit cancel, the CoverField field is visible and doesn't go away.
Copy link to clipboard
Copied
If a PDF viewer doesn't support JS, then you can't use JS to do something. The setup has to be failsafe, meaning it works when JS isn't supported. So make the field visible to start, then use the JS to make it hidden (as shown by Try67). If the viewer is does not support JavaScript, or is an old Acrobat, the field stays visible.
Copy link to clipboard
Copied
If you can't read French copy-paste these URL in Google Translate to learn killer tips:
&
Copy link to clipboard
Copied
I need to try this method as I had problems with using the above method. I don't have the programs listed. Is there 1 that doesn't have to be purchased just to add a layer.