HTML with MathJax content => PDF, client-side only #1
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
brad/writing#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Final goal: CTRL+P => triggers download of PDF
Problem: I am unable to render PDF for a page containing MathJax
Related: http://stackoverflow.com/questions/42785850/render-mathjax-into-pdf, http://stackoverflow.com/questions/27706956/render-svg-to-pdf-using-jspdf
Any idea @Purush0th ?
Hi @josephernest
I tried different work around to export LaTex/Tex based TypeSettings. But current client side libs doesn't support these.
So one way is to output the mathematical expressions in SVG, Canvas or HTML/CSS format.
Mathjax.js supports the following output rendering format.
From MathJax Docs
Here SVG format uses foreignobject and it's not getting exported by SVG to canvas libraries.
Finally I tried HTML & CSS /Common HTML with html2canvas.js. It works but the quality of the output image is poor.
Check this fiddle here.
https://jsfiddle.net/Purushoth/0L9jf0gk/
You can check and see to improve this quality (or) try some other methods.
Good luck!!
I got another idea,
Lets get the content of input panel in text format and before exporting process the content and generate the PDF by code.
a. If it's a formula like
$$x^2+1$$then use MathJax to render it in a hidden canvas and get the image. After add this image to the jsPDF doc.b. If it's a text add the text using
@Purush0th : about your 2nd post: good idea !
Instead of
2. Use Regex, can't we parse all the MathJax content with "class" or something like that? (probably each rendered MathJax is a<span class="mathjax"or similar?)Would you have a jsfiddle or a github fork showing this idea? This looks promising! Thanks in advance :)
@Purush0th : about your 1st post and this jsfiddle : isn't it possible to use SVG instead of PNG to keep the "vector" type instead of bitmap? Because with PNG here the output has quite bad quality.