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

Using saveAS on a PDF form opened in Outlook

New Here ,
May 15, 2016 May 15, 2016

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 availPreferences.jpg

Please tell me I am doing something wrong!!

Louis

TOPICS
Acrobat SDK and JavaScript , Windows
734
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 ,
May 15, 2016 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/"

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 ,
May 15, 2016 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

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 ,
May 15, 2016 May 15, 2016

Using the following code:

var ReportedPath=this.path;

app.alert("the PATH is: "+ReportedPath);

I get this:

path.jpg

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 ,
May 15, 2016 May 15, 2016

Which version of Outlook, and on what operating system are you running this?

What is the exact error,that is getting thrown? You can display that by changing this one line:

app.alert("Error during save: " + e);

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 ,
May 15, 2016 May 15, 2016

Outlook Version 14.0.7166.5000

Windows 7 Enterprise SP1

Error During SAve: NotAllowedError: Security settings prevent access to this property or method""

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 ,
May 15, 2016 May 15, 2016

What is the file-name you're trying to use?

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 ,
May 15, 2016 May 15, 2016

it varies with job number and date. Here's an example:

RKB - 10012345 - OKeeffe - 12-Apr-2016.pdf

No illegal characters

Like I said, this works fine from another directory. There doesn't seem to be a problem with the path or filename

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 ,
May 16, 2016 May 16, 2016
LATEST

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

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