Copy link to clipboard
Copied
I need to create a button or link that allows a Reader user to click and attach a resume file. Most attachments will probably be Word documents.
Using Acrobat Pro XI, is it possible to add that type of button to a form?
Copy link to clipboard
Copied
Here's a link to a sample document: Dropbox - importTest_20150411_1.pdf
It contains a single button that uses some JavaScript, most of which is contained in a document-level JavaScript. You'll have to study it a bit to figure out how it works. It relies on using the cAttachmentPath annotation property, which really acts like a method to prompt the user to attach a file. If Acrobat is used and it's prior to 11, the normal type of file attachment is used, but this won't work with Reader unless the document has file attachment usage rights applied by LiveCycle Reader Extensions, which I don't think you have.
It is currently set up to add the attachment icons (when used with Acrobat/Reader 11 or greater) below and to the left of the bottom left corner of the page, so they usually won't be visible as they would be when a user manually adds a file attachment as a comment (annotation). Any comment attachments that are added will appear in the Attachments pane.
Copy link to clipboard
Copied
It's only possible to do with a button if the users will have Reader 11 or the new DC, or you're able to Reader-enable the document with LiveCycle Reader Extensions. If it has to work with earlier versions, users will be able to manually attach files using the "Attach File" commenting tool. With Reader 11/DC, it will require some JavaScript to work with a button. Post again if you need help with the scripting.
Copy link to clipboard
Copied
George,
Thanks so much for your reply, and thanks for offering to help with the JavaScript -- I will need help with that.
I'll be using Acrobat XI Pro to create the form. I could possibly use Acrobat DC, but I don't know anything about that version.
Copy link to clipboard
Copied
It doesn't matter which version you use to create the form. Reader users will be able to attach files that are not in the blacklist, which includes ZIP and other file types (EXE, VBS, etc.) The JavaScript won't work on mobile devices, but then iOS normally doesn't allow much access to the file system anyway. Android allows greater access, but there are limitations with it as well.
I'll post something a bit later.
Copy link to clipboard
Copied
I have this piece of script (below). Would that work?
But I thought that Reader users, even with Acrobat XI, could only use it to insert a PDF. Has that changed?
event.target
buttonImportIcon();
Copy link to clipboard
Copied
No, that's just used to set a button icon, not attach a file that can later be extracted. I haven't checked Reader DC yet to see if it allows non-PDFs like images.
Copy link to clipboard
Copied
George,
I found a related web page that you contributed to
http://alltamedia.com/2014/06/09/how-to-add-attachments-to-a-pdf-form/
Ideally, I'd like users to be able to simply click a button to attach their file.
Have any improvements been made since that page was posted that would allow Reader XI users to attach a file?
Copy link to clipboard
Copied
Yes, there is a method that's available with Reader XI and DC that allows you to add a script to a button that will prompt the user to select a file to attach. Like the manual method, the file gets attached as a comment, but you can manipulate the placement of the icon so it doesn't appear on the page. It will appear in the attachments pane like a regular file attachment. I promise to post the code later today.
Copy link to clipboard
Copied
George, I truly appreciate your help on this and will look for your post later today.
Copy link to clipboard
Copied
Here's a link to a sample document: Dropbox - importTest_20150411_1.pdf
It contains a single button that uses some JavaScript, most of which is contained in a document-level JavaScript. You'll have to study it a bit to figure out how it works. It relies on using the cAttachmentPath annotation property, which really acts like a method to prompt the user to attach a file. If Acrobat is used and it's prior to 11, the normal type of file attachment is used, but this won't work with Reader unless the document has file attachment usage rights applied by LiveCycle Reader Extensions, which I don't think you have.
It is currently set up to add the attachment icons (when used with Acrobat/Reader 11 or greater) below and to the left of the bottom left corner of the page, so they usually won't be visible as they would be when a user manually adds a file attachment as a comment (annotation). Any comment attachments that are added will appear in the Attachments pane.
Copy link to clipboard
Copied
George,
Many thanks for sharing your file! This is great for Acobat XI or DC.
For the Reader X and earlier users, if the PDF is Reader Enabled in Acrobat (not LiveCycle Reader Extensions), would they be able to use the commenting tools to add file attachments?
Copy link to clipboard
Copied
Yes, they will be able to manually attach files like that article you linked to before discusses. For Reader versions prior to 11 to be able to manually attach file, the document will need to be Reader-enabled with Acrobat so that commenting is allowed.
Copy link to clipboard
Copied
I received the email below and am replying on this forum:
Hi
Did you manage to make attachment to work in your PDF form?
I tried to use the example but when I press the send button, Outlook only attached the form and not the attachments.
Button to allow user to attach a file
Can you please send me a working PDF form with button for attachments to: khanghy.huynh@gmail.com
Thank you!
The sample file that George Johnson provided works perfectly. The link in in the "Correct Answer" #10 message, and it sounds like you already found that file. The attachment kind of becomes part of the PDF; it is embedded in the PDF. When you send with Outlook, only the PDF will show as an attachment in the email. When the PDF is opened, as George explained, whoever receives the PDF can open the attachment by double-clicking it in the Attachments pane if they are using Acrobat XI or higher.
I hope this helps. If not, post again.
Copy link to clipboard
Copied
Hi George, I use Adobe Acrobat Pro, and the button doesn't work. Can you help me, please?
Copy link to clipboard
Copied
After you click the button, do you see any errors reported in the JavaScript console (Ctrl+J)?
Copy link to clipboard
Copied
Hi George, appears this message:
ReferenceError: import_11 is not defined
4:Field:Mouse Up
I don´t know I do wrong, thanks
Copy link to clipboard
Copied
If you just copied the button from the demo file into your own document, that's not sufficient. You also need to copy the JavaScript code that's in the document-level JavaScript of the demo and place it into a document-level JavaScript in your file. If you don't know how to do this, post again and include what version of Acrobat you're using.
Copy link to clipboard
Copied
HI George, I tried to copy and also i do it my seflf. I include the javaScrip. Ando also doesn't. If i'm do by the 2 forms in your pdf exemple works, but if i do in mine, doesn´t work, I use Adobe Acrobat XI version 11.0.0.
Thanks
Copy link to clipboard
Copied
Can you help me with another thing, please? It´s possible with a text field, when he reach the maximum size, add automatically a new page?
Thank you
Copy link to clipboard
Copied
Hi George,
I'm trying to use the button from your demo, but I'm not sure how to "copy the JavaScript code that's in the document-level JavaScript of the demo and place it into a document-level JavaScript" of my livecycle form. I'm using LiveCycle Designer E8 8.2. Would you be able to explain how to do this?
Thank you so much!!
Quentin
Copy link to clipboard
Copied
The code would have to be modified to work with an XFA form, and it can only work with static XFAs, not dynamic ones. You might want to ask in the LiveCycle Designer forum here for more guidance.
Copy link to clipboard
Copied
Thank you!!
Copy link to clipboard
Copied
Hello, I came across this thread after putting an "attachment" button into a PDF Form where we want people to attach drawings and documents to send back to us. I realize that any older versions of Reader doesn't allow this, and can use the comment workaround.
My original button was set up and worked in Acrobat Pro DC, but as soon as it was sent to anyone, it no longer did anything when you clicked it. Reader (11) seems to be the culprit, it just doesn't want to open the Add Attachment dialog at all.
I then tried adding the button you created above to see if it would be different than mine (the JS was different) and again worked in Pro DC, but not in Reader (11).
Is there a setting I need to enable or something else I need to add? I thought this would be a very simple addition to a PDF form, but am going crazy trying to make this work.
My Original button JS:
this.importDataObject("attachment");
Which opened the add attachment dialog in Pro DC, but nothing else.
Any help would be greatly appreciated.
Joel
Copy link to clipboard
Copied
The importDataObject document method won't work with Reader, so you have to use the techniques demonstrated in the sample document that I posted a link to earlier.
Copy link to clipboard
Copied
Actually I just tried that piece of code lower in this thread from Kellya and that seemed to have worked! I have no idea what the difference is from the code below, or the code in the original button example in this thread, but I am happy it works.
That original button PDF posted was not working for me - same outcome as my own button that I added.
Thanks!
Joel