Markmin, LaTeX and pdf generation

217 views
Skip to first unread message

peibol

unread,
Jun 20, 2013, 11:53:58 AM6/20/13
to web...@googlegroups.com
Hi all

I'm getting in love with web2py, but I'm just a newcomer, and need some advice. Take into account that I finally want to deploy my app on GAE (so I can't install pdflatex for example).

1- I have configured my views to use mathjax (in the head section). Is it the right way to proceed with markmin? Cause mathjax is cooler than the google api that produces images...

2- I want to produce a pdf with some math formulas. I've managed to create a pdf in this way, but I don't know how to render the latex...:


def fractions1topdf():  
    html=markmin2html('\( \cfrac{1}{3} + \cfrac{3}{4} = \)')
    class MyFPDF(FPDF, HTMLMixin):
        pass
    pdf=MyFPDF()    
    pdf.add_page() 
    pdf.set_font('Arial','B',16)    
    pdf.write_html(html) 
    response.headers['Content-Type']='application/pdf' 
    return pdf.output(dest='S') 

Thanks!!!

Massimo Di Pierro

unread,
Jun 20, 2013, 12:59:44 PM6/20/13
to web...@googlegroups.com
Why not use markmin2latex or markmin2pdf (itsuses latex inside)

peibol

unread,
Jun 20, 2013, 1:04:18 PM6/20/13
to web...@googlegroups.com
Does it requires pdflatex, doesn't it? I think it's not supported in GAE.

Massimo Di Pierro

unread,
Jun 20, 2013, 5:00:25 PM6/20/13
to web...@googlegroups.com
You are right. No latex on GAE. I cannot think of any other way to render formulas in PDF without latex.

peibol

unread,
Jun 20, 2013, 5:35:04 PM6/20/13
to web...@googlegroups.com
Could it be feasible to use mathjax to render the latex to be put inside the pdf? Or the google api to generates the image and then add it to the pdf?

Thanks Massimo

Massimo Di Pierro

unread,
Jun 21, 2013, 3:08:09 AM6/21/13
to web...@googlegroups.com
mathjax is not an option because it is JS and cannont be embedded in PDF. You can, in principle, generate images using google and and embed those. The alignment and font sizes will be a nightmare.

peibol

unread,
Jun 21, 2013, 11:33:41 AM6/21/13
to web...@googlegroups.com
Yes, I've tested it with the google chart api and it works. I plan to use it with a template for pypdf to minimize alignment issues.
Although it would be better if we could just "render" the html produced by mathajax (or similar) but server side and then use it.
Reply all
Reply to author
Forward
0 new messages