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

Button to Attach File in Reader

mrogers
Registered: Sep 20 2007
Posts: 2

In creating/editing a form in LiveCycle, I would like to create a button that my Reader users can click to allow them to attach a file(s) to the form, which they will then submit back to me. I know that the user could simply go to Tools, Comments & Markup, Attach a file as a comment, but this will be too complicated for my very low-tech users. What is the most efficient way of creating this function? Thanks.

My Product Information:
LiveCycle Designer, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
Follow this link:

[url=http://www.box.net/shared/qimy7l9h7i]http://www.box.net/shared/qimy7l9h7i[/url]

Open the PDF (Developing Acrobat® Applications Using JavaScript), search for - keyword - attachment. Select the method you want to use.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
Registered: Jul 9 2006
Posts: 858
Make sure your LiveCycle Form is saved as an Acrobat 7 (Static) PDF form so it will be compatible with more users.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
Registered: Jul 9 2006
Posts: 858
This code (button click) will email the current PDF as an attachment.

var myDoc = event.target;
myDoc.mailDoc(true, "management [at] company [dot] com", "supervisor [at] company [dot] com", "ceo [at] company [dot] com", "Employment Application Form");++++++++++++++++++++++++++++

If the file attachment is not FDF, XDP, XFDF, HTML, XML, XFD, OR PDF, use this button click script in LiveCycle.

app.mailMsg(false, "youremail [at] yourcompany [dot] com; [url=mailto:otheremail [at] yourcompany [dot] com"]otheremail [at] yourcompany [dot] com"[/url], "","",
"This is the subject", "Please use your email application to attach the excel spreadsheet file to this message.");

This code allows the user to browse their hard drive for the file to attach.

Note: In LiveCycle Designer, you must ensure that the scripting language for the event is set to JavaScript
so that the script will execute correctly at run time.

Make sure all incoming file attachments are throughly check for virus and other nasty programs.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
Registered: Jul 9 2006
Posts: 858
The solution I posted is the simpliest way to instruct the user to browse their hard drive for the file to attach.

I'll post another method using LiveCycle that is a little more complicated so I'll need time to write the complete instructions.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
Registered: Jul 9 2006
Posts: 858
After further review and testing of a few scripts, I discovered that the only solution to this issue is the one that I posted in my initial response with instructions in the body of the email on having the user attaching a file.

Here are a couple on incomplete scripts that will work in LiveCycle, which you can experiment with.

Put the following javascript on "click" event of a button will pop up a file browser that you can select a file from your client's hard drives.

var myDoc = event.target;
var sFile = "myFile"
myDoc.importDataObject(sFile);

Here is the code to display the selected file name in a text field:

var myDoc = event.target;
var sFile;
myDoc.importDataObject(sFile);
var myDataObject = myDoc.getDataObject(sFile);

TextField1.rawValue = myDataObject.path;

According to the Acrobat JavaScript Scripting Reference, Reader can not use the "importDataObject", unless the PDF has had Extended Reader Usage Rights applied to the PDF. If you manage to get the script to work, you'll have to enable Extended Reader Usage Rights or the person receiving the form must open it in Acrobat Pro OR render the form through Reader Extensions with attachment enabled.

Sorry, I couldn't help.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

thea_ls
Registered: Oct 24 2007
Posts: 12
Eugene, I am wanting to do the same thing as mrogers, but I am unable to access your link which looks like it may have the answer. Do you know why this is?
brianscottoliver
Registered: Oct 29 2007
Posts: 6
Eugene,
I am also wanting to do the same thing and there are no shared files when I open the link.

I would appreciate any help
sweta pandya
Registered: Mar 13 2009
Posts: 4
I am using myDoc.importDataObject(sFile); functions for attachment & trying to open with adobe reader (i have design PDF by using adobe livecycle Designer 8)But in reader i am getting error :
NotAllowedError: Security settings prevent access to this property or method.

As previous Posts for enable attachments rights need adobe acrobat pro Or Reader Extensions.

How can i enable attachment rights by adobe acrobat pro 8?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
It is not possible to attach a PDF to a Designer-form (XML form), this only works for forms created by Acrobat.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Have you checked the security restrictions about using this method?

See the Acrobat JavaScript API Reference for more information about trusted fucntions and priviliged operations.

George Kaiser