wkhtmltopdf codeigniter

╄→尐↘猪︶ㄣ 提交于 2019-12-04 15:46:43

问题


wkhtmltopdf sounds like an excellent solution...the problem is nothing happens on the exec

shell_exec("c:\wkhtmltopdf.exe","http://www.google.com google.pdf");

Am i doing anything wrong?


回答1:


Can you use the "official" class?

http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp

If not, perhaps peeking into how they did things will help you out with your implementation.

// Include WKPDF class.
require_once('wkhtmltopdf/wkhtmltopdf.php');

// Create PDF object.
$pdf = new WKPDF();
// Set PDF's HTML
$pdf->set_html('Hello <b>Mars<.b>!');
// Convert HTML to PDF
$pdf->render();
// Output PDF. The file name is suggested to the browser.
$pdf->output(WKPDF::$PDF_EMBEDDED, 'sample.pdf');

Edit:

New link, from the Githubs - https://github.com/mikehaertl/phpwkhtmltopdf




回答2:


shell_exec() only takes one parameter, but you have given it two. Try this instead:

shell_exec("c:\wkhtmltopdf.exe http://www.google.com google.pdf");

I think that will do it. You might also consider using the exec() function.




回答3:


add path to wkhtmltopdf.exe CLASS_PATH variable and in your php script use bellow code

passthru("wkhtmltopdf www.gmail.com output.pdf",$err);

// We'll be outputting a PDF header('Content-type: application/pdf');

// It will be called downloaded.pdf header('Content-Disposition: attachment; filename="output.pdf"');

// The PDF source is in original.pdf readfile('output.pdf');

i hope this will work...



来源:https://stackoverflow.com/questions/3474810/wkhtmltopdf-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!