renderwkhtmltopdfmathjaxwkhtmltoimagewkhtmltopdf-binary

wkhtmltopdf and MathJax: equations are rendered too small


I am trying to download the Feynman lectures using wkhtmltopdf. This is the command line that I use:

wkhtmltopdf.exe http://www.feynmanlectures.caltech.edu/I_44.html --javascript-delay 20000 --no-stop-slow-scripts ./out/I_44.pdf

However the MathJAX formula are rendered too small. Here is a picture: enter image description here

How I can enlarge the rendered equations?

In this topic the suggested solution (as I understand it) would be to add

MathJax.Hub.Config({
CommonHTML: {
    minScaleAdjust: 100,
}
});

to the HTML.

But of course downloading the HTML file and modify it before passing it to wkhtmltopdf would be too cumbersome. I would prefer an easier solution if possible.


Solution

  • Try using

    wkhtmltopdf.exe http://www.feynmanlectures.caltech.edu/I_44.html --run-script 'MathJax.Hub.Config({"HTML-CSS": {scale: 200}}); MathJax.Hub.Queue(["Rerender", MathJax.Hub], function () {window.status="finished"})' --window-status finished --no-stop-slow-scripts ./out/I_44.pdf
    

    This will set the scaling factor for the math and re-render it at that size. It also uses the window.status variable to synchronize the page capture with MathJax so that the capture occurs immediately after MathJax finishes (rather than waiting for an arbitrary delay).