note 23978 added to ref.fdf

From: Date: Fri, 02 Aug 2002 15:30:18 +0000
Subject: note 23978 added to ref.fdf
Groups: php.notes 
Request: Send a blank email to php-notes+get-34155@lists.php.net to get a copy of this message
Here is yet another example of generating pre-filled PDFs without using the FDF functions. This function takes two args: a URL to the PDF (like "http://domain.com/path/to/form.pdf" and an array with all the field's values. /* WARNING!! THIS FUNCTION SENDS HTTP HEADERS! It MUST be called before any content is spooled to the browser, or the function will fail! void output_fdf (string $pdf_file, array $pdf_data) $pdf_file: a string containing a URL path to a PDF file on the server. This PDF MUST exist and contain fields with the names referenced by $pdf_data for this function to work. $pdf_data: an array of any fields in $pdf_file that you want to populate, of the form key=>val; where the field name is the key, and the field's value is in val. */ function output_fdf ($pdf_file, $pdf_data) { $fdf = "%FDF-1.2\n%‚„œ”\n"; $fdf .= "1 0 obj \n<< /FDF "; $fdf .= "<< /Fields [\n"; foreach ($pdf_data as $key => $val) $fdf .= "<< /V ($val)/T ($key) >> \n"; $fdf .= "]\n/F ($pdf_file) >>"; $fdf .= ">>\nendobj\ntrailer\n<<\n"; $fdf .= "/Root 1 0 R \n\n>>\n"; $fdf .= "%%EOF"; /* Now we display the FDF data which causes Acrobat to start */ header ("Content-Type: application/vnd.fdf"); print $fdf; } -- http://www.php.net/manual/en/ref.fdf.php http://master.php.net/manage/user-notes.php?action=edit+23978 http://master.php.net/manage/user-notes.php?action=delete+23978 http://master.php.net/manage/user-notes.php?action=reject+23978

« previous php.notes (#34155) next »