note 5420 modified in ref.fdf by felipe

From: Date: Sun, 20 Jul 2008 23:41:31 +0000
Subject: note 5420 modified in ref.fdf by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142361@lists.php.net to get a copy of this message
The simplest thing to do is get the FDF data from $HTTP_RAW_POST_DATA. (unless you have the server library installed none of the fdf data gets parsed!) This is typical of what you get: %FDF-1.2 1 0 obj << /FDF << /Fields [ << /V (0)/T (amount0)>> << /V (0)/T (amount1)>> << /V (0)/T (amount2)>> << /V (0)/T (amount3)>> << /V (0)/T (amount4)>> << /V (0)/T (amount5)>> << /V (0)/T (amount6)>> << /V (0)/T (amount7)>> << /V (0)/T (amount8)>> << /V (0)/T (amount9)>> << /V /0102 /T (chase_bk)>> << /V (0)/T (count)>> << /V (0)/T (invtotal)>> << /V (12/21/2000)/T (sent_ap)>> << /V /Off /T (spec_hand)>> << /V (041232)/T (transit_no)>> << /V (THIS FORM IS NOT COMPLETE!!!)/T (X)>> ] /F (http://x.com/forms/AA00390q.pdf)>> >> endobj trailer << /Root 1 0 R >> %%EOF kill everything before the [ and then parse it down into key value pairs. I wrote this to create an FDF, make sure you do a header("Content-type: application/vnd.fdf"); before you echo the returned value to the user. <?php function FDFput($FDFpage){ $A = "%FDF-1.2\n1 0 obj\n<< \n/FDF << /Fields [ \n"; $C = " ] \n" ; if ($FDFpage>"" ) {$C .=" /F ($FDFpage)>>\n";} $C .= ">>\n>> \nendobj\ntrailer\n\n<</Root 1 0 R>>\n%%EOF\n"; $B = ""; reset($FDFData); while (list($key, $val) = each($FDFData)) { if (strlen(trim($val)) > 0 && is_string($key)) { $B .= "<</T ($key) /V (". $val . ")>>\n"; //echo "<</T ($key) /V (". $val . ")>>\n"; } } return $A.$B.$C; } ?> It ain't perfect - but it works. (I use HTML for posting to the server, FDF to the browser) joe --was-- The simplest thing to do is get the FDF data from $HTTP_RAW_POST_DATA. (unless you have the server library installed none of the fdf data gets parsed!) This is typical of what you get: %FDF-1.2 1 0 obj << /FDF << /Fields [ << /V (0)/T (amount0)>> << /V (0)/T (amount1)>> << /V (0)/T (amount2)>> << /V (0)/T (amount3)>> << /V (0)/T (amount4)>> << /V (0)/T (amount5)>> << /V (0)/T (amount6)>> << /V (0)/T (amount7)>> << /V (0)/T (amount8)>> << /V (0)/T (amount9)>> << /V /0102 /T (chase_bk)>> << /V (0)/T (count)>> << /V (0)/T (invtotal)>> << /V (12/21/2000)/T (sent_ap)>> << /V /Off /T (spec_hand)>> << /V (041232)/T (transit_no)>> << /V (THIS FORM IS NOT COMPLETE!!!)/T (X)>> ] /F (http://x.com/forms/AA00390q.pdf)>> >> endobj trailer << /Root 1 0 R >> %%EOF kill everything before the [ and then parse it down into key value pairs. I wrote this to create an FDF, make sure you do a header("Content-type: application/vnd.fdf"); before you echo the returned value to the user. function FDFput(,$FDFpage) { $A = "%FDF-1.2\n1 0 obj\n<< \n/FDF << /Fields [ \n"; $C = " ] \n" ; if ($FDFpage>"" ) {$C .=" /F ($FDFpage)>>\n";} $C .= ">>\n>> \nendobj\ntrailer\n\n<</Root 1 0 R>>\n%%EOF\n"; $B = ""; reset($FDFData); while (list($key, $val) = each($FDFData)) { if (strlen(trim($val)) > 0 && is_string($key)) { $B .= "<</T ($key) /V (". $val . ")>>\n"; //echo "<</T ($key) /V (". $val . ")>>\n"; } } return $A.$B.$C; } It ain't perfect - but it works. (I use HTML for posting to the server, FDF to the browser) joe http://php.net/manual/en/ref.fdf.php

« previous php.notes (#142361) next »