简体   繁体   中英

Create a PDF with content as Latex, text and images

I have a database and I want to create a form where a user can submit a query and create a PDF file with the results. The database has Latex and images as content and I cannot use simple libraries for PDF creation, since Latex isn't recognized.

My backend is in Python and I don't have a problem to use a server or cliend side way to do this.

What I have tried until now:

1) Use a Python library for HTML+CSS to PDF, but without MathJax Javascript library to render the Latex, the results is just text without the Latex.

2) Create a temp page with exactly the look I want to PDF has and then using http://pdfcrowd.com/ download the file. But my data is sensitive and also pdfcrowd isn't a free service.

Any other idea, how I could do this?

Edit: I found another way which seems to me the easier one, but I have a problem. I create a temp page with the look of PDF I want, wait the browser to render the Latex and then autorun a Javascript to print the page which give the option to save as PDF. The problem is that even if I add the media="all" in the link of css files, the result is without a css style.

Turning my comment into an anser.

You could have your Python script create a Latex document by pasting the right snippets into a template file, then run pdflatex on the server to create PDF document from this. There would be no HTML step involved in any of this, but since you don't mention HTML as one of your input formats, that should not be a problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM