将html + css + js转换为PDF [英] Convert html+css+js to PDF

查看:749
本文介绍了将html + css + js转换为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建类似的内容(代码为此处):

pdf格式.我正在使用 google图表,并且与此 iText + XMLWorker ,但是 css 和任何支持js的问题我认为.


因此,问题是:如何将html + css + js转换为.pdf文件?或者,可能是该问题还有其他变体?

解决方案

按照评论中的承诺,我问过Raf.这就是他的答案:

将XML Worker用于HTML + CSS + JS的一种方法是使用浏览器引擎预处理HTML.这样的浏览器引擎的示例是WebKit(Chrome,Safari)和Gecko(Firefox).它们可以解释CSS和JS,并为您提供可供XML Worker解析的HTML.

竞争产品的示例是:

  • wkhtmltopdf,这是一个使用WebKit作为其呈现引擎的命令行工具.
  • Prince XML使用自己的引擎支持HTML + CSS + JS到PDF.

也许还有其他人,但这就是Raf告诉我的.我希望这会有所帮助.

I want to create something like this (code is here):

in pdf format. I'm using google charts and regarding to this forum converting chart to pdf is impossible. I've already tryied iText+XMLWorker, but there is some problem with css and any js supporting at all, I think.


So, the questions are: How can I convert html+css+js to .pdf file? Or, may be, the issue have other variants?

解决方案

As promised in the comment, I've asked Raf. This was his answer:

One way to use XML Worker for HTML+CSS+JS is to use a browser engine to preprocess the HTML. Examples of such a browser engine are WebKit (Chrome, Safari) and Gecko (Firefox). These can interpret the CSS and JS and give you HTML that is ready to be parsed by XML Worker.

Examples of competing products are:

  • wkhtmltopdf, a command line tool that uses WebKit as its rendering engine.
  • Prince XML supports HTML+CSS+JS to PDF using their own engine.

Maybe there are others, but this is what Raf told me. I hope this helps.

这篇关于将html + css + js转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆