25 Replies Latest reply on May 30, 2008 5:11 PM by (Pam_Barnet)

    How to Supply the form field values to a pdf form when loading it

    Level 1
      I am working on a web site project using Asp.net where the user has to fill in a PDF eform in acrobat reader. Then when he clicks on submit it returns to my asp.net app and the PDF form supplies the values back to my asp.net app. So my asp.net app has the values that were filled in the PDF form and can save those values and work with them...

      OK.

      What I need to know is when I am in my asp.net app, and the user wants to go back and reopen the same form, from my asp.net app..... then how do I pass back the values that were saved back to the PDF form??

      I know if I had a way to pass the values to the PDF form in some way then in the Doc.open or doc.load event of the form I could easily write a little javascript to plug in the values in the PDF form fields.

      but how do I pass those values from my asp.net app to my PDF form???

      thanks
        • 1. Re: How to Supply the form field values to a pdf form when loading it
          (Aandi_Inston) Level 1
          If this is an Acrobat form (not a Designer form), you can submit in
          FDF or XFDF format and preserve this file, then serve the FDF or XFDF
          back to the user. These data files contain form field values and the
          URL of the form to load and fill.

          Aandi Inston
          • 2. Re: How to Supply the form field values to a pdf form when loading it
            Level 1
            Thank you very much for this information. Although that puts a new twist to things. Before I was submiting the data in HTML and that made it sinple to receive that data in my asp.net app. Now I have to find out all about the FDF or XFDF format and how pass this from one side to the other, catch the data and then pass it back again to the Acrobat form (It is Acrobat and not Designer) and also learn how to catch and parse the data at that end

            Any idea where to start reading or looking on this?
            • 3. Re: How to Supply the form field values to a pdf form when loading it
              Patrick Leckey Level 3
              FDF Toolkit: http://www.adobe.com/devnet/acrobat/fdftoolkit.html
              • 4. Re: How to Supply the form field values to a pdf form when loading it
                (Aandi_Inston) Level 1
                You can still have the submission in HTML, because there is enough
                information in there to build an XFDF or FDF. At this stage, I'd
                recommend the XFDF route as this is an XML file, probably easier to
                make given the FDF Toolkit seems unavailable.

                Aandi Inston
                • 5. Re: How to Supply the form field values to a pdf form when loading it
                  Patrick Leckey Level 3
                  Unavailable?

                  I just downloaded it from the link at the bottom of the page. He said he's using ASP.NET and there is an ActiveX Component included in the FDF Toolkit.
                  • 6. Re: How to Supply the form field values to a pdf form when loading it
                    Level 1
                    Thank you guys. You have given me lots to go by. but feel free anyone to add any comments to this thread, still.

                    BTW I also just downloaded the toolkit from the link
                    • 7. Re: How to Supply the form field values to a pdf form when loading it
                      Level 1
                      PDL....

                      Is there anywhere I can find support or any forums about the Toolkit? specialy the ActiveX toolkit.

                      Case I am getting an error every time I try to pass a FDF back to a form or to the client in this case.

                      When I use the same code as in the examples it seem to work all fine to pass the values as FDF and my asp.net app catches everything... its beautiful. But when I do the reverse; load up the field values and send them back to the client and still using the sample provided with the tool kit, then it seem to go all the way as trying to open up Acrobat reader but I get a acrobat reader "file IO problem"....

                      Why?

                      where can I find an answer would you say?

                      thanks
                      • 8. Re: How to Supply the form field values to a pdf form when loading it
                        Level 1
                        "A file IO Error has occured" is what it says precisely
                        • 9. Re: How to Supply the form field values to a pdf form when loading it
                          Patrick Leckey Level 3
                          Can you post the contents of the FDF it outputs? Is the PDF it's referencing already created or is it a stream?
                          • 10. Re: How to Supply the form field values to a pdf form when loading it
                            Level 1
                            OK the PDF is already created and is in the root of my application. The FDF I am trying to work with is in the stream. Not a hard writen FDF.

                            However when I do Hard write the value to a FDF file, then when I reference and anchor to it "<a heref="test.fdf">PDF<a/>" then it all works just fine. Perfect.

                            So like I sais those are just etsts that I am doing to see all it all works.

                            So, this is the code for it to write the values to a FDF file. And this works fine:

                            Dim FdfAcX As FDFACXLib.FdfApp
                            FdfAcX = New FDFACXLib.FdfApp
                            Dim FDFin As FDFACXLib.FdfDoc = FdfAcX.FDFCreate()

                            FDFin.FDFSetValue("Text3", "December", False)

                            FDFin.FDFSetFile("http://localhost:2370/test%20acrobat%20garb/Untitled.pdf")
                            Response.ContentType = "text/html"

                            FDFin.FDFSaveToFile("D:\bills system\bills documents\Visual Studio 2005\WebSites\test acrobat garb\test.fdf")
                            ' Now put a link to the file on your page.
                            Response.Write("<a href=test.fdf>pdf</A>")
                            '
                            ' Close your Objects
                            '
                            FDFin.FDFClose()
                            FdfAcX = Nothing

                            Like I said this works fine. It puts a link on the page and when you click it it loads up the form with its proper value all loaded up.

                            THE PROBLEM is when I try to do this from the buffer instead of a file.
                            So I put those 2 lines instead of all the other lines. And thats when I get the error "File IO error occurd" in a little Acrobat message box that lingers on screen after I click OK. Parts of that error message window box stays on screen and is hard to get rid of.

                            Anyways those are the liones:
                            I put this:
                            Response.ContentType = "application/vnd.fdf"
                            Response.BinaryWrite(outputFDF.FDFSaveToBuf)

                            Intead of this:

                            Response.ContentType = "text/html"

                            FDFin.FDFSaveToFile("D:\bills system\bills documents\Visual Studio 2005\WebSites\test acrobat garb\test.fdf")
                            ' Now put a link to the file on your page.
                            Response.Write("<a href=test.fdf>pdf</A>")
                            • 11. Re: How to Supply the form field values to a pdf form when loading it
                              Level 1
                              And last night I thought it was a conflict between the acrobat Reader and the PRO I have installed or that my systen was cracking up, so this morning I reformated all and reinstalled all from fresh. So my system only has XP, Visual studio, Acrobat reader and the tool kit installed.

                              And still same mistake..

                              ???
                              • 12. Re: How to Supply the form field values to a pdf form when loading it
                                Patrick Leckey Level 3
                                Hmm... that certainly is odd. Currently I generating the FDF in my application from scratch since I'm limited to a PHP-based web server for that project, but it is streaming the FDF not saving it to file so the idea is the same. I have used the FDF Toolkit with the ActiveX component before, but not in some time now.

                                Can you post your full output source? Have you tried Response.Write(FDFSaveToStr) instead? Do an FDFSaveToFile and post the output FDF too just to make sure it's outputting a properly formatted FDF.
                                • 13. Re: How to Supply the form field values to a pdf form when loading it
                                  Level 1
                                  OK so check it out.

                                  its all there:

                                  http://bcweed.mine.nu/PDFTest/

                                  check out all the otions. You will see that there is no problem it seems to capture a FDF from a form, also there is no problem writing that captured FDF to file on disj and reserving it to the client. Also there is no problem in filling a value in a field on the asp.net form and from there generate a dynamic FDF, write it to disk and then serve it.

                                  THE PROBLEM is generating a dynamic FDF in memory and passing it to the the client directly.... thats were my greatest lack of knowledge lies by the way
                                  • 14. Re: How to Supply the form field values to a pdf form when loading it
                                    I have similar project. I am taking data from OLEDB, through ASP.net, and filling it into an already made pdf. My ASP.net code gets the data fine, and the pdf opens, but the fields stay empty.

                                    I copied the code from an old project that worked. The trouble is with the pdf form, I think it has some accessibility settings that don't allow access to write, but I changed the security settings to allow everthing and still same problem.

                                    Any idea how I could change the settings in LiveCycle, or if there is another way to fix this?
                                    • 15. Re: How to Supply the form field values to a pdf form when loading it
                                      (Aandi_Inston) Level 1
                                      >I have similar project. I am taking data from OLEDB, through ASP.net, and filling it into an already made pdf.

                                      Not entirely clear of your workflow. Do you mean that ASP.net running
                                      Acrobat? If not, how is the ASP.net application filling the PDF - what
                                      product or method is used?

                                      Aandi Inston
                                      • 16. Re: How to Supply the form field values to a pdf form when loading it
                                        Level 1
                                        Wow! Thank you for the quick reply!

                                        My webpage is pulling data using sql and feeding it to the pdf using:

                                        Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")
                                        Set outputFDF = FdfAcX.FDFCreate
                                        outputFDF.FDFSetValue "VendorID",VendorID,False ...etc.

                                        Problem comes when I try to use a new output file:

                                        outputFDF.FDFSetFile "../InvoiceAuthorization.pdf"

                                        It will open but,the designated fields will remain blank. I set the object binding name same as it was in the previous document, and default binding is set to normal. I even trying copying the individual fields and pasting them in the new doc to no avail.

                                        Thanks again for responding so quickly...
                                        • 17. Re: How to Supply the form field values to a pdf form when loading it
                                          Level 1
                                          Ok thnaks everybody for picking this feed up. I have worked with the ActiveX FDF tool kit and it works fine. The only problem I have had is to pass values to the PDF form direct to the buffer (without creating a FDF file). Then I get the error "I/O error". Always, always, always...

                                          You can see that by going to
                                          http://bcweed.mine.nu/pdftest
                                          where i have put a little sample web site to demonstrate the problem I am having with all this.

                                          Also you can find the other link by searching "Problems with the FDF toolkit activeX" in this forum.

                                          For those who are having trouble pasing values back to the PDF from an FDF file... I suggest you make sure you are working with a valid FDF file. To do this I found the easiest way was to submit the form data to my asp.net app as an FDF file format and thyen let my asp.net app create and write the file to disk for me. Then it is just a matter of feeding that same FDF file to the same form and all should go well

                                          Anything else I suggest you check the field names and also make sure the path to the PDF document is correct as it should be a URL to the PDF doc itself.
                                          • 18. Re: How to Supply the form field values to a pdf form when loading it
                                            Level 1
                                            Also Ed, like I said earlier the path to the PDF document must be a URL to it I think... not sure but in my case i set it like this:

                                            FDFin.FDFSetFile("http://bcweed.mine.nu/pdftest/Untitled.pdf")

                                            and it works for me
                                            • 19. Re: How to Supply the form field values to a pdf form when loading it
                                              Level 1
                                              and like I said earlier also for me the only problem (and I sure would like to solve it!!) is when using the buffer method of passing the FDF values direct to the PDF document without creating a file.
                                              thats this method here:

                                              Response.ContentType = "application/vnd.fdf"
                                              Response.BinaryWrite(FDFin.FDFSaveToBuf)

                                              the other methods of passing it a FDF file work fine. those are those methods here:

                                              FDFin.FDFSaveToFile("F:\PDFTest\Test.fdf")
                                              Response.Redirect("~/test.fdf")

                                              and

                                              Response.ContentType = "application/vnd.fdf"
                                              Response.Write(FDFin.FDFSaveToStr)

                                              you can see it all at :

                                              http://bcweed.mine.nu/PDFTest/
                                              • 20. Re: How to Supply the form field values to a pdf form when loading it
                                                Level 1
                                                Thanks bcweed for all the info. I fixed my problem, it had something to do with LiveCycle Designer. If I just use Acrobat to add the form fields, then the FDF works fine. As to your situation with the SavToBuf, that happens to be the method that I am using, so I will just post my code here, and maybe you can pick out what is different from yours. The Response.BinaryWrite(FDFin.FDFSaveToBuf)is at the bottom.

                                                Sql = "SELECT * FROM Invoices" & WHERE
                                                Set Conn = Server.CreateObject("ADODB.Connection")
                                                Conn.Open Db_Conn_Str
                                                Set Rs = Server.CreateObject("ADODB.Recordset")
                                                Rs.Open Sql, Conn, adOpenStatic, adLockReadOnly, adCmdText

                                                If Not Rs.EOF Then

                                                End If



                                                Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")
                                                Set outputFDF = FdfAcX.FDFCreate

                                                'VendorID = VendorName = VendorNum = InvoiceDate = PreparedBy = ""
                                                Gross = 0

                                                For I=0 To Rs.RecordCount-1
                                                If InStr(VendorID,Rs.Fields("VendorID")) = 0 Then
                                                VendorID = VendorID & Rs.Fields("VendorID") & ", "
                                                End If
                                                If InStr(VendorName,Rs.Fields("VendorName")) = 0 Then
                                                VendorName = VendorName & Rs.Fields("VendorName") & ", "
                                                End If
                                                If InStr(InvoiceNum,Rs.Fields("InvoiceNumber")) = 0 Then
                                                InvoiceNum = InvoiceNum & Rs.Fields("InvoiceNumber") & ", "
                                                End If
                                                If InStr(InvoiceDate,Rs.Fields("InvoiceDate")) = 0 Then
                                                InvoiceDate = InvoiceDate & Rs.Fields("InvoiceDate") & ", "
                                                End If
                                                If InStr(PreparedBy,Rs.Fields("PreparedBy")) = 0 Then
                                                PreparedBy = PreparedBy & Rs.Fields("PreparedBy") & ", "
                                                End If

                                                Rs.MoveNext
                                                Next

                                                Rs.MoveFirst

                                                outputFDF.FDFSetValue "VendorID",VendorID,False
                                                outputFDF.FDFSetValue "VendorName",VendorName,False
                                                outputFDF.FDFSetValue "InvoiceNum",InvoiceNum,False
                                                outputFDF.FDFSetValue "InvoiceDate",InvoiceDate,False
                                                outputFDF.FDFSetValue "PreparedBy",PreparedBy,False

                                                For I=0 To Rs.RecordCount-1
                                                outputFDF.FDFSetValue ("Line."&I), Rs.Fields("Amount")&"", False
                                                outputFDF.FDFSetValue ("Company."&I), Rs.Fields("Company")&"", False
                                                outputFDF.FDFSetValue ("GL."&I), Rs.Fields("GL")&"", False
                                                outputFDF.FDFSetValue ("CC."&I), Rs.Fields("CostCenter")&"", False
                                                outputFDF.FDFSetValue ("DocNum."&I), Rs.Fields("DocNumber")&"", False

                                                Gross = CCur(Gross) + CCur(Rs.Fields("Amount"))

                                                Rs.MoveNext
                                                Next

                                                outputFDF.FDFSetValue "Gross", Gross, False

                                                Rs.Close
                                                Set Rs = Nothing

                                                Sql = "UPDATE Invoices SET DatePrinted = '" & Now() & "'" & WHERE
                                                Conn.Execute Sql

                                                Conn.Close
                                                Set Conn = Nothing

                                                outputFDF.FDFSetValue "PrintDate", Date(), False

                                                outputFDF.FDFSetFile "http://admin/invoices/pdf/InvoiceAuthorization.pdf"

                                                Response.ContentType = "application/vnd.fdf"
                                                Response.BinaryWrite outputFDF.FDFSaveToBuf

                                                outputFDF.FDFClose
                                                %>
                                                • 21. Re: How to Supply the form field values to a pdf form when loading it
                                                  (Aandi_Inston) Level 1
                                                  Ed, looks as if you are using the FDF toolkit, correct? If so...
                                                  LiveCycle forms don't support the FDF format, you do indeed have to
                                                  use Acrobat forms.

                                                  Aandi Inston
                                                  • 22. Re: How to Supply the form field values to a pdf form when loading it
                                                    If you have a form that is already set up in LiveCycle and you want to change it to Adobe Forms so that you can use the FDF toolkit, how can you do that?

                                                    I've tried saving the file as a prior version of Adobe. Adobe Acrobat still opens LiveCycle when I go to edit the form.

                                                    I've tried exporting the file to Word so that I could save as PDF & re-set up the form in Adobe Forms. Unfortunately, that messed up the formatting in a complex looking form.

                                                    I am sure LiveCycle is good to work with, but I already have a ton of code around the FDF Toolkit & upgrading all my forms to LiveCycle & XML is not in my current scope of work.

                                                    Any suggestions?
                                                    • 23. Re: How to Supply the form field values to a pdf form when loading it
                                                      Patrick Leckey Level 3
                                                      LiveCycle Designer does not have the ability to save a form as an AcroForm.

                                                      There are completely different objects and object models in XFA forms and AcroForm. There is no way to convert from one to the other while retaining the form functionality. If it was created as an XFA form, it will forever remain an XFA form.

                                                      The closest you can get would be to open the form in Acrobat, and print to the PDF printer. This will create an non-XFA form. However this process will do what's known as "flattening" the form - i.e. you will lose all your scripts, form fields will no longer be fillable, buttons will not be clickable, etc.

                                                      If you want an AcroForm, you have to design it from the ground up as an AcroForm. Same goes for XFA forms. They are in no way interchangeable or convertable.
                                                      • 24. Re: How to Supply the form field values to a pdf form when loading it
                                                        (Aandi_Inston) Level 1
                                                        You'd start again, so far as I know.

                                                        Aandi Inston
                                                        • 25. Re: How to Supply the form field values to a pdf form when loading it
                                                          I just found how to use Acrobat 8 to create forms without using LC Designer!
                                                          1. As long as your form has not been created in LC Designer to begin with, open it in Acrobat.
                                                          2. From the menu, choose Tools > Forms > Show Forms Toolbar.

                                                          You can create your forms with the tools in Acrobat and still use FDF.

                                                          pbarnet