1

This is my PHP code which I am using to convert HTML file to pdf and then download pdf file from server.

wkhtmltopdf

$url = base_url().'invoices/'.$file_name.'.html';                    
exec("wkhtmltopdf-amd64 $url {$file_folder}{$file_name}.pdf");

header("Cache-Control: no-cache");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file_name.pdf");
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
$pdfFile = base_url().'invoices/'.$file_name.'.pdf';
readfile($pdfFile);

& after execute exec("wkhtmltopdf-amd64 $url {$file_folder}{$file_name}.pdf"); it does not create pdf file in the folder

It is working fine on Ubuntu but on Debian after download pdf, when open pdf Adob Reader says error please see the image.

I think the issue is due to exec() not working in Debian...!

enter image description here

wkhtmltopdf

PHP Ferrari
  • 15,754
  • 27
  • 83
  • 149

2 Answers2

0

Check for the path in base_url() is passing correct path during download of the file, to test that write down the path in browser and check whether it gets downloaded or not

somesh
  • 589
  • 1
  • 5
  • 11
  • ulr is pointing correct, sorry one thing more i m using wkhtmltopdf & after execute exec("wkhtmltopdf-amd64 $url {$file_folder}{$file_name}.pdf"); it does not create pdf file in the folder. – PHP Ferrari Jan 16 '13 at 06:09
  • That's what it is happening when there is no file in the or of proper format that error is given and for wkhtmltopdf this may help u [http://stackoverflow.com/questions/8881315/linux-permissions-issue-when-executing-wkhtmltopdf-amd64](http://stackoverflow.com/questions/8881315/linux-permissions-issue-when-executing-wkhtmltopdf-amd64) – somesh Jan 16 '13 at 06:18
0

For Debian I needed to install xvfb-run wkhtmltopdf

PHP Ferrari
  • 15,754
  • 27
  • 83
  • 149
  • I have to install xvfb-run but always like this case, can I get spesific solution maybe the configuration or etc, please, thanks – wuku Feb 07 '22 at 08:56