[Tex/LaTex] JavaScript/HTML/SVG rendered inside a TeX PDF document, impossible

htmljavascriptsvg

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?

Best Answer

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.

Related Question