Miscellaneous
|
|
|
|
<?php /*
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.2n%����n";
$fdf .= "1 0 obj n<< /FDF ";
$fdf .= "<< /Fields [n";
foreach ($pdf_data as $key => $val)
$fdf .= "<< /V ($val)/T ($key) >> n";
$fdf .= "]n";
$fdf .= "/F ($pdf_file) >>";
$fdf .= ">>nendobjntrailern<<n/Root 1 0 Rnn>>n";
$fdf .= "%%EOF";
/* Now we display the FDF data which causes Acrobat to start */
header ("Content-Type: application/vnd.fdf");
print $fdf;
}
?>
|
|
|
Usage Example
|
$file = 'http://url.com/form.pdf';
$data = array (
'field1' => 'value',
'field2' => 'value'
);
output_fdf($file, $data);
|
|
|
Rate This Script
|
|
|
|