Adding Attachments to PDF Form

Hi
Just finished helping a customer who wanted to add attachments to PDF using javascript. There are 2 ways to add attachments to a PDF form
1- using the attachments tab
2- Using javascript- with the help of a button the user selects the file to add to the pdf
I have included the PDF which allows the user to add attachment , view the attachment and deleted the selected attachment from the form.
Please click here to access the formPDF Form
PS- THIS WILL ONLY WORK WHEN YOU OPEN THE FORM WITH ACROBAT.IF YOU WANT IT TO WORK IN READER YOU WILL NEED TO APPLY USAGE RIGHTS USING THE READER EXTENSIONS ON THE SERVER

About these ads

174 responses to “Adding Attachments to PDF Form

  1. What when you distribute the form or put in on web page? It doesn’t work there.

    • Girish Bedekar

      Hi Aparna
      The end user will need to have acrobat or you will have to Apply Usage rights using READER EXTENSION on the server
      Also when you say it does not work – do you get any errors?
      thanks
      girish

  2. Nicholas Wright

    Hi, i’m trying to make an interactive pdf in acrobat pro 9. Firstly i want people using reader to be able to attach files. I like you pdf with attach boxes. Can you tell me the java script for programing the buttons etc. Will i then be able to activate this to work in reader or do i need to activate it in live cycle (probably trial version as i can’t afford it). Many thanks for your time and help,
    Nicholas

    • Girish Bedekar

      Hi Nicholas
      The javascript for the buttons can be seen when you open the form in livecycle designer.(Comes free with acrobat). To make the form fully functional for your end users who have reader, you will have to apply usage rights using livecycle server software.you can also try acrobat.com to see if there is any way to apply usage rights.
      Also if possible can you please explain me your usecase/problem you are trying to solve
      thanks
      girish

  3. Nicholas Wright

    Hi Girish, thanks for your very swift reply. I’m trying to create a pdf form for my work. We’re a small land surveying company and we want to create a relatively simple form for people to fill in with data for us to get back to them with a quote. It helps us if they include attachments of various information such as Google areal photos of the area, and land registry plans (indicating the boundaries of the land owned). Originally I was going to create a web page but the information is neater for us when enclosed in a pdf document. I’m using adobe cs design premium which comes with acrobat pro 9 (not extended) and i’m working on a mac. As far as i am aware there’s no live cycle designer bundled with it (possibly because it’s on a mac) but to be honest i’m completely new to acrobat and live designer so it could be staring me in the face!

  4. Nicholas Wright

    Hum, thought so, can’t understand why it doesn’t work on a mac when everything else does. Id di download a trial onto my pc so maybe i can use that to try and activate whatever it is i need to do to see if it works. Is the live cycle server software part of live cycle designer or is it something else. It’s all so confusing that adobe seem to have about 4 different programs and techniques to create much the same thing (or so it seems to the novice). Acrobat pro is seeming like a less and less powerful program by the day! Many thanks, Nicholas

    • Girish Bedekar

      Hi Nicholas
      Read your comment, I understand your point. Some clarfications
      Livecycle designer is an WYSIWG tool for designing interactive PDF forms.
      Adobe LiveCycle® ES (Enterprise Suite) software is an integrated server solution that blends data capture, information assurance, document output, process management, and content services to help you create and deliver rich and engaging applications that reduce paperwork, accelerate decision-making, and help ensure regulatory compliance
      More info can be found on this site

      http://www.adobe.com/products/livecycle/

      Reader Extensions is an integral part of LiveCycle ES.
      Let me know if I can be of any further help
      thanks
      girish

  5. Nicholas Wright

    HI Girish, thank you, you have been more than helpful. Just one more question (probably leading to another fifty!). I’ve opened adobe livecycle designer se (trial version on pc) to see if i can create the form. When i open your pdf’s with the attachment boxes it open and says if i save it all info will be lost but when i click on the various buttons to view the script there is nothing that i can see. The open file and delete file buttons seem to work (they open a box saying basicaly cannot do the action as there is no atachment already in your viewing box). The attach file button seems to do nothing though and when i look at the programming for the buttons it looks like thay are set to form calc and i just cannot for the life of me see where the script to program the buttons is. Please could you help me with a ‘for dummies’ step by step – however don’t worry if you’re too busy, i’m sure it’s a big ask. Many thanks again, Nicholas

    • Girish Bedekar

      Hi Nicholas
      That is strange, can you try to view the script editor from the window menu button
      let me know
      thanks
      girish

  6. Hi Girish,
    I am back with same prob. still on.
    Actually as test before putting it on web, I distributed the form then opened it in Acrobat 9, filled it, and wanted to attached CV and photo, but the buttons doesn’t open any browser to browse from. It doesn’t give any errors. You are talking about server meaning that I should buy externally or it’s inbuilt in LiveCycle designer? Again, while playing arround to make those buttons work I also went in Advance and try to extend features in reader, it showed me error that they already been assigned.
    So again back to where I was. Frankly, I not a programmer or much familiar with scripts so don’t know if I have make any changes in script before inserting the object in my form. Any help will be great, no hurry whenever you have time.
    Have a great day. Thanks so much for reply.
    Aparna

  7. Hi, very useful example but I wondering is there a possibility to add the content of attachment files to form’s xml ?

    • Girish Bedekar

      Hi tomson
      So you want the attachments contents somehow included in the form data when you export the form data as xml?
      I do not think that is possible
      thanks
      girish

  8. Hi

    I have tried to use the attachemnt with my form but after sending the form over the email
    attachement is lost ??
    how can I do it?

    • Girish Bedekar

      Hi Talibah
      Are you sending the pdf or just the xml data in your email. If sending xml data there will not be an attachments,make sure the submit button’s format is set to pdf

  9. Hi Girish, I’m in the same position as Aparna. I have a multi page pdf that was created in indesign cs4 to which I need to add the ability to insert a file. I opened your pdf and then my pdf in livecycle and tried to copy and paste the buttons, I get the same error as Aparna. When I import my pdf I suppose I need to select interactive form for the copy and paste to work?

  10. Hi Girish, thanks for the reply.
    I don’t think InDesign CS4 can do a xfa pdf so would it mean remaking the pdf in lifecycle or is there another method.

  11. Hi, this is exactly what I’ve been looking for. I too am unable to view the script in LiveCycle designer. Using Acrobat 8 Pro. Have tried everything but can’t view or edit any of the script in LiveCycle designer. Tried resaving the pdf, nothing works. Any suggestions? I can’t recreate the buttons in another document because I can’t view the script. Thanks!

    • Girish Bedekar

      Hi Mark
      when you open the form in livecycle designer you should be able to view the script from the view menu and the choose the script editor option. I am on my vaction in India , so I am not sure about the exact menu option, but the script editor option is available in the top level menus in livecycle designer
      thanks
      girish

  12. U are very good at this but i am not, after many tryouts i cannot make your scripts working in my form, i think it is because of different sort of form properties but i cannot understand how to change them to make this possibly work.
    You say iti ahs to be a XFA type document but in livecycle i don’t see this particular voice, can you help me?

  13. when u say “YOU WILL NEED TO APPLY USAGE RIGHTS USING THE READER EXTENSIONS ON THE SERVER” to which server u refer? and how? with acrobat or with livecycle?

  14. I see an error when i open your file in my server, it says: “cannot save a copy compiled of the form on the computer, if u want a copy compile it and print it” so what it is needed in order to make this to happen? i am sorry for my ignorance but i need this to work and u seem to be a very good person to ask to, if u cannot no problem, until u answer i will continue to googling for it. ;)

  15. Hi Girish, my problem is not solved, i tried everything and i discovered some interesting good things in livecycle and made some form for other purposes but the “quest for attachment to PDF form” is very not solved.

    I want only be able to do a file like yours that works with adobe reader giving possibility to upload attachments to a form and send it by email.

    Do u have some guide to do it?

    I tried with your file modifying it and trying to understand the code but nothing, is it too much difficult for me?

    I really hope u can help me.

  16. I cannot understand why i cannot make it working even in preview like your file does, i copy it in my file but only one part is copied, the form, the rest (referenced objects+counter+scriptobject) i am trying to learn about them but the help guide of livecycle is not greatly userfriendly, i made the scriptobject and copied the code inside so now i am trying to understand the other 2.

    Every advise about them is very appreciated.

  17. the version is 9 pro.

  18. I too think this is a great button and thank the author for providing it, as I had been looking for file attach in pdf. But after hours of trying to make it work in my own form I finally just redid my form in classic .asp and used cdo.sys for the file attachment. Works like a charm.

  19. Thank you very much for helping me to reach the truth about this fantastic application, the only thing that was blocking me to use your file was the variable to be added in the form properties.

    I owe u one and if i can i i would like to owe u more about another, for you will be very simple, function:

    auto sending form to email of administrator and to user after filling and submitting.

    Thanks again.

  20. Hi there!
    I’m having the same problem as Aparna. I added the buttons to my form, but when I click the button nothing happens. I assume you solved the problem via private e-mail conversation. Could you help me out too?
    Thanks a lot !
    (running LiveCycle Designer ES v 8)

    • When adding attachments to form you will need to use Acrobat , or you will need to Reader Extend the form. What are you using(Acrobat or Reader) to add attachments to the form. Also if you could send me the form to mergeandfuse@gmail.com
      thanks
      girish

  21. Hi Girish

    I tried this great script. Works fin alone – but included into an existing file not. In my file variables are allready defined. Could it be that your Variables interfere with the existing ones?

    Regards
    Hermann
    (using Adobe 8 Pro)

  22. Hi Girish

    Working with Adobe 8 I’ve just discovered that the list of attachments is empty when reopening the file after saving with attachments. I’ve no clue why.

    Regards
    Hermann
    (using Adobe 8 Pro)

    • Hi Herman
      Is your problem solved
      thanks
      girish

      • Hi Girish

        Unfortunately I didn’t find a solution by myself. Could it be that my versions (Adobe Acrobat 8 Pro and 7 Standard) make any trouble?

        Regards
        Hermann

      • Hi Girish

        Just to clarify: I doesn’t work with Adobe Acrobat 7 Standard. Attachments are there but will not show up in the List of Attachments. You may have an idea how to correct this. I didn’t succeed.

        Unfortunately some of the users of my form still work with this version of Adobe Acrobat.

        Regards
        Hermann

      • Girish Bedekar

        Hi Hermann
        So you have a pdf which has attachments, when this PDF is opened with Acrobat 7, the attachments do not show up? Is this correct
        I will be out of office till Wednesday, returning on Thursday. I do not have Acrobat 7 handy, but will get to it once I return on Thursday
        BTW are you in the US?
        thanks
        girish

      • Hi Girish

        You’ve got it right.
        I will be in this week and then be gone for two – desperately need holidays. And no, I’m not in the US -> European Mountains. What about an Indic name and India? ;¬)

        Regards
        Hermann

      • Hi Girish

        Back from holidays and full of energy I’m eager to get my form working. Did you may had a spare minute to look into the problem?

        Regards
        Hermann

  23. Hi Girish,
    I sent you my form but never heard back from you. Unfortunately it’s still not working.
    Thanks.

    • Hi
      I just sent you the form, sorry for the delay
      All you need to do is to add a variable called “counter” and set its value to 0. You can do this by opening the form in livecycle designer, and from the File | Form Properties
      select the variable tab and create a variable called counter and set its value to 0. Tip when using acrobat you can open the debugger window by hitting ctrl-j
      thanks
      girish

  24. Samantha are you opening your form in Reader or Acrobat ?

  25. Hi,

    Very useful script. Thanks a lot.

    I need something simpler, and appreciate your help.

    I want to write JavaScript for the “Click” event of a Button, to open the Attachments Tab only.

    Appreciate your help.

    Tarek.

  26. Hi Girish,

    I am currently looking for help with a form that I am developing with LiveCycle Designer 8.2.

    The form has an attachment (word document), which is opened and edited by the user, saved and closed. The attachment is needed because it gives advanced editing capabilities.

    1) My request/challenge is to be able to print the form together with the attachment with only one print button so the printed copy includes the attachment content as well.

    2) Or be able to transform the attachment into PDF and then merge it with the form so that we only have one PDF at then end.

    I want to achieve the above using JavaScript as we currently don’t have LiveCycle ES deployed.

    Thank you in advance for your assistance in this regard.

    • Hi
      I am sorry you cannot do that without opening the attachments and printing it one by one
      Livecycle ES can do all these very easily
      thanks
      girish

      • Thanks very much for your quick reply,

        Will it be possible to display the content of the attachment inside the form? The aim is to be able to have a kind of preview of the attached document inside the PDF form.

        Thanks

      • Girish Bedekar

        Hi Loralon
        I do not think that is possible at least for non PDF attachments. PDF attachments ma be possible, but I am not sure. Sorry could not be of any help here.
        girish

  27. Hello, I am having a bit a difficulty with viewing my attachments. It works great when I am in the form, but after I submit the form via email, the attachments are missing. Any ideas? Thanks!!!

  28. Hi Girish,

    This is a great sample, just right for what I’m looking for.
    Besides I want to create a pdf file by Livecycle which not only can be attached files but also can be exported to a database software (for instance, MS Access). Is there any way to manipulate the process so as to have the data and also the attachments in the database?

    Thanks a million,
    Lam

  29. Hi Girish,
    How can you see the preview of an adobe form inside the parent PDF. Is it possible to embed an attachment inside an interactive form designed in LiveCycle designer?

    Thanks,
    Mahantesh

    • I do not think you can do a preview, what do you mean by embedding? You can add attachments to form designed in LC
      girish

  30. How would I take what you’ve done and add it to an existing PDF that I have? I have Adobe Master Collection CS4, so I should have any program I need.

    Thanks,
    Bill

    • look for Adobe LiveCycle designer, It comes free with Acrobat. Loo for it in the same folder in which acrobat is installed
      let me know
      thanks
      girish

  31. David Sztarinka

    Hi all!
    Great post, and comments I admit! So the only way you can make a pdf to be able to attach files in the free Adobe Reader is Adobe Livecycle ES2.
    Am I right?!

    Thx David

    • Hi David
      Yes to be able to add attachments to a pdf using Reader is to Reader Extend the form using the Adobe Reader Extensions server software. The Adobe Reader Extensions is an integral part of Adobe Livecycle ES.
      let me know if you have any more comments
      girish

  32. Hello Grish,

    I have to say I wish I had as much knowledge as you when it comes to using Adobe products, I am still learning, so someday. Its great what you are doing to help others out.

    I have been reading your blog on Adding Attachments to PDF Form, the button works great with Acrobat, but with reading the blog it says you have to have Adobe Reader Extensions server software to make this work for those using reader. Is there some other way that this can be done without spending $10,000 for a button to get used?

    If you could help me in anyway that would be great, Thank You

    • Hi Todd
      I am sorry there is no other way for the end user to add attachments to the form without Reader Extending the form. You should consider getting a licence for Reader Extensions, I am sure it will pay off very quickly for your organization
      thanks
      girish

  33. Hi Girish,

    I want to only put the filenames in the drop-down list, not actually attach the files. I looked at your JavaScript but wasn’t sure what to change to just get the filenames.

    Any help much appreciated!


    Brian

  34. Hi Girish

    I am creating a scholarship application and would like to use the add attachment button.
    I have a portion that has a radio button next to Essay requirement, where the applicant must attach an essay. Can I link the “Attach Essay” button to the radio button so that when someone attaches their essay that the required radio button is checked. Also do I have to have the list attachments box and other, can I just have the attach button.

    • Hi
      You can just have the radio button to add the attachments
      But do remember only users using Acrobat will be able to attach files, unless you reader extend the form using ReaderExtesnions
      thanks
      girish

  35. Thanks for your quick reply. Could you tell me the actual line that causes the browse file window to pop up. I also copied all the boxes into my form then just set the ones I didnt want to show to hidden from layout. And in the pdf preview when I clicked on add attachments nothing happened. I am just starting to learn javascript and it seems a little overwhelming. Thanks for all your help.

  36. Hi Girish,

    I figured out my problem or at least I think I did. When I was view in pdf preview box the attachment buttons wouldnt work. I saw that when I copied them over into my form that the variables that where on your form did not copy over into my form. I added the variables and now they work. Was this the problem?

    • yes, you need to copy the variables
      glad to hear it is working
      thanks
      girish

      • Hi Girish,

        The form was working but then after Extending Features in Adobe Reader with Adobe Acrobat 9 Pro the radio buttons that I have used as the attach form button do not work. Help Please.

        Michael

  37. michellelovesbikes

    Hi Girish,

    I created a form in LiveCycle Designer 8.0, saved it as an Acrobat 8 (Dynamic) XML Form (*.pdf) and added your bits of code.

    When I open the form in my version of Adobe Acrobat Pro 8.0 the code works like a charm.

    Unfortunately, most of my end users don’t have Acrobat Standard or Pro, they just have reader, so I have to extend Reader rights.

    When I open the form in my Adobe Acrobat Pro 8.0, and go to:
    Advanced > Enable Usage Rights in Adobe Reader…

    your code doesn’t work. No dialog box appears to attach a file and consequently I can’t attach anything.

    Any ideas what’s breaking the code in Reader?

    Thanks for your help!
    MDO

    • Hi Michelle
      You would need to enable usage rights using the Reader Extensions server software, you cannot add the capability to add attachments in reader by enabling usage rights through acrobat
      thanks
      girish

  38. Hi Girish,

    I created a form with your script. It works fine except when I try to View Attachment, either in LiveCycle or in Adobe Pro (9.2) or Adobe Reader. If I’m testing the form in all three above, before submitting it, a window Opens with a 0 in it and the attachment opens.

    When I submit the form as a test and try to open the attachment I get a message that says -1 and the attachments don’t open.

    I don’t think I’ve done anything different from what you’ve recommended. I even have my counter set at 0.

    Thanks – this has been an immense help finding this for a form I need to create.

    Ady

  39. Hello Grish ,

    Still like the work you are doing keep it up.

    I already have the PDF made in LiveCycle ES 8, I extended the rights just through Acrobat Pro 9, no server. I attached a diffrent PDF to my original by using the attachement feature in Acrobat. Is there a way that I can make a button that will open the attached form, the original form will be used by about 100 or so people I would like to make this as simple as possible.

    Thak you for information you can provide.

  40. I want to attach the filled pdf form as an xml some times and pdf some times and send it across to recepients through some http url. Is it possible. In live cycle designer xml we are able to attach and is taking msoutlook ot send mail to the recepients.

  41. I’m having these same issue as one of your posters above was having. I was wondering if you could possibly help me out as well. Here’s the issue. I can’t view my attachments after its been submitted to a file server using a servlet(borrowed from an example of yours). It works great when I am in the form initially, but after I submit the form, the attachments are missing on the pdf on the file server . I sent you the pdf. Any help would greatly be appreciated.

  42. Hi,
    I have a requireemtn to add an attachment to a pdf document designed in life cyle designer 8.1 and using a reader 9. I came acros your blog, its great but some how I dont understand why “ADD Attachment ” is not working. I searched the net and found that I need some extended life cyclereader for this functionality. Is that so?

    • Girish Bedekar

      yes, to be able to add attachments to a pdf using reader you will need to apply usage rights to the document
      let me know if you have any more questions
      giirsh

  43. Girish,

    Thank you very much for posting a sample form, however I am having some trouble with it.

    After I downloaded it (Adobe Pro 9.1.3) attached a file, saved it, closed it, and then re-opened it, the file was no longer visible in the form, however the attachment still showed 1.

    Thanks for your help!

  44. Hi Girish,

    Your code works great on Acrobat 8. However, when I attach couple of files, save the document and reopen the same, I don’t see the document list in the text area. Is there a way you can provide code snippet for that?

    I tried including a button to list the attached object but not luck. Source and error message are below.

    Source:
    var d = this.dataObjects;
    if ( d == null )

    attachmentsList.addItem(“No file attachments”);
    else {
    attachmentsList.addItem(d[i].name);
    }

    Error: Object d is null – displays “No file attachments”

  45. Hello Girish,
    I have a few questions relating to attaching files as well.
    1. Can you save the file with the attachments so that when you open the file to edit, the attachments are still embedded?
    2. Also, if I use acrobat.com to distribute the my pdf file, will I be able to receive the attachments with the filled out pdf file?

    Please help!

    I am currently using the following code:

    form1.DocCkList.Table1.Row1.Button1::click – (JavaScript, client)

    var myDoc = event.target;
    var sFile = “myFile” + NumericField1.rawValue;
    myDoc.importDataObject({cName: sFile});
    var myDataObject = myDoc.getDataObject(sFile);

    var sFileName = myDataObject.path;

    ListBox1.addItem(sFileName,sFile);

    NumericField1.rawValue = NumericField1.rawValue + 1;

    THANK YOU!
    -cc

  46. Hello Grish,

    Using you attachment button I have some problems bring it over to the form I would like to use it in. It does not work once I take out of your form, I looked at the script and can not find any thing that not make it work.

    Second, what I am really trying to do is make it so when the person clicks on the submit button of the form, a pop up comes up and asks would you like to add an attachment, if they click “No” it goes to the email prompt, if “Yes” then they pick from a file on there PC and add it. But I would like to have it attached to there email not the form itself, is there a way that this could be done?

    Using LiveCycle 8.2
    Thank You
    Todd

    • check the Form | Properties | variables my form in the designer you will see that I use a variable , you will need to do the same

  47. Thank you Grish that worked, but I was wondering if you have an answer to my second part of my question?

  48. I’m having a similar problem to Ady from 2/25 & Nate from 6/4. When I copy your script to my form, I can add an attachement, but can only view it if I add a second attachment.

  49. I see how your example works [I think], but when I try to distribute the form through LiveCycle the Add Attachment button stops working. I also used the same logic, trying to apply it to my own form, with the script, the counter variable and the appropriate javascript code on the buttons, but it doesn’t work with my document. Is there something in the distribution process that destroys the functionality?

  50. UPDATE: I got the button to work in my form (had to position the script above the counter variable) using Acrobat Pro–so by extending rights to Reader it would work. But it still breaks when distributing the form. If I skip the distribution command and just send out the saved file (with Reader extensions) will that work? Will it also compile my responses, attachments included, into a responses file?

    • Hi
      If you want to distribute the form, just follow the steps in the wizard and it should work. Do not Reader Extend it, the wizard will do it for you
      let me know if you need any more help
      girish

  51. The form upload breaks when I try to extend rights to Adobe Reader…

  52. Great post, helped me a lot. I have a pdf that is striclty FormCalc, is there a way of implementing this solution using formCalc?

    • you probably could, but I am familiar with js You can have a combination of FormCalc and javascript in your form, there is no harm
      thanks
      girish

  53. Hi, I have used your code to create a PDF form in LC Designer and it works when the form is run in Acrobat. However, I cannot add any attachments in Acrobat if the form is a distributed PDF form. Is there any tip to solve this problem? Thank you.

    • Hi
      To be able to add attachments when the form is opened in Reader, you will need to Reader Extend that form using Adobe Reader Extensions Software. Let me know if you have any more questions
      Thanks
      girish

      • The question is if the form is distributed, I cannot add any attachment into PDF form even I open a distributed form in Acrobat Pro

  54. The problem is if the form is distributed, I cannot add any attachment into PDF form even I open a distributed form in Acrobat Professtional. So, what can I do if I want to add an attachment in a distributed form? Another question is can Adode Reader add the file name ONLY (not attachment) by using same method? Thank you very much.

    • Are you able to add attachments before the form is distributed? I am not clear when you add the file name only(not attachment). Can you send me your form, I will take a look and send it to you
      send the form to
      mergeandfuse@gmail.com

  55. Dear Girish Bedekar,

    I have sent you a mail, please kindly check. Thank you.

    • Hi
      The problem is this
      To be able to add attachments either the end user will have to use Acrobat or you will have to apply usage rights using the Adobe Reader Extensions Server Software. You cannot apply usage rights using the Acrobat client and distribute the form and expect end users to be able to add attachments to the form.(even if your end user is using acrobat, reason being when you apply usage rights using acrobat you do not get the permission to add file attchements).
      Let me know if this helps, or if you have any more questions let me know
      girish

  56. Thank you for your information. Does it mean that even if an user uses Acrobat, he / she cannot add an attachment in a distributed form?

    • if you apply usage rights using Acrobat and distribute the form then yes the end user will NOT be able to add attachments. If you distribute the form without applying usage rights the end user WILL be able to add attachments
      thanks. You should consider investing in Adobe Reader Extensions Software – it will solve your problem
      girish

  57. Thank you for your reply. Sorry I have found there is another problem in this example. If I add an attachment into a PDF form, the list box will show the attachment name. When I click save button and close it, the file size will become larger (e.g. 121 KB to 500KB). After that I reopen the PDF form, I find that the list box is empty but the file size is still 500KB. How can I retrieve back my attachment when I reopen the PDF form? Thank you very much.

  58. Thank you for your reply. Sorry I found there is another problem in this example. If I add an attachment into a PDF form, the list box will show the attachment name. When I click save button and close it, the file size will become larger (e.g. 121 KB to 500KB). After that I reopen the PDF form, I find that the list box is empty but the file size is still 500KB. How can I retrieve back my attachment when I reopen the PDF form? Thank you very much. (I am using Acrobat Pro)

  59. Hi
    When you say the size of the pdf increases, are you referring to the size of the pdf to which you are adding attachments? If so that is the correct behavior as you are adding attachments to the file. I tried to save your form but it needs all the form fields to be filled before I can save that form.When you open the form, do you see the attachments in the attachment tab of the pdf? If yes then you may need to write some code to populate the list with the filenames in the document ready event of the form

  60. Thank you for your reply. Yes, I am referring to the size of the pdf which I am adding attachments. In fact, I found this problem in your sample PDF (not my PDF) I used your example to add some attachments. There are some attachmets in attachment tab. The n I saved the PDF form and closed it. The problem is when I REOPEN the saved PDF form, all the attachments are lost in attachment tab but the file size still 500KB. So, ido you mean that I have to handle this thing by writing script in ready state??

    • yes, the sample form does not have the script to populate the list when you close and open the form. Maybe I can send it to you in a day or two
      thanks
      girish

  61. Thank you very much indeed as I am very new in LiveCycle.

  62. Sorry to interrupt you again. I have tried to write a script to handle this problem but still the attachment list is empty after I reopen the file. I would like to know if there is any way to solve this problem. Thank you.

  63. Dear Girish,

    I have two questions. First of all could you please send me the updated form with the populated list as well?

    Also I could not find a solution for the following problem:

    Lets say you add 3 attachments, A, B and C. When you delete B you only have A and C in the list but you cannot open C because (I guess) the new index 1 is linked to a deleted attachment?

  64. Hi Girish,

    I also want to make a form either in Acrobat or in lifecycle in which users can add a attachment.

    Please guide me how I can do that…….

    If any user know anything related to this subject or have done something similar please share your PDF so that I can review it.

    You can send me the file at: susan_etli@yahoo.com

    Many Thanks

  65. Forgot to write I want this form to be reader enabled.

  66. Hi Girish,

    How do I ensure that the attachments and the listing thereof is available after submission of the form. The listing disappears if i submit or save the form hence rendering the attachment unavailable. Please send me the script to be able to view the attachments after submission or save. Also advise in which event i should put the script.

    Thanks

  67. Hi Girish,

    I know that this is a dated thread but are you still following it and giving assistance? Your form works so, I have copied your form and code into mine and all the code appears there but it does not work when clicking the add attachment button. I can send you a copy of the form if you’d like.
    On your form –
    When trying to view (obviously, nothing in the list) I get a scripting error – I think that is normal but wanted to check. Also, if you remove a document, the count does not change.

    Thanks again for all the assistance!!

  68. Dear Girish,

    I truly appreciate your blog about adding attachments in PDF.I have been reading and looking for solutions like crazy but for no avail.
    I have designed a form using Adobe LiveCycle Designer ES version 8.2.
    My requirements are as follows
    1) After filling the form, the user needs to attach some documents (PDF and word formats).I checked your form and tried to add documents, I can browse and attach the docs but I don’t see them after I save nor after I have submitted the form (submit as a PDF).
    2) Is there any way a user can fill a form and submit the form both in PDF as well as XML format?(in my case both are required)
    Please kindly assist me
    Thanks,

  69. Girish,

    Great stuff here. Right now I am using an email submission button which will attach the actual pdf form (instead of xml data) to the email. I am wondering if it is possible to work this script so that the attachments will attach to the email as well? When I tried to do this, the pdf form attached and then upon opening the pdf, it no longer had any attached files.

    I don’t have the first clue as to how to do this.

    Thanks!

    • To be able to attach the PDF to the email, you will need to ReaderExtend the form
      My blog has a entry on this
      thanks
      girish

    • I do’nt think so
      The attachments are inside the pdf. To be able to do what you want, you will have to use our Server Product

  70. Girish,
    I’m loving this functionality in my Adobe form, but was wondering if it still works when a digital signature has been used to sign the form. The following message appears on the screen when trying to open an attachment after the form has been signed. “At least one signature requires validating. Please fill out the following form author, choose distribute Form in the Forms menu to send it to your recipients.” Once the signature has been validated it still does not allow the attachment to be opened.

  71. Thank you for this form… I am having a little difficulties with it though…

    I incorporated the buttons/list into an existing form of mine. It works fine when I open the file in LiveCycle, as well as when I open it with Acrobat. When I save the file with additional features for Reader, it stops working, even when opening in Acrobat on that same computer…

    Any ideas?

    • Hi
      to be able to add attachments using reader you will have extend rights using Reader Extensions software to which is not free.
      the enable rights options from the acrobat menu will not allow you to add attachments to the pdf using reader
      thanks
      girish

  72. Hello,

    I’m wondering if you can help me with this issue I’m having with Reader Extension:
    After “extending” a form, it asks me to download and save the extended form, however I’m getting a popup application alert saying, “The file could not be saved. Are you sure you want to lose your results?” This wasn’t happening before, but all of sudden I’m getting this error.

    If you could give me an ideas as to why this is happening, I’d appreciate it!

    Thanks in advance!
    Ken

  73. Love the script, thanks for providing it. One question – After I attach documents then save and close, when I reopen the view and remove buttons don’t work. The attachment is accessible if I open up the attachments view, but the buttons are not working. I probably just need to add in a refresh to the script, but not sure about it. Can you point me in the right direction? Thanks a bunch!!

  74. Hello!
    I believe I have followed your instructions, but I am still having the same problem that Aparna, Nick Dring, and Samantha have described. I have designed a form in livecycle designer and added the attachment button with the script that was included in your example. But when I click on the buttons in the preview, or in Acrobat, there is no response. I have not been able to make the buttons in your example PDF work either. I am new to Livecycle, so perhaps I am missing something. Should I be changing anything in the script?

  75. Hi Girish,
    Thank you, I would appreciate that very much! I have sent you my email again.
    Kasia

  76. Hi Girish,
    An alternate email (because others have said that my email bounces back) is mcmah086@umn.edu.
    Thank you!
    Kasia

  77. Hi Girish,
    I am trying to place the scripts into my form, but the only button that works is the “View Selected Attachment” button (at least I think it works, it pops up with -1).
    I am also unable to attach anything to your form at the top of this page using Acrobat and Reader X. What am I missing? Nothing works in preview or when I distribute.
    Thanks,
    Ryan

  78. I have built a form that is designed so users fill it out, save it to their directories (usually an F drive) , and manually attach the saved file to an email. Security and usage rights constraints don’t permit a “submit by email” button even though it is possible. The form is “Reader-enabled” in Acrobat. Two questions: If users have to submit my form manually as an attachment anyway, wouldn’t it be easier to tell them to add their other attachments (charts, diagrams) to the same email? Also, how can we purchase the LiveCycle software that extends usage rights to Reader?

  79. It’s not that we can’t set the form up on a server. The people in charge of that don’t feel this form warrants it, so it has to remain a local file.

  80. Hello Girish
    I am new to Livecycle.
    I created a form , copy pasted your buttons in my form …… I open the form in Acrobat and the buttons wont work.
    I made a form on the same file you have attached. The buttons work in acrobat but even after adding reader exetension rights through Acrobat the buttons wont work on Reader.
    I have also emailed you the form.
    Please help me out.
    Thank you !
    Need help desperately :S

    • To be able to add attachments to a PDF using reader you will HAVE TO USE READER EXTENSIONS SOFTWARE TO APPLY RIGHTS TO THE DOCUMENT. APPLYING RIGHTS USING ACROBAT WILL NOT WORK
      thanks
      girish

  81. Hi Girish,
    Thank you for putting this blog together, I’ve found it invaluable!
    I’ve just tried to use a trial version of LiveCycle ES 2.5 as this solution is perfect for what I need to do with a form in my office – however it hasn’t really configured properly so I’m looking at getting access to LiveCycle Express.
    I was just wondering though, when Usage Rights are extended in a PDF, will they remain embedded in the PDF for all users of the form, as they do if you were to apply reader extensions through Adobe Professional?
    Thanks in advance for your help!
    Kind regards, Lisa

    • Hi
      Congratulations on a wise choice. There are two ways to apply reader extensions – one through Acrobat and one by using the Reader Extensions server software. In both the cases the rights will remain embedded in the document for all the users .
      Let me know if you have any more questions will be glad to help
      thanks
      girish

  82. Hi
    How Adding Attachments to PDF Form and How to achieve this.
    If u have any sample source code, pleshare .
    Can u please help me..

    • Girish Bedekar

      The blog entry has a link to the sample code. BTW you need to have some experience in javascript programming, without which it will be hard for you to accomplish your gooal
      thanks
      girish

  83. Hi Girish,
    So I’ve created a fillable form using Adobe Pro X but the thing is, I’m working on a mac. Is it correct to say that I can’t get the Adobe Reader Extensions at all because of this? I would like the “Add Attachment” function on my form. Please help.

  84. Can you supply the javascript that you used to create this document? The PDF is secured.

  85. Hi Girish,

    I’m a teacher and trying to create a form that would allow my students to input their information and a photo. I’m wondering if there is any way the students can attach a photo of themselves to my form and then email it back to me. Thoughts?

    • Girish Bedekar

      hi
      Sorry for the late reply
      Yes your students can attach a photo and send the form to you provided you have either of the following 2
      1- Your students use the Acrobat(Not the free Reader) to attach photo to the form
      2- Your school/institution needs to buy Reader Extensions Software from Adobe which will allow your students to attach photo to the form using the Free Reader.
      Taking the second option is the best- provided you have the necessary budget to do it
      Let me know if you have anymore questions
      Thanks
      Girish

  86. Hi Girish,

    This is a great post and I really like your unique design of attachment functionality in pdf form. It works fine with me except two issues:

    1. When I click the attachment button it opens the dialog box, if I decide to cancel rather than selecting a file to attach, it throws an exception
    TypeError: Invalid argument type.

    2. It only keeps the latest attachment. If I reopen the saved file with some attached file and attached a new file, reopening next time will show only the latest attachment.

    Is there any solution and update on your code for these issues? I would appreciate it if you could email me the latest update to fix these bogs.

    Many thanks

    Roya

  87. Hi

    I am attempting to create a PDF form which when completed and returned will contain multiple attachments. The attachments would in ideally be placed within separate sections of the form

    Problem 1: Printing the file does not automatically print the attachments (without opening each one). Do you know of a way of auto batch printing the form and the attachments?

    Problem 2: Rather than having to sort through a jumble of attachments at the end of the file is there a way of retaining the order that they are attached within the document? So all section 1 attachments can be found in a section 1 appendix at the end (I would obviously have covers in place for each appendix)

    Your help would be greatly appreciated,

    Thanks,

    Warren

    • Girish Bedekar

      Printing of attachments automatically can be done using LC ES. LC ES is enterprise software offering from adobe which offers you document creation/management capabilities. Suggest you take a look at Adobe. I am not sure if you can print the attachments without opening them by using Acrobat

      https://www.adobe.com/products/livecycle/

      Thanks
      girish

      • Thanks Girish, will have a look at the software. I had suspected Lifecycle ES might be the key however for the likes of myself, reading through the adobe website is as clear as mud unless you are familiar with the jargon.

        Thanks again,

        Warren

  88. Hi Girish, I wonder if you can help me please? I am building a form in LiveCyle Designer and need to build the capacity to attach two documents to the form. I downloaded your sample but I cannot seem to see the code that makes it work. I’ve opened the Script Editor and all I can see is Show: initialize – Language: FormCalc Run At: Client. I am sorry, I am very new to LC Designer – I just can’t figure this out, where to see what makes the buttons work….
    Thank you so much!!!!
    Carin

  89. Your document has some problem.
    1. After deleting a file, its not updating counting value
    2. It always show 1 attachment in the list box, while there may be more than one attachments.

  90. Pingback: Adding Attachments to PDF Form | arifulalamtuhin

  91. Here was my solution. The hard part was removing an attachment from the middle of the list. I didn’t need to keep track of the number of attachments so that is not included.
    Need to add a button to attach receipts. The button should accept most document types: Word, Excel, img, jpg,…
    A subform was created and a list box created to hold the filenames for attachments. Three “normal” buttons are also added to the subform: Add Receipt, Remove Receipt, View Receipt. The layout is as below.

    Javascript was added to each button click event to manage the contents of the list box and attachments. The attachments are added to the document as a DataObject. A set of methods on the DataObject are relevant to this feature:
    1. importDataObject(“filename”); – adds a file as an attachment to the form. Launches a file picker for the user to navigate and select a file to attach
    2. getDataObjectcontents(“filename”); – retrieves the contents of the named file as a binary object.
    3. setDataObjectContents(“filename”, contentVar); – overwrites the named file with the contents of the variable specified in the second parameter
    4. removeDataObject(“filename”);- removes the specified attachment
    5. exportDataObject({cName:”filename”,nLaunch:2}); – launches the application associated with the filename for display to the user
    The ADD button is simple. Uses the length of the listBox array as the filename in which to stuff the selected file.

    topmostSubform.Page1.subformReceipts.addReceipt::click – (JavaScript, client)

    var oThisDoc = event.target;
    var oFileAttachments = oThisDoc.dataObjects;
    if(listAttachedReceipts.length > 0) {
    oThisDoc.importDataObject(oFileAttachments.length); //add the new receipt
    var oNewReceipt = oThisDoc.getDataObject(oFileAttachments.length); //get the receipt you just added
    listAttachedReceipts.addItem(oNewReceipt.path); //use the file name as the list object name
    } else {
    oThisDoc.importDataObject(0);
    var oNewReceipt = oThisDoc.getDataObject(0);
    listAttachedReceipts.addItem(oNewReceipt.path);
    };

    The REMOVE button is a challenge. It ensures something is selected in the listBox. It then overwrites the contents of the selected attachment with the contents of the next file in the list. It recursively does this until it reaches the end of the listbox. Finally, it removes the last element from the listBox since that element has been copied and is no longer needed. Otherwise, the last attachment would print twice in a print action and it would also take up space in the document.

    topmostSubform.Page1.subformReceipts.removeReceipt::click – (JavaScript, client)
    if(listAttachedReceipts.selectedIndex != -1){
    var oThisDoc = event.target;
    app.alert(listAttachedReceipts.selectedIndex + “:” + listAttachedReceipts.length);

    listAttachedReceipts.deleteItem(listAttachedReceipts.selectedIndex); //remove it from the list
    //bubble the attachments up to close the gap if an attachment is removed from the middle of the list
    for(i=listAttachedReceipts.selectedIndex; i<listAttachedReceipts.length-2;i++){
    var tempAttachment = oThisDoc.getDataObjectContents(i+1); //Get the next attachment contents as a dataStream (binary)
    oThisDoc.setDataObjectContents(i,tempAttachment); //overwrite this attachment
    }
    oThisDoc.removeDataObject(listAttachedReceipts.length-1);
    } else {
    app.alert("Please select an attachment.");
    };

    The VIEW button is also simple. Uses the length of the listBox selectedIndex value as the filename to open in its associated application.

    topmostSubform.Page1.subformReceipts.viewReceipt::click – (JavaScript, client)
    if(listAttachedReceipts.selectedIndex != -1){
    var oThisDoc = event.target;
    var sAttachedObjName = listAttachedReceipts.selectedIndex;
    oThisDoc.exportDataObject({cName:sAttachedObjName, nLaunch:2});
    } else {
    app.alert("Please select an attachment to view.");
    };

  92. Sorry, had a typo. The View button uses the listBox.selectedIndex value as the file name.

    • Hi David. When I flatten my PDF, the listbox holding the names of the attached files is cleared, any suggestions?

      • Girish Bedekar

        Hi Laurie
        Can yo please send me your form?
        I can take a look and get back to you
        thanks
        Girish
        mergeandfuse@gmail.com

      • The attachments are kept is an object called a dataObject. The acro.js can describe it to you. Before you flatten the PDF, you can use one of the available PDF inspection tools to see the objects and their attributes. In my code I refer to the .path attribute and the object itself. This works in the “non-flattened” pdf because all the objects are there in the PDF document. I suspect that when you “flatten” the PDF, the renderer strips off all the elements of the document that won’t be part of the rendered document because it thinks the un-renderable components are needed.
        I think what I would do is create some sort of fixed size text object, fill it with the filename list and make it an immutable part of the document before you flatten it. The document I had put everything in a list object which is probably not available to the flattened PDF. Maybe you could put a hidden textField in the same area as the listBox. Before you flatten, copy the elements in the listBox into the textField making sure you retain the list appearance of the listBox. Then hide the listBox and make the textField visible. You would have to be sure that the textField was large enough to hold the entire list (put a max number of entries on the listBox). If your listBox needed to hold more entries, maybe you could set the font on the textField smaller if the number of entries grows beyond the textField area. At least, this is what I would try.

        I tried to do things with the dataObject to flatten it. I wanted to have a “Print All” button but I didn’t have a chance to get it working. It’s a similar problem in that I have to print all the dataObject elements before actually sending the PDF to the printer. Here you have to collect all the filenames and put them into something that will not be thrown away by the renderer.

        HOpe this helps,

        Regards, Dave.

  93. Has anybody figured out how to use the Add Attachment button when a pdf has been digitally signed, as once a pdf has been signed it locks the Add Attachment Button, you can still use the View and Delete Buttons.

  94. Girish, I have tried using this form and have extended the features for Reader, but everytime I do this it breaks and the Add Attachments button stops working. Is there something I’m not doing right? I’m using LiveCycle for creating, Acrobat 9.0 to Extend and then trying to use the features in regular Reader…help??

    • Girish Bedekar

      hi
      can you send me the form please? my email is mergeandfuse@gmail.com
      also the ability to add attachments when you extend the features for Reader using Acrobat is not going to work. You need to use Livecycle Reader Extensions Software
      let me know if you need any help
      girish

  95. Hey guys, could you help me out here?
    My for is used in Workspace, so I need to recover the attachments added into the form in my process.
    How can I do that?

    Thanks in advance!

    • Just correcting:
      Hey guys, could you help me out here?
      My FORM is used in Workspace, so I need to recover the attachments added to the form in my process.
      How can I do that?

      Thanks in advance!

  96. Hi GB, How do I make this work if the form is ‘created’ in Acrobat X (not LiveCycle)??
    :)

  97. Hi GB, How do I make this work if the form is ‘created’ in Acrobat X (not LiveCycle)?? :)

  98. Hi Girish, your file is working good. but i need to insert your file to another pdf. while i insert i got a error message “You cannot insert pages from an Adobe XML form in to another PDF file”. Please let me know is there any chance i can get your file in my pdf.

  99. Hi
    I am so sorry if you have already answered this question, but I have a hard time figuring out if it is the same deal!
    You are my last hope…
    My task is to make a form with flowable fields – that our supplier can fill in, attach a file and submit the form (with attachments) to a specified email-adress.
    I have made a (dynamic) form in LiveCycle designer ES2, I use Adobe X Pro to save the document as a reader extended PDF -> Enable additional Features.
    When I open the form in Adobe reader, two of the buttons has been deactivated. I can still use the one for print and the one for reset, but submit form and attach file buttons do not work any more.
    I have tried to make a work around, by using distribution instead of submit – but the most important function I need is attach a file (and I can’t find any work around for that).

    Could you please help me, and let me know if it in any way is possible with that function in reader (I will be okay with activating the paper clip via command – but I have not been able to figure that out).

    In advance many thanks and have a nice weekend
    Br
    Maria

    • Hi
      To be able to attach attachments to PDF forms using Reader, YOU WILL NEED TO APPLY READER EXTENSIONS. Applying usage rights using Acrobat WILL not enable you to add attachments in Reader. Yo must use Reader Extensions Server software to enable the ability to add attachments using Reader
      The Reader Extension Server Software is NOT FREE needs to be purchased
      Let me know if you have any more questions
      Thanks
      Girish

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s