Allow/Disallow scripts while running PDF

Skip to first unread message

Gowtham Lcs

Nov 13, 2019, 4:57:08 PM11/13/19
to PDFTron WebViewer
Hi Team,

We would like to get the consent from user before running the script embedded in PDF document while previewing the PDF. For, example now I am uploading the attached file and viewing the preview throws general browser alert, on pressing ok it starts running the script on the preview. 

But we would like to get the consent from user to run or stop the script further. Do we have any settings to control this behavior. Please share. Thanks. 


Gowtham C




Kristian Hein

Nov 14, 2019, 7:15:20 PM11/14/19


You can use the following code in a config file:

var firstRun = true;
var allowJavaScript = false;
var onTriggered = Actions.JavaScript.prototype.onTriggered;
Actions.JavaScript.prototype.onTriggered = function(target, event) {
  if (firstRun) {
    firstRun = false;
    allowJavaScript = window.confirm('Allow document JavaScript?');
  if (!allowJavaScript) {
  onTriggered.apply(this, arguments);

This was done using

See config file guide here:

Best Regards,

Kristian Hein

Developer - WebViewer

PDFTron Systems, Inc.

CONFIDENTIALITY NOTICE: This message (and any attachment to it) is intended only for the use of the individual or entity to which it is addressed in the header, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any reproduction, distribution, modification or use of the contents of this message (and any attachment to it) by any individual or entity other than the intended recipient is prohibited. If you have received this communication in error, please notify us immediately and delete the original.

Reply all
Reply to author
0 new messages