This project is providing a simple integration of LaTeX with java. Velocity templates are compiled to valid LaTeX code and the result is fed to the external pdflatex process.
- latex-template: to be used by clients to create a valid tex file, basically just a wrapper of velocity.
- latex-server: simple REST frontend to render latex snippets
- latex-renderer: to be used by server/local client to process the generated tex files (created by the template) in order to convert LaTeX code into pdfs
- Velocity tex template is processed and results are returned as String
- Renderer creates a temp file containing the tex input and renders the pdf in the same directory
- Renderer is archiving the pdf output and the tex input file in a separate archive directory
- Install MiKTeX on windows / TexLive on Linux and make sure the
pdflatex
executable is available via system path (e.g. by executing it on the command line). - Browse to
src/test/resources/META-INF
and compile thesample.tex
file by executingpdflatex sample.tex
. MiKTeX will try to download the missing packages off the internet. You might have to install them manually in TexLive by using tlmgr. - See
LatexTemplateIT
/SynchronousLatexRendererIT
to get started in your project.
Install missing TexLive packages
- change to user latex
- run
tlmgr init-usertree
, if this is the first time - run
tlmgr install <package>
to install the missing package
- Generating a pdf: send post request with tex body to base url. The response will contain a uuid, which is used to retrieve the pdf. Status code will be accepted(202).
- Retrieving a pdf: send get request to base url, e.g. http://renderer/65891272-fbd6-44fe-8152-dc4ea8e1901b. If it's not available yet, the service will return a 404 status code. If it was already created, the pdf file will be returned.
- The server status url is /admin/index.html. Jolokia(jmx remoting) and dropwizard metrics have been integrated.
- Deploy it in a loadbalanced setup on multiple servers
- Our installation is using GlusterFS as backend storage of the archive folder, so the pdfs will be distributed and available on all members of the cluster. Each job output is stored in a subdirectory named by its uuid. The tex template and the pdf will be stored there for debugging purposes.
- LaTeX is single threaded, so the render jobs are submitted to a thread pool, which is sized to use the number of physical cpus as a limit to parallel threads (default value).
- The whole tex template is submitted in the post request, so it's currently not possible to include external resources (e.g. images), because those won't be found/available on the render server. Use pdfinlimg to inline small images (e.g. company logos) and supply them within the tex document.
- Currenly pdflatex is run multiple times to create the pdf. BibTeX or other external tools aren't executed as part of this build. If you need that, it's probably easier to switch to Latexmk instead of pdflatex to render files