来自包含 Javascript 的 html 的动态 PDF
我目前正在努力从一个简单的 html 页面生成 PDF,该页面包含一些使用 Highcharts 在 Javascript 中生成的图表。
我们目前安装了 ABCPdf,它可以生成 PDF,但它不会捕获任何图表。经过一番谷歌搜索后,我发现添加:
theDoc.htmlOptions.UseScript = True
应该有效,但事实并非如此。我将不胜感激任何想法。
谢谢,
戴夫
I'm currently working on generating a PDF from a simple html page that contains a few charts that are generated in Javascript using Highcharts.
We currently have ABCPdf installed which generates the PDF, however it doesn't capture any of the charts. After some Googling, I found that adding:
theDoc.htmlOptions.UseScript = True
Should work, but it doesnt. I'd appreciate any ideas.
Thanks,
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们目前正在生产中使用 javascript 的网页执行此操作,这些网页以 pdf 格式呈现以创建报告(使用 HighCharts 图表)
我们正在使用 wkhtmltopdf 取得了巨大成功。
We're currently doing this in production for web pages with javascript that are rendered in pdf to create reports (with HighCharts Graphs)
We're using wkhtmltopdf with great success.
一些想法:
Some ideas:
Highchart 网站 上找到的示例图表似乎使用 SVG。
当我尝试使用 WebSupergoo 的 online demo for ABCpdf(使用 IE)渲染他们的主页时,这些也无法渲染。
根据 文档...
不过,最新版本的 ABCpdf 引入了对使用 Gecko 渲染引擎转换网页的支持。由于该引擎支持大多数 SVG Full 配置文件,因此我建议尝试一下。您可以在 Mozilla 网站... 上找到当前未实现的部分
。对于 Gecko 引擎,您需要添加类似以下代码行的内容:
每个渲染引擎还具有一组不同的 HtmlOptions。您可以在此处找到有关 GeckoSubset 的更多信息。 .
如果这不起作用,您可能需要查看 HighChart 可以导出哪些其他格式。他们支持 HTML5 canvas 元素吗?
另一个想法:是否有可能您的图表正在淡入而 ABCpdf 仅捕获第一帧?
The example charts found on Highchart's website appear to use SVG.
When I attempted to render their home page with WebSupergoo's online demo for ABCpdf, which uses IE, these also failed to render.
ABCpdf supports only a subset of SVG based around the SVG Tiny specification, according to the documentation...
However, the latest version of ABCpdf introduced support for converting web pages with Gecko's rendering engine. As this engine supports the majority of the SVG Full profile, I would suggest giving it a try. You can find out which bits are not currently implemented here on Mozilla's site...
To switch to the Gecko engine you'll need to add something like the following line of code:
Each rendering engine also has a different set of HtmlOptions. You can find out more about the GeckoSubset here...
If this doesn't work, you may need to look at what other formats HighChart can export. Do they support the HTML5 canvas element?
Another thought: Is it possible your charts are fading in and ABCpdf is only capturing the first frame?