Dynamic PDF from html that contains Javascript
I'm currently working on generating a PDF from a simple html page 开发者_如何学Cthat 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
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:
- Since ABCPDF uses the IE engine: Does your server IE version supports Highcharts? Upgrade if not.
- You may want to check if Highcharts have to option the generate an image.
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:
myDoc.HtmlOptions.Engine = EngineType.Gecko;
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?
精彩评论