tags:

views:

234

answers:

2

I was trying to create a pdf from 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
A: 

Remove echo $fdf_file,' written successfully.';

Peter Lindqvist
I have removed it. Still shows the same error
Jasim
Have you tried passssthru("pdftk test.pdf fill_form test.fdf output test-out.pdf "); and verified that it works? Have you tried editing the PDF in a hex-editor to see what the data looks like?
Peter Lindqvist
No i haven't.... how do i test "passssthru("pdftk test.pdf fill_form test.fdf output test-out.pdf ".
Jasim
just change output from stdout to a file in your example code.
Peter Lindqvist
I came to find that i haven't installed pdftk... i have got the source code ...but don't know how to use it.. what should i do?
Jasim
depends on the operating system ubuntu/debian -> apt-get install pdftk
Peter Lindqvist
windows -> http://www.pdfhacks.com/pdftk/pdftk-1.41.exe.zip
Peter Lindqvist
When i try "pdftk test.pdf fill_form test.fdf output test-out.pdf" in command line it shows " Input error . so not output created"
Jasim
Do the files exist? Are they in the proper format?
Peter Lindqvist
Yes..When i open test.fdf with adobe pro its asking me whether to save it to test.pdf and its working fine.
Jasim
I'm afraid i can't do much without the files then... :(
Peter Lindqvist
A: 

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.

Fuzzy76