I was trying to create a pdf fr开发者_Go百科om an FDF file. I have created the FDF file succesfully. But when i try to convert it into pdf i get some errors. Below is the part of my code. the test.pdf file open in a download box and when i try to open it gives error "couldn't open test.pdf because it is either not supported file type or has been damaged"
if($fp=fopen($fdf_file,'w')){
fwrite($fp,$fdf_data,strlen($fdf_data));
echo $fdf_file,' written successfully.';
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="test.pdf"');
passssthru("pdftk test.pdf fill_form test.fdf output - ");
exit;
}else{
die('U
if($fp=fopen($fdf_file,'w')){
fwrite($fp,$fdf_data,strlen($fdf_data));
//echo $fdf_file,' written successfully.';
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="test.pdf"');
passssthru("pdftk test.pdf fill_form test.fdf output - ");
exit;
}
Remove echo $fdf_file,' written successfully.';
To further debug this, check the size of the downloaded file, and take a peek at it in an editor. I am guessing you have output before or after this code.
You probably need to be making sure to directly reference where pdftk is installed, as such:
passthru('/usr/local/bin/pdftk /forms/test.pdf fill_form /forms/test.fdf output - ');
Also, you can add >> output.pdf
at the end of the command to create a new pdf file.
精彩评论