How to use highcharts with princeXML?
Asked Answered
H

3

6

I'm evaluating princexml, and it is very very good so far. One minor problem though. Is there any way to save a graph generated by highcharts into princexml, on the browser?

I understand that I need to create the graph as an image, on a canvas, but not sure how to feed the graph to princexml. Any ideas?

Hartsell answered 27/2, 2012 at 21:19 Comment(0)
N
2

One thing you can do is just feed the SVG generated by HighCharts to prince.

One problem you will have with this solution is that IE8 won't generate SVG, but VML, which prince can't render. You may be able to feed your javascript directly to Prince, but we have yet to test this solution out.

Edit:

I actually just tested feeding Prince with the javascript that would generate the SVG... but no luck, so we're stuck with feeding it pre-rendered SVG. Might have to do it server side using a javascript runtime.

Nannienanning answered 27/2, 2012 at 23:47 Comment(0)
O
2

I work at DocRaptor (an HTML to PDF API, using Prince XML for PDF rendering) and we just published a blog post about adding Highcharts to PDFs:

Adding Highcharts to PDFs

Basically, you just need to use our JavaScript engine (which is distinct from Prince's JavaScript engine, and runs before we hand the process off to Prince) and disable animations in the code that renders your graphs.

Ope answered 9/10, 2014 at 19:59 Comment(1)
Where can I find your JavaScript engine? Is it open source?Marla
S
0

PrinceXML's JavaScript engine doesn't seems powerful enough to do charts with components like Highcharts.

So what I've done is run my page into PhantomJS so it would run the JS and create the SVG elements in the DOM and then feeding the result to PrinceXML.

Be sure to disable animations otherwise you'll print frame 0 of it:

Highcharts.setOptions({
                plotOptions: {
                    series: {
                        animation: false //Animations prevent proper PDF generation of charts!
                    }
                }
            });
Sidle answered 6/3, 2015 at 9:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.