wkhtmltopdf Windows下 測試demo 成功


html2pdf 轉pdf 中文不換行 然后找到了wkhtmltopdf 支持中文換行 樣式也支持 

 

在PHP中生成PDF文件,可以使用 FPDF 和 TCPDF 。但是它們只能用於創建簡單的表格,當涉及到需要將圖像添加到表中,就無法產生所需的布局。有一個強大的工具叫wkhtmltopdf就能夠實現。

Wkhtmltopdf 是一個shell工具,它使用了WebKit渲染引擎和QT,將HTML轉換為PDF格式。

wkhtmltopdf 下載地址
http://www.softpedia.com/get/Office-tools/PDF/wkhtmltopdf.shtml

 

$pdf_tool=dirname(__FILE__).'\bin\wkhtmltopdf';
//exec("D:/xampp/htdocs/test/wkhtmltopdf/bin/wkhtmltopdf bin/ceshi2.html bin/ceshi2.pdf");
exec("$pdf_tool bin/ceshi2.html bin/ceshi2.pdf");
if(file_exists("bin/ceshi2.pdf")){
	header("Content-type:application/pdf");
//直接下載 //header("Content-Disposition:attachment;filename='ceshi2.pdf'"); // echo file_get_contents("/tmp/{$filename}.pdf"); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.filesize('bin/ceshi2.pdf'));
//pdf預覽模式 header('Content-Disposition: inline; filename="ceshi2.pdf";'); echo file_get_contents('bin/ceshi2.pdf'); //readfile("bin/ceshi2.pdf"); }else{ exit; }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM