note 17752 added to ref.fdf
| From: | gregDELETETHIS at laundrymat dot tv | Date: | Fri, 21 Dec 2001 20:06:07 +0000 |
| Subject: | note 17752 added to ref.fdf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-23770@lists.php.net to get a copy of this message | ||
Here is an easy script to output fdf data to the browser without using the fdf toolkit or creating
an actual fdf file on the server.
By the way acrobat is very picky about line breaks so you must leave the "\n" in the
script. The script reads the variables posted to it from a form use POST and creates a fdf file from
them. The field names posted to this script must match the field names in the pdf. Acrobat will
ignore any that don't match.
<?php
//path to pdf file
$url="http://www.some_url.com/form.pdf";
$values=$HTTP_POST_VARS;
$fdfdata = "%FDF-1.2\n%\n";
$fdfdata .= "1 0 obj \n<< /FDF ";
$fdfdata .= "<< /Fields [\n";
//loop that adds the field names and values
foreach($values as $key=>$val)
{
$fdfdata.="<< /V ($val)/T ($key) >> ";
}
$fdfdata .= "]\n";
$fdfdata .= "/F ($url) >>";
$fdfdata .= ">>\nendobj\ntrailer\n<<\n/Root 1 0 R\n>>\n";
$fdfdata .= "%%EOF";
/*** Now we display the FDF data which causes Acrobat to start ***/
header ("Content-Type: application/vnd.fdf");
print $fdfdata;
?>
You can use javascript in the pdf to read the values from a GET method posted directly to the pdf.
you can see both methods here: http://laundrymat.tv/pdf/
--
http://www.php.net/manual/en/ref.fdf.php
http://master.php.net/manage/user-notes.php?action=edit+17752
http://master.php.net/manage/user-notes.php?action=delete+17752
http://master.php.net/manage/user-notes.php?action=reject+17752