These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Email PDF in Acrobat without user intervention

BAWD001
Registered: Jan 21 2009
Posts: 47
Answered

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.

My Product Information:
Acrobat Standard 9.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
the “Enable Menu Items JavaScript Execution Privileges” won't help you. Back in Acrobat 6, menu item scripts were privileged by default. So the way to run a privileged script was to create a menu item with a folder level script and then run the menu item from another piece of code. Once they added the trustedFunction(), this menu methodology was unnecessary, and potentially dangerous, so they disabled it. This Preference is to allow older scripts to operate properly.

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

BAWD001
Registered: Jan 21 2009
Posts: 47
Thanks Thom,

It looks like I'll need to upgrade to Acrobat 9 Pro to get access to folder level scripting.

/Brian
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
No, folder level scripting has been around since Acrobat 3. The concept of "privilege" was formalized in Acrobat 7 with the introduction of the "app.trustedFunction()" function.

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

BAWD001
Registered: Jan 21 2009
Posts: 47
Hmmm.

After reading the provided article on folder level scripting then accessing its [i]JavaScript Console[/i] link, it states:

[i]In Preferences, select the JavaScript pane. Make sure both Enable Acrobat JavaScript and Enable interactive console are checked. It’s a good idea to also check Enable JavaScript debugger after Acrobat is restarted so you can use some of the other debugging features, if necessary.[/i]

I can set [i]Enable Acrobat JavaScript[/i], I can set [i]JavaScript Debugger|Show console on errors and messages[/i] (I assume this is the equivalent to [i]Enable JavaScript debugger[/i]), but I have no option to [i]Enable interactive console[/i] in Acrobat 9 Standard (v9.1.0).

I think it's been removed on Acrobat 9 Standard and is only available in Acrobat 9 Pro.

Comments?

/Brian
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Sorry, I missed the bit about Acrobat Standard. The article is written specifically for Acrobat Pro, on a version earlier than 9. The debugger/interactive console did not come with previous versions of Acrobat Standard. So the options you are seeing are new to Standard. Anyway, none of that is important. The JavaScript Console doesn't have anything to do with folder level scripts. The console is a tool you use to debug and test code. In the article the console is only used to run code that identifies the location of the JavaScript folders.

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

BAWD001
Registered: Jan 21 2009
Posts: 47
Sooo ... I assume that if I create the trusted function Javascript as a .js file (eg. sendform.js) and place it in the same online folder as where the online PDF resides (becoming the [i]app[/i] JavaScript path?), that it will be accessible to the user, accessing the PDF through the Acrobat Reader via their web browser , and will function properly?

What if the user saves the PDF to their local PC? Is there anyway to specify [i]within the PDF[/i] to access the online sendform.js file to allow the trusted function to execute properly? Otherwise, I assume clicking the Save button would have to not only save the PDF to the local PC but also save the sendform.js to that user's [i]user[/i] JavaScript path in order to function.

That would be just way too clunky for me (vs. the ideal of simply having the capability to imbed [i]trusted function[/i] functionality within the PDF itself).

Is there simply no other way to create a PDF-imbedded MailDoc javascript function that allows user-intervention-free emailing of that PDF file?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The JS file needs to be placed in one of the JavaScript application folders on the end user's system, local PC. Adobe does this so to limit release of user's personal data without the end user's permission.

George Kaiser

BAWD001
Registered: Jan 21 2009
Posts: 47
Thanks Thom.

So I guess my options are:

1. Continue without the trusted function and force users to click [i]Send[/i] in their email software (clunky)
-or-
2. Change the sending/receiving mechanism to something server based (time consuming and too expensive for the client)
- or-
3. Is there another option that's an easy, non-trusted-function, method for transferring FDF data via email automatically and having it readable at the receiving end by simply clicking on the FDF attachment and having the data load automatically into the original PDF form?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You are correct!! The user must hit the send button. The basic rule of Acrobat and PDF is that you can't do anything without the user knowing whats going on. If you want something to happen silently, then the user must deliberately install something on thier system to allow it.

There are simpler ways to handle the server side. For example, www.formrouter.com.

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

BAWD001
Registered: Jan 21 2009
Posts: 47
For now, I think I'll stick with the current MailDoc and manual email [i]Send[/i] setup.

Thanks for the link to Formrouter. In the future, if my client requires database or spreadsheet data management (eg. to import into accounting or other software) I'll look into it more closely.

Thanks again for your comments and feedback Thom.