仅使用 javascript 将 HTML 转换为 PDF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10683095/
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 10:40:41  来源:igfitidea点击:

HTML to PDF conversion using only javascript

javascriptjqueryjquery-plugins

提问by user359187

Is there any way convert an HTML page to a PDF document using javascript only?

有什么方法可以仅使用 javascript 将 HTML 页面转换为 PDF 文档吗?

I know this can be done using PHP or Java etc. but i don't have the option to use these languages in my project.

我知道这可以使用 PHP 或 Java 等来完成,但我没有选择在我的项目中使用这些语言。

回答by Eugene

Disclaimer: I am affiliated with ByteScout

免责声明:我隶属于ByteScout

Bytescout has new javascript product "PDF Generator SDK for Javascript" which is capable of generating PDF files 100% on client side, probably you may generate PDF with text, images, graphics. Full HTML formatting is not supported, but you can use <b>, <i>, <u> html tags inside text to use rich formatting (new version will include support for <font> and <a href> html tags inside text)

Bytescout 有新的 javascript 产品“PDF Generator SDK for Javascript”,它能够在客户端 100% 生成 PDF 文件,可能您可以生成带有文本、图像、图形的 PDF。不支持完整的 HTML 格式,但您可以在文本中使用 <b>、<i>、<u> html 标签来使用丰富的格式(新版本将包括对文本内 <font> 和 <a href> html 标签的支持)

Demo of invoice with logo and table generated: http://bytescout.com/products/developer/pdfgeneratorsdkjs/create_pdf_invoice_javascript.html

带有徽标和表格的发票演示:http: //bytescout.com/products/developer/pdfgeneratorsdkjs/create_pdf_invoice_javascript.html