I'm trying to create a button on a PDF form in Acrobat 9 Standard that will allow an online Acrobat Reader user (from their web browser) to send the filled-in PDF form to a fixed email address without user intervention (i.e. without loading the user's email software to send). Ideally, after successful sending I'd like to show a popup that acknowledges that the PDF form was successfully sent.
Progress:
I've been able to create a button that, when clicked, creates an email message with the filled-in PDF file attached, set to send to the appropriate recipient with the appropriate Subject and Message body text. It can then be sent successfully by having the user click the Send button in their email software.
I've properly set the extended rights for Adobe Reader users to fill-in and save the PDF (menu Advanced|Extend Forms Fill-in & Save in Adobe Reader...).
Research:
From reading the JavaScript™ for Acrobat® API Reference, pg. 32 there appears to be two ways to allow functions that require privileged access (eg. MailDoc sending of a PDF without user interaction) to run in a non-privileged context.
1. By opening the JavaScript category of the Acrobat preferences and checking the item named “Enable Menu Items JavaScript Execution Privileges”.
2. By executing a specific method through a trusted function (introduced in Acrobat 7.0). Trusted functions allow privileged code—code that normally requires a privileged context to execute—to execute in a non-privileged context. For details and examples, see app.trustedFunction.
I've tried Option 1 and that does not seem to change the result (i.e. still loads the email software with user interaction required to send).
I have not tried Option 2 because I am unclear on a few issues. Does the trusted function Javascript code need to be in a separate .js file? If so, where does that .js file need to reside? How is the .js file referenced in the PDF file (or does it just scan ALL .js files in the directory)? Note: This PDF form's users can, and are encouraged to, save the PDF form offline for testing calculations and potentially sending the filled-in form via the same button. If the form is saved to the user's local PC drive would they also need to save the .js file to the same directory to make it work?.
The simple existing Javacript code for the button (Properties|Actions|Mouse Up|Run Javascript) is as follows:
//
// Set email address (I use an ACTUAL email address vs. the fake one below)
//
var cToAddr = "xxx [at] xxx [dot] xxx";
//
// Set the subject and body text for the e-mail message
//
var cSubLine = "Online Order";
var cBody = "Message body text";
//
// Send the form data as a PDF attachment in an e-mail message
//
this.mailDoc({bUI: false, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});
___________
Do I need to upgrade to Acrobat 9 Pro? (eg. to make the "Preferences|JavaScript|Enable Menu Items JavaScript Execution Privileges" work or for any other reason)?
Any hints on setting up a popup acknowledging a successful delivery of the PDF form via email?
Any help you could provide would be appreciated.
To setup a folder level script see this article:
http://www.acrobatusers.com/tutorials/2006/folder_level_scripts
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script