Converting MathJax into pdf with wkhtmltopdf yields too small maths

限于喜欢 提交于 2020-01-24 18:08:05

问题


By using pdfkit-pythonbased on wkhtmltopdf, I have managed to convert MathJaxinto pdf. wkhtmltopdf configuration options are the following:

options = {
    'quiet': '',
    'javascript-delay' : '5000',
    'page-size': 'A4',
    'margin-top': '0.75in',
    'margin-right': '0.75in',
    'margin-bottom': '0.75in',
    'margin-left': '0.75in',
    'disable-smart-shrinking': '',
    'dpi': '400',
}

This allows to obtain the markdown text that is large as expected, however maths do not scale accordingly.

Here a snapshot of the pdf obtained :

where maths appears definitely too small.

And here how it is rendered on the browser:

Any idea on how to tackle the problem, in other words obtain maths scaling with the markdown text in the pdf output, will be greatly appreciated.

Here below the MathJax config:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    TeX: {extensions: ["mhchem.js"]},
    tex2jax: {
    inlineMath: [['$','$'], ['\\(','\\)']],
    displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    processEscapes: true
    }
});
</script>

<script type="text/javascript" async
    src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

回答1:


Found a solution, by adding the following to MathJaxconfiguration:

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

thus increasing to 100% while default value is only 50 %. Reference is here.



来源:https://stackoverflow.com/questions/44851460/converting-mathjax-into-pdf-with-wkhtmltopdf-yields-too-small-maths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!