Skip to main content
Participant
May 15, 2016
Question

Using saveAS on a PDF form opened in Outlook

  • May 15, 2016
  • 2 replies
  • 829 views

Hi Guys and Gals (assuming there are some Nerdy Gals out there )

I have this lovely expense claim form I created and want to have it approved electronically, meaning I will fill out the form and click a "Submit" button to email it to my boss for approval. This all works fine.

When my boss gets the email in Outlook, he double-clicks the attached expense form to review. Hopefully he will click "Approve" at the bottom

The "Approve" button tries to save the Form using this.saveAs in a privileged context.to a trusted location on the bosses hard disk.

That's where it all goes wrong....

Anyway here's my code:

In C:\Program Files (x86)\Adobe\Reader 11.0\Reader\Javascripts I have a script called MyTrusted.js:

var MySavesAs=app.trustedFunction(

function(oDoc,cPath,cFlName)

{

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

try{

oDoc.saveAs(cPath+cFlName);

}catch(e){

app.alert("Error during save");

}

}

)

I'm sure Thom Parker will recognise this, cos he wrote it!

In the mouseUp JavaScript for my button, I have

if (typeof(MySaveAs)=="function")

{

var MyPath="C:/AIF/";

var MyFileName=this.documentFileName;

MySaveAs(this,MyPath,MyFileName);

}

Anyway. When the boss opens the attached pdf in Outlook, it is cached in C:\outlookcache\

When he hits the Approve button with the aforementioned button script, he gets "Error during save" from the trusted function MySaveAs.

I have tried to add the directory C:\outlookcache\ to the list of Privileged Locations under the Enhanced Security Preferences, Reader doesn't accept this.

If the Boss manually Clicks File>Save As and saves to C:\AIF\ (which IS on the list of Privileged Locations), and then opens that file from that location he can approve without problems i.e. the script works perfectly.

So, how do I get around this security restriction?

"Enable Protected Mode at Startup" has been switched off, as has "Enable Enhanced Security" but to no avail

Please tell me I am doing something wrong!!

Louis

This topic has been closed for replies.

2 replies

Karl Heinz  Kremer
Community Expert
Community Expert
May 16, 2016

You need to wrap the call to Doc.saveAs() with app.beginPriv() and app.endPriv():

var mySaveAs = app.trustedFunction(

   function(oDoc,cPath,cFlName)

   {

      // Ensure path has trailing "/"

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

      try{

         app.beginPriv(); // <-- NEW

         oDoc.saveAs(cPath + cFlName);

         app.endPriv();   // <-- NEW

      }catch(e){

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

      }

   }

);

You can find more about how to raise the execution privileges in the API documentation: Acrobat DC SDK Documentation

Karl Heinz  Kremer
Community Expert
Community Expert
May 15, 2016

Your path is wrong. Acrobat uses device independent paths that are different than your normal windows paths. Try this instead:

"/C/AIF/"

Participant
May 15, 2016

Nope that didn't work

As I said, this script does work if the file has been opened from a "Privileged Location", but not as an attachment to an Email