The reason I ask is that things like jQuery are becoming increasingly common as a styling tool (eg odd/even table row styling). Does Prince XML have a Javascript engine? Are there plans to add one? The Google Chrome engine is open source (but it might be GPLed, which would exclude it).
Forum › How do I...?
Does Prince XML have a Javascript engine?
Cool. BTW the Google V8 Javascript engine has a variant of the BSD license, which is a lot friendlier than GPL.
We have now released Prince 8.0 beta, which supports JavaScript and can be used with jQuery.
Has anyone gotten prince 8 to render javascript charts in a PDF?
I downloaded the 8.0 beta and tried to generate from http://highcharts.com and http://amcharts.com/javascript using --javascript but the pdf still contained blanks for the charts.
Any suggestions for charting libraries that will both work with prince and be enable browser interaction?
Any suggestions for generating pdf charts from one of the libraries mentioned above?
I downloaded the 8.0 beta and tried to generate from http://highcharts.com and http://amcharts.com/javascript using --javascript but the pdf still contained blanks for the charts.
Any suggestions for charting libraries that will both work with prince and be enable browser interaction?
Any suggestions for generating pdf charts from one of the libraries mentioned above?
Because this is the first release of Prince with JavaScript support, there are bound to be many little issues that pop up once people start running real scripts in the wild. We're making a list of these to fix for 8.1, and we will do some testing with these charting libraries to see what we can find.
Thanks for the response.
What is the timeframe for 8.1?
While you are considering test cases ... google interactive charts should also be considered (http://code.google.com/apis/chart/interactive/docs/gallery.html).
I also tried to generate a PDF from google image charts (e.g. - http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html) but they ended up looking very grainy. Not sure what approach to use for charts at this point...
What is the timeframe for 8.1?
While you are considering test cases ... google interactive charts should also be considered (http://code.google.com/apis/chart/interactive/docs/gallery.html).
I also tried to generate a PDF from google image charts (e.g. - http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html) but they ended up looking very grainy. Not sure what approach to use for charts at this point...
Thanks, we've done some testing with Google charts and found some further issues to address, mostly minor stuff like support for deprecated octal character escapes, a few additional standard functions, and so forth. Can't give a timeframe for 8.1 just yet, but making these charting/graphing libraries work will be a priority.
Add me to list of folks who would like to be able to use HighCharts with Prince. We have an online app for a public school district that uses HighCharts - teachers/principals love to print things, but to date we can't give them the charts.
We use highcharts with princexml. It required a bit of cunning but it works. We do it by storing the svg in a db.
It looks great, although we haven't been able to reproduce the animation part [winking emoticon].
It looks great, although we haven't been able to reproduce the animation part [winking emoticon].
@Grozzled - You've got my attention. Would you mind sharing an example project/solution? This sounds like an approach that the Prince team could use as a recommendation for working around the issue until js charts are fully supported.
Just wanted let you know DocRaptor has a javascript engine which can run highcharts and some other charting libraries without the need for the SVG pre-rendering (though that's faster on our end). We are currently running Prince 7.1 rather than Prince 8.0. If you really need this feature Right Now, it is available.
joelmeador wrote:
Just wanted let you know DocRaptor has a javascript engine which can run highcharts and some other charting libraries without the need for the SVG pre-rendering (though that's faster on our end). )
How were you able to get DocRaptor to work? When I run http://www.highcharts.com/ or http://www.highcharts.com/demo through http://docraptor.com/try_it_out I don't see any charts.
k6b wrote:
How were you able to get DocRaptor to work? When I run http://www.highcharts.com/ or http://www.highcharts.com/demo through http://docraptor.com/try_it_out I don't see any charts.
By default, highcharts has some animations enabled on their charts. You have to turn off the global and plotting animations for it to work.
I'd like to run jQuery, Highcharts, and a bunch of other Javascript within Prince.
On the input side, I'd like to stick with XML, rather than HTML.
'xi:include' currently only supports XML files, so I'm stuck with '--javascript --script=xyz.js' and so on in the shell, which is quite tedious if you have a lot of Javascript files to add.
Is there a more elegant solution?
On the input side, I'd like to stick with XML, rather than HTML.
'xi:include' currently only supports XML files, so I'm stuck with '--javascript --script=xyz.js' and so on in the shell, which is quite tedious if you have a lot of Javascript files to add.
Is there a more elegant solution?
@mikeday: Thanks for your kind answer - it worked.
@Grozzled: Yes, it would be awfully helpful if you could share a few details with us; I've got all the parts together now but I'm missing a small piece of 'glue' in between. How do you manage without 'innerHtml Could you maybe share some demo code?
@Grozzled: Yes, it would be awfully helpful if you could share a few details with us; I've got all the parts together now but I'm missing a small piece of 'glue' in between. How do you manage without 'innerHtml Could you maybe share some demo code?
I have had similar issue when trying to use jQuery and MathJax (mathjax.org) in a document. I came up with a 2 step approach that might also be useful for you: I let the Javascript handling to webkit such that Prince can focus on what it does best, formatting html using advanced css.
More in detail. In the first step I use PhantomJS (phantomjs.org) to render the entire page and save the resulting html. The tricky part is that a browser doesn't know exactly when all the rendering is done because of the asynchronous nature of Javascript. The resulting html is saved to a temporary file and all scripts are stripped. In the second phase, this temporary file is feed to Prince.
For me, this works really well and I use it on a weekly basis. I have shared my html/css/js template + scripts on github if you'd want to see it: https://github.com/wannesm/articlecls (the PhantomJS script is in the support directory).
More in detail. In the first step I use PhantomJS (phantomjs.org) to render the entire page and save the resulting html. The tricky part is that a browser doesn't know exactly when all the rendering is done because of the asynchronous nature of Javascript. The resulting html is saved to a temporary file and all scripts are stripped. In the second phase, this temporary file is feed to Prince.
For me, this works really well and I use it on a weekly basis. I have shared my html/css/js template + scripts on github if you'd want to see it: https://github.com/wannesm/articlecls (the PhantomJS script is in the support directory).
I was facing the same problem, and I found a decent enough workaround that has worked for us. Try looking into http://phantomjs.org.
We use Lasso (similar to PHP, but better) as our middleware. We first have Lasso call the phantomjs binary, which runs a javascript file that loads the particular page that Lasso renders. It then dumps the output of the html (including the necessary SVG tags) into a file in /tmp. We then call PrinceXML to render the PDF from that html file.
I've added the javascript file here: https://github.com/macguyInNC/pageloader. Feel free to ask me any questions if you need any help. I'll try to help as best I can.
We use Lasso (similar to PHP, but better) as our middleware. We first have Lasso call the phantomjs binary, which runs a javascript file that loads the particular page that Lasso renders. It then dumps the output of the html (including the necessary SVG tags) into a file in /tmp. We then call PrinceXML to render the PDF from that html file.
I've added the javascript file here: https://github.com/macguyInNC/pageloader. Feel free to ask me any questions if you need any help. I'll try to help as best I can.