wkhtmltopdf and MathJax: equations are rendered too small

1.6k views Asked by At

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.

2

There are 2 answers

0
Davide Cervone On BEST ANSWER

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).

0
Slartibart On

What works for me is close to the proposed approach above but with a different keyword.

MathJax.Hub.Config({
  "HTML-CSS": {minScaleAdjust: 100,},
  jax: ["input/TeX", "output/HTML-CSS",],
});

Reference is here: https://docs.mathjax.org/en/v2.7-latest/options/output-processors/HTML-CSS.html

But I guess (not tested) that you might be able to make the original proposal work if you replace the output/HTML-CSS with output/CommonHTML.