I have a pretty general question.

I have a report that is automatically created from HTML and Javascript and is output as a PDF. I'm using JavaScript because it's the best and easiest way I've found to generate the graphs I want.

So I render all the graphs in HTML documents and then use a tool called wkhtmltopdf to render the a PDF out of all the pages.

Now the problem is that the type produced by that tool absolutely sucks.

What I want to do is render the JavaScript graphs, which renders as a <svg ..></svg> tag, inside a PDF document that has it's layout and text produced by some variation of TeX.

Is this at all possible by any means?

  • This is probably not what you want to hear, but thought I'd suggest it anyway: You really should consider using pgfplots and/or tikz for drawing especially if you want tight integration with LaTeX. There should be numerous example here that will get you started, but without seeing an example of what your graph looks like I don't know which question on this site to refer you to. Apr 12, 2012 at 17:59
  • I'm using Protovis to create the graphs, and it's about 25 custom-coded graphs with quite specific layouts, but in general they look like this
    – Fredrik
    Apr 12, 2012 at 19:15
  • Thanks for Protovis link, I did not know about that. But bar charts are no problem in pgfplots. Here are a few useful links in case you are interested (not saying that these are the best ones here): How to put the values of each bar in a pgfplots bar chart inside the bar itself?, and Stacked bar-plot: display total value. Search for [pgfplots] bar if you want more examples. Apr 12, 2012 at 19:24

1 Answer 1


PGFplots has the \addplot graphics (or \addplot3 graphics) feature.

This would allow you to export only the projected graphics plus some meta data about your coordinate space. Then, you import the resulting graphics using \addplot graphics - and communicate the mentioned "meta data" such that pgfplots can properly overlay a suitable axis, including all TeX axis descriptions that the package supports. It would even allow you to change axis limits (somewhat restricted by your input graphics of course).

Here, SVG would be an intermediate step; you would need to convert it to (say) pdf first. But this would not hurt anymore since your graphics would only contain graphical elements, the text would be task of pgfplots and its overlay.

You can find detailed instructions in the pgfplots manual pgfplots manual, section "Using External Graphics as Plot Sources".

In case this is what you want and you run into unparticipated problems, you can ask a more detailed question here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.