問題描述
是否可以創建網頁打印視圖的 PDF? (Is it possible to create a PDF of a webpage's print view?)
I have a webpage with a separate stylesheet for print. When I view the print preview it looks exactly how i want it.
Is there a way I can generate a PDF and begin download on click / submit that is that file?
參考解法
方法 1:
To Generate PDF in PHP , you can use FPDF . Gothrough the folowing link to learn more about fpdf
http://www.fpdf.org/
方法 2:
You can print your webpage using freepdf as pdf.
方法 3:
I'd suggest something like wkhtmltopdf, which converts HTML to PDF format. You'll need to read your own site in, possibly over http, and save a copy to disk before sending out to the user.
方法 4:
You can use one of:
http://code.google.com/p/dompdf/ http://www.tufat.com/docs/html2ps/ http://code.google.com/p/wkhtmltopdf/
The first two are runnable directly from PHP, suggested if you do not have a Linux server where you can run shell commands. The last one is the best HTML->PDF converter, but it's not a PHP function, it's a Linux shell command. You can run it from PHP if your server allows it.
(by user1157393、Suresh kumar、take、halfer、lorenzo-s)