10 Replies Latest reply on Feb 26, 2013 3:59 PM by Dave Merchant

    Submitting Data from a PDF Form

    ElliottWD

      I created a form with Acrobat Pro. It is set to submit data via http "get". I can send it just fine from Acrobat, but not Reader. With Reader the server does not recieve any data. I first tried to create a form that sent via mailto, but I had problems with computers that did not have an email client setup to work with Adobe. So then I read it was best to send it to a web server. Now after many hours of work I got it working great with Acrobat, but not with Reader. Any suggestions?

       

      this.submitForm({

              cURL:"http://mysite.com/acceptPDF.php",

              bGet:true,

              aFields: aSubmitFields,

              cSubmitAs: "HTML"

      });

       

       

      In the php

       

      I have die(print_r($_REQUEST));

       

      With Reader I just get some strange pared keys and values I believe are cookie values.

        • 1. Re: Submitting Data from a PDF Form
          Dave Merchant MVP & Adobe Community Professional

          The form data sent to the server isn't in the $_REQUEST variable, it's passed through the stdin connector. Try

           

          $data = file_get_contents("php://input");

          • 2. Re: Submitting Data from a PDF Form
            ElliottWD Level 1

            I don't understand this. I know file get contents get the contents of file, but I don't understand the "php://input". Why does it work in Acrobat and why does the request work when I have told the form to submit field data a GET?  I tried pasting the code into my php file and I get nothing when sent from Acrobat.

            • 3. Re: Submitting Data from a PDF Form
              Test Screen Name Most Valuable Participant

              With Reader I believe you have to return FDF data. Reader has no clue what to do with the text contents you return from your PHP, because it does not contain the "convert to PDF" code found in Acrobat.

              • 4. Re: Submitting Data from a PDF Form
                ElliottWD Level 1

                "With Reader I believe you have to return FDF data. Reader has no clue what to do with the text contents you return from your PHP, because it does not contain the "convert to PDF" code found in Acrobat."

                 

                I do not want to return any data to Reader. I just want to send data from Reader to be email and stored.

                • 5. Re: Submitting Data from a PDF Form
                  Test Screen Name Most Valuable Participant

                  Isn't the purpose of die(print_r($_REQUEST)) to send information back to the client? Sorry, if not, then I misunderstood.If it is, then you are returning text contents to Reader - aren't you?

                   

                  Can you give us the whole of a set of data submitted by Reader (remove anything confidential of course). There are no cookies in Reader, either...

                  • 6. Re: Submitting Data from a PDF Form
                    ElliottWD Level 1

                    This is an array of the data being sent

                    var aSubmitFields = Array('acceptcode','SALES PERSON','DATE','Job Number','Job Description','Business Name','Contact Name','Proof Status','CHANGES COMMENTS','PROOFED OK BY','Okay Date','Phone Numbers','Spelling','Names_A_Addresses','Layout_A_Size','Ink_Colors','Bleeds_A_Margins',' Folds_A_Prefs','Photo_Resolution')

                     

                    I have the die(print_r($_REQUEST)) just to see if the data gets to the php script. When I do this in Acrobat, Acrobat creates a nice PDF of the php web page. When I do this with Reader it send the request, but then it creates an html file in the temp folder with the data. But the data that was supposedly sent is not displayed in the html file nor is it place in the database. Just cookie information for the domain that the php file site on.

                    • 7. Re: Submitting Data from a PDF Form
                      Test Screen Name Most Valuable Participant

                      I would expect Reader to fail horribly if you try this. By design because you are not sending it an FDF, and you have to send it an FDF (or nothing). There's no guarantee it will save anything, nor that what it saves is what it was sent, or anything useful. Since Reader does not know anything about cookies, and does not send them, the chances are that the HTML you see is a side effect of something you weren't asking for.

                       

                      If you want to track what Reader is sending, log it or save it on the server.

                      • 8. Re: Submitting Data from a PDF Form
                        ElliottWD Level 1

                        If you want to track what Reader is sending, log it or save it on the server

                         

                        Yes, but how? That is what I am trying to do.

                        • 9. Re: Submitting Data from a PDF Form
                          Test Screen Name Most Valuable Participant

                          I don't know PHP, but you need to not use methods that show anything in the browser there and then. Whatever method you use would write a file, or more than one file, which you'd have a DIFFERENT PHP to display later on. Or it would send an email or whatever. The call you are using is not suitable.

                          • 10. Re: Submitting Data from a PDF Form
                            Dave Merchant MVP & Adobe Community Professional

                            Sorry, I didn't notice your bGet parameter; but that's why it won't work in Reader.

                             

                            As the SDK explains, to use bGet:true you need the Acrobat Web Capture plugin to be loaded, which as the name suggests isn't available in Reader. To submit HTML in Reader you have to use POST, in which case the returned data is available in $_REQUEST (as an alias for $_POST) and on the standard input (php://input).

                             

                            As Test Screen Name says, while you can submit the form data to the server in HTML using Reader, the server has to respond in FDF. Here's a sample utility script that will dump all the data to a logfile and reply with something in a dialog box:

                             

                             

                            <?php

                            header("Content-type: application/vnd.fdf");

                            $data .= "--- STDIN follows ---\n".file_get_contents("php://input");

                            $data .= "\n --- REQUEST follows ---\n";

                            foreach ($_REQUEST as $k=>$v) $data .= "$k = $v\n";

                            $data .= "\n === END DATA ===";

                            $log = fopen("datalog.txt","w");

                            fwrite($log, $data, strlen($data));

                            fclose($log);

                            // reply with some FDF data

                            echo <<<RESPONSE

                            %FDF-1.2

                            1 0 obj

                            << /FDF <<

                            /Status (Thanks - your information has been stored)

                            >>

                            >>

                            endobj

                            trailer

                            << /Root 1 0 R >>

                            %%EOF

                            RESPONSE;

                            ?>