Skip to main content
drslrb
Known Participant
January 30, 2024
Answered

Web Browser

  • January 30, 2024
  • 3 replies
  • 2146 views

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.

This topic has been closed for replies.
Correct answer try67

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

3 replies

Participant
August 13, 2024

To ensure your PDF form is opened in a dedicated PDF reader and not a web browser, follow these steps:

 

1. Add a Warning Message: Include a note on the first page of the PDF:
> "Please open this form in Adobe Acrobat Reader to maintain password protection and functionality. Opening in a web browser may disable these features."

2. Host PDF for Download: Provide a download link on a web page with a clear instruction:
> "Download and open with Adobe Acrobat Reader. Browser viewing may bypass security."

3. Use PDF Features: Utilize advanced form features or JavaScript that require a dedicated PDF reader, discouraging browser use.

 

Adobe Community Profile 

https://youtubethumbnaildownloaderonline.com
JR Boulay
Community Expert
Community Expert
January 30, 2024
drslrb
drslrbAuthor
Known Participant
January 30, 2024

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.

JR Boulay
Community Expert
Community Expert
August 13, 2024

The simpliest way is placing the PDF form into a PDF Portfolio.

Acrobate du PDF, InDesigner et Photoshopographe
drslrb
drslrbAuthor
Known Participant
January 30, 2024

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

 

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 30, 2024

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;
}
drslrb
drslrbAuthor
Known Participant
January 30, 2024

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