©
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
(PHP 4, PHP 5, PHP 7)
fdf_create — Create a new FDF document
Creates a new FDF document.
This function is needed if one would like to populate input fields in a PDF document with data.
Returns a FDF document handle, or FALSE
on error.
Example #1 Populating a PDF document
<?php
$outfdf = fdf_create ();
fdf_set_value ( $outfdf , "volume" , $volume , 0 );
fdf_set_file ( $outfdf , "http:/testfdf/resultlabel.pdf" );
fdf_save ( $outfdf , "outtest.fdf" );
fdf_close ( $outfdf );
Header ( "Content-type: application/vnd.fdf" );
$fp = fopen ( "outtest.fdf" , "r" );
fpassthru ( $fp );
unlink ( "outtest.fdf" );
?>
[#1] jwadhwani at pobox dot com [2006-06-06 08:08:46]
For fdf_save you need to provide the complete path, such as :fdf_save($outfdf,"c:/inetpub/wwwroot/temp_sites/fdf/outtest.fdf"); and not only outtest.fdf.
[#2] Punkisdead [2003-10-04 00:03:14]
<?php
$outfdf = fdf_create();
$volume = "test";
fdf_set_value($outfdf, "volume", $volume, 0);
fdf_set_file($outfdf, "http://localhost/webapps/volume.pdf");
Header("Content-type: application/vnd.fdf");
fdf_save($outfdf);
fdf_close($outfdf);
?>
This works for IE 5.5+
It will populate the fields and open the resulting pdf for you, without having to create an fdf file and adding the open script to the pdf...
[#3] mlarke at nanuc dot ca [2003-08-10 17:14:05]
Header("Content-type: application/vnd.fdf"); simply does not work in IE. The easiest method to automatically load the fdf file is to open the 'pdf' file via php. With use of Acrobat
document -> page action -> page open -> add -> javascript
and paste the following into the pdf file:
this.importAnFDF("my_fdf_file.fdf");
This will auto-load the fdf contents
Cheers Mike
[#4] Sergei [2003-03-17 11:43:20]
I thought the following might save someone a lot of time. The example fdf snippet above, namely:
<?php
$outfdf = fdf_create();
fdf_set_value($outfdf, "volume", $volume, 0);
fdf_set_file($outfdf, "http:/testfdf/resultlabel.pdf");
fdf_save($outfdf, "outtest.fdf");
fdf_close($outfdf);
Header("Content-type: application/vnd.fdf");
$fp = fopen("outtest.fdf", "r");
fpassthru($fp);
unlink("outtest.fdf");
?>
will not work (or there's at least a big possibility it won't) in IE (version 6 sure and I suspect lower versions as well) if you have session.auto_start on. Apparently, setting a cookie before feeding the fdf to the browser somehow messes it up. It works fine in Netscape though. I spent days on Google before I found a post somewhere about someone else having the same problem.
The solution? Well, I created a separate directory in the web tree and turned session.auto_start off just for that directory like this:
<Location /new_directory>
php_admin_flag session.auto_start 0
</Location>
Hope this was useful to somebody.