2017-06-30 39 views
0

通過使用pdfkit-python根據wkhtmltopdf,我設法將MathJax轉換爲pdf。 wkhtmltopdf配置選項如下:將MathJax轉換爲pdf與wkhtmltopdf產量太小的數學

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', 
} 

這允許獲得markdown文本預期大,但數學不按比例調整。

這裏PDF格式的快照獲得:

mathJax to pdf yield tiny maths

其中數學肯定會出現過小。

在這裏,它是如何在瀏覽器中呈現:

enter image description here

就如何解決這個問題,換句話說,獲得數學比例與在PDF輸出markdown文本的任何想法,將大大讚賞。

這裏下面的MathJax配置:

<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> 
+0

試着分享展示問題的最小工作示例。 –

+0

@PeterKrautzberger我已經添加了更多細節,但我不確定我應該多說些什麼。讓我知道。 – mannaia

回答

0

實測值的溶液中,通過加入以下MathJax配置:

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

從而增加至100%,而默認值僅爲50%。參考是here

相關問題