Login

Snippets by blizz

Snippet List

Convert LaTeX templates to various output formats

**The code is a bit messy and may include bugs ;-) Anyway, I want to clean it up and add features (see below).** The `process_latex()` function will read the given template, render it with a custom context and convert it into the desired output format by running it through pdflatex. Depending on the `outfile` parameter, the output will either be returned (for a response object) or written to the path specified in `outfile` (useful for `save()` in models which generate static, unique files). **TODO** * Error handling in case pdflatex breaks (non-zero return value) * Optionally returning a HttpResponse with the correct mimetype and Content-Disposition set to attachement and an appropriate filename * RequestContext instead of Context (passing the Context object instead of a dict) **CREDITS** Credits also go to ronny for the names dict :-P

  • template
  • django
  • pdf
  • dvi
  • png
  • latex
  • pdflatex
Read More

blizz has posted 1 snippet.