What is the easiest way to convert a string of Latex (e.g. "Consider the polynomial $x^2$") into a pdf within a Python web app? Ideally, this wouldn't require the creation of intermediate files that I would have to store in a database.
I tried downloading Texcaller (http://vog.github.io/texcaller/) but I could not get it to work. In particular, the key file python/texcaller.py has the line "import _texcaller" which gives the error "No module named _texcaller."
I'm thinking that there must be some way to do it because the Texer resource at AoPS (http://www.artofproblemsolving.com/Resources/texer.php) renders Tex as PDF almost instantaneously.
Thank you very much in advance!
I've recently written a library for the purpose of generating LaTeX code using python. It supports tables, plots, matrices and more. https://github.com/JelteF/PyLaTeX
Related
So I am generating reports with Python and Ninja in the ASCIIDoc format.
But from within my app I need to convert them into PDF and upload them to another system.
I have seen that there are multiple HowTo for command line that involve ASCIIDoctor or other tools, but they always are invoked at OS level by starting a program or running a docker container and writing the output to a file.
Isn't there a way to perform those action within my app and get the PDF as a string that I can use for the upload?
You can certainly use the available tools to generate a PDF, which you could then read into memory as an opaque string that could be uploaded as needed.
If your question is: how do I generate and upload a PDF without installing any other tools?
Then the answer is that you'd have to implement the PDF generation logic yourself, rather than using tested tooling.
I have a requirement involving making a large pptx file with loads of charts, images and tables dynamic. This pptx has default styles. Is there any library or method to make a template so that I can insert the dynamic parts. Like docxtpl library allows us to input a dict and generate a docx file.
Thanks.
You can try the following python modules:
https://pypi.org/project/template-pptx-jinja/
https://pypi.org/project/pptx-template-simple/
https://pypi.org/project/python-pptx-templater/
With the first one, the example they show, it works fine, but im having trouble applying it in another custom ppt.. keep getting "Unepexpected end of template".
The third one didint work for me though, maybe you have more luck.. and now i will try the second one.
I'm not sure I understand your problem...
python-pptx (a tag you've used) is the fundamental programmable way to build a presentation - whether from a "template presentation or not.)
I hope nobody will mind me advertising my md2pptx open source project for taking Markdown and images and making a presentation.
However, I think md2pptx doesn't help you unless you have a way of turning graphs into eg PNG files - and I suspect that's not what you want.
The scenario is I have to create a pfd file which will have the 3d model in it using python. For 3d model I have .u3d file. I did a bit of searching and could only find some theoretical proofs that it could be done via some libraries like pyLatex, texcaller....but I have not found any snippet which does the same [using a .u3d file and creating a pdf from it].
I am new to python.
Thankyou in advance
I'm not sure what the reason is for using Python, but you can simply use Latex, and the movie15 package.
In your header:
\usepackage{movie15}
In the document body:
\includemovie[poster=figs/my3dmodel.png]{7cm}{6cm}{models/my3dmodel.u3d}
Though movie15 appears deprecated, I found it works well for embedding MP4 or U3d. An alternative is the movie9 package, which did not work for me.
If you have to use Python, you can use the PyLaTeX package, and extend it yourself with a Movie15 context.
See this example: https://github.com/JelteF/PyLaTeX/blob/master/examples/own_commands_ex.py
I have a script I have written in python which pulls data from a bunch of files on my computer which change daily. I want to insert the results into a latex template so that I can review the summary.
What is the best way to open a file and insert text into it at a specific point?
Preferably using a python, but I'm open to other tools if there is something better.
Thanks
Russ
You could also do it all from within python using the pylatex library.
https://github.com/JelteF/PyLaTeX
This way you only have to run the python file every day.
I figured out how to do it.
It seems to me the best way is to have python output low level latex code, then use latex's command \input to pull that code into a larger document.
https://en.wikibooks.org/wiki/LaTeX/Modular_Documents
We have a project in python with django.
We need to generate complex word, excel and pdf files.
For the rest of our projects which were done in PHP we used PHPexcel ,
PHPWord and tcpdf for PDF.
What libraries for python would you recommend for creating this kind of files ? (for excel and word its imortant to use the open xml file format xlsx , docx)
Python-docx may help ( https://github.com/mikemaccana/python-docx ).
Python doesn't have highly-developed tools to manipulate word documents. I've found the java library xdocreport ( https://code.google.com/p/xdocreport/ ) to be the best by far for Word reporting. Because I need to generate PCL, which is efficiently done via FOP I also use docx4j.
To integrate this with my python, I use the spark framework to wrap it up with a simple web service, and use requests on the python side to talk to the service.
For excel, there's openpyxl, which actually is a python port of PHPexcel, afaik. I haven't used it yet, but it sounds ok to me.
I would recommend using Docutils. It takes reStructuredText files and converts them to a range of output files. Included in the package are HTML, LaTeX and .odf file writers but in the sandbox there are a whole load of other writers for writing to other formats, see for example, the WordML writer (disclaimer: I haven't used it).
The advantage of this solution is that you can write plain text (reStructuredText) master files, which are human readable as is, and then convert to a range of other file formats as required.
Whilst not a Python solution, you should also look at Pandoc a Haskell library which supports a much wider range of output and input formats than docutils. One major advantage of Pandoc over Docutils is that you can do the reverse translation, i.e. WordML to reStructuredText. You can try Pandoc here.
I have never used any libraries for this, but you can change the extension of any docx, xlsx file to zip, and see the magic!
Generating openxml files is as simple as generating couple of XML files (you can use templates) and zipping it.
Simplest way to generate PDF is to generate HTML (with CSS+images) and convert it using wkhtmltopdf tool.