Skip to main content
Zogthemighty13
Participating Frequently
May 5, 2022
Question

Trusted Functions in Reader on a Windows 11 tablet.

  • May 5, 2022
  • 1 reply
  • 925 views

I have a form with a button to check through the form and save it using two field values combined as the name. For this I created a Save As Trusted Function (following instructions from here: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript/) which all worked fine on my Windows 10 PC using DC Pro. The idea is to run the forms from a tablet at the entrance to our building. When I transferred everything across to the tablet running windows 11 the Save As function no longer works. I have placed my Trusted Function script in what I understand to be the correct folders:

C:\Prgram Files\Adobe\Acrobat DC\Acrobat\Javascripts 

and:

C:\Users\*this user*\AppData\Roaming\Adobe\Acrobat\DC\Javascripts

I get this error when I press the save button:

“Error During Save – NotAllowedError: Security settings prevent access to this propert or method.”

Here are my scripts.

Folder Lever – trusted function script:

var mySaveAs = app.trustedFunction(

    function (oDoc, cPath, cFlName) {

        cPath = cPath.replace(/([^/])$/, "$1/");

        try {

            app.beginPriv();

            oDoc.saveAs(cPath + cFlName);

            app.endPriv();

        }

                                catch (e) {

            app.alert("Error During Save - " + e);

        }

    });

 

Save As function from the button:

            var recordFileName =

                this.getField("Company").valueAsString + " " + this.getField("startDate").valueAsString;

            console.println("recordFileName = " + recordFileName);

            //set all fields as read only

            for (var k = 0; k < this.numFields; k++) {

            this.getField(getNthFieldName(k)).readonly = true;

            };

            //save file to folder

            var directory = "/c/Users/Tech Department/LGT&OH Ltd/Health & Safety - Venue Information - Documents/Site Inductions/Completed Induction Forms/"

                if (typeof(mySaveAs) == "function") {

                    mySaveAs(this, directory, recordFileName + ".pdf");

                                                                                app.openDoc("/c/Users/Tech Department/LGT&OH Ltd/Health & Safety - Venue Information - Documents/Site Inductions/Master Forms/Contractor Induction.pdf");

                } else {

                    app.alert("Missing Save Fucntion. Please contact forms administrator");

                };

        }

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 6, 2022

Does it work if you run the saveAs command, with the same file path value, from the Console?

Zogthemighty13
Participating Frequently
May 6, 2022

I'm struggling to find a way to access the console in Reader DC. It has appeared to report errors when saving but I can't find a way to open it.

try67
Community Expert
Community Expert
May 6, 2022

If you can't press Ctrl+J you can use a script attached to a button that runs this code:

console.show();