0
votes

I have a PDF form created in Livecycle Designer ES3.

My job is to have the submit button save the whole pdf on the server in a certain folder.

The button points to a php file on my web server. The button is of type "submit" and submit as "URL-encoded date (HTTP).

I have tried:

$file = $GLOBALS['HTTP_RAW_POST_DATA'];
$newfile = "/var/watchfolder/" . microtime(true) . ".pdf";
file_put_contents($newfile, $file);

I have also tried:

$file = file_get_contents("php://input");
$newfile = "/var/watchfolder/" . microtime(true) . ".pdf";
file_put_contents($newfile, $file);

Both times they write a file but the contents of the file look like this:

OrderDate=&DocumentNo=&Concat_BuyfromVendorNo_BuyfromVendorName=&JobNo=&TicketNo=&Concat_SellToCustomerNo_SellToCustomerName=&LineNo_1=&No_1=&OutstandingQuantity_1=&Quantity_1=123&...

and neither Reader or Acrobat will open it as a valid pdf.

how do I get it to write as a pdf-formatted file?


UPDATE:

* I figured it out. In Livecycle choose "Submit As: PDF" and point it to your php file.

Mine looks like:

<?php
ob_start();
$file = file_get_contents("php://input"); //Gets binary PDF Data
$time = microtime(true);
$newfile = "/var/watchfolder/" . $time . ".pdf"; //Names xml file based on the time to the microsecond so nothing gets overwritten.
$worked = file_put_contents($newfile, $file); //Creates File
ob_end_clean();

$file = "/var/www/forms/Submission_Confirmation.pdf";
$filename = 'Submission_Confirmation.pdf'; /* Note: Always use .pdf at the end. */

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);

?>

The last part loads a PDF in reader as the confirmation. It can be any pdf you want including the PDF that was just submitted.

Reader Extend the PDF in Acrobat

Fill out and submit

Voila!

1

1 Answers

0
votes

That because plain text/html (ASCII) is not in pdf format (wich is binary).

You need to use PHP PDF, great examples and how-to's can be found here:

http://www.php.net/manual/en/pdf.examples-basic.php

Also, $GLOBALS['HTTP_RAW_POST_DATA']; is just a nope. Check the $_POST globalvariable and retrieve the value need to put into the pdf file.