javascript 如何从 html5 + css3 创建 pdf 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14333023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:19:43  来源:igfitidea点击:

How can I create a pdf file from html5 + css3?

phpjavascripthtmlcss

提问by Jarab

Possible Duplicate:
Convert HTML + CSS to PDF with PHP?

可能的重复:
使用 PHP 将 HTML + CSS 转换为 PDF?

I need convert an html + css to pdf. The target is generate an invoice.

我需要将 html + css 转换为 pdf。目标是生成发票。

回答by Yogesh Suthar

use this

用这个

http://html2pdf.fr/en/default

http://html2pdf.fr/en/default

$html = file_get_contents("valid.html");
require_once("html2pdf.class.php");
$html2pdf = new HTML2PDF("P", "A4", "en", array(10, 10, 10, 10));
$html2pdf->setEncoding("ISO-8859-1");
$html2pdf->WriteHTML($html);
$html2pdf->Output("pdf/PDF.pdf", "F"); //output to file
$html2pdf->Output(); //output to browser