开发者

FDF to PDF using PHP

开发者 https://www.devze.com 2022-12-13 05:27 出处:网络
I was trying to create a pdf fr开发者_Go百科om an FDF file. I have created the FDF file succesfully.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号