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

Web Browser

Participant ,
Jan 30, 2024 Jan 30, 2024

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.

TOPICS
PDF , PDF forms
1.4K
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 30, 2024 Jan 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;
}

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
Participant ,
Jan 30, 2024 Jan 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;
}

 

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 ,
Jan 30, 2024 Jan 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;
}
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
Participant ,
Jan 30, 2024 Jan 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;
}

 

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
Participant ,
Jan 30, 2024 Jan 30, 2024

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.

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 ,
Jan 30, 2024 Jan 30, 2024

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.

 

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

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 ,
Jan 30, 2024 Jan 30, 2024

If you can't read French copy-paste these URL in Google Translate to learn killer tips:

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 Photoshoptographe
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
Participant ,
Jan 30, 2024 Jan 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.

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 ,
Aug 13, 2024 Aug 13, 2024
LATEST

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


Acrobate du PDF, InDesigner et Photoshoptographe
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 ,
Aug 12, 2024 Aug 12, 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
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