10

I'm very interested in using the Java LaTeX Report library, but one of the requirements is an installed or portable LaTeX distribution. My software would be running on various servers and it would not be possible to install any software (only uploading a .war file).

Is there any LaTex distribution that runs from a java .jar?

edit: or can you think of a way round my problem?

  • It's been a while since I scrubbed bytecodes, but by the looks of them (and I might be terribly wrong), JLR relies on the first occurrence of the pdflatex program found in the system path. A .war file deployed into a servlet container has a very limited scope and, even if we could find out a batteries-included pure Java implementation of TeX and friends, we would end up with both system and JVM restrictions. :( I know it's heartbreaking, but maybe LaTeX isn't the best option for you right now, since the server is not under your control. I'd take a look at JasperReports or BIRT. – Paulo Cereda Mar 29 '13 at 10:36

2 Answers2

5

I have been there and here I share with you some ideas which may not be the answer to your question but might be helpful for the work you want to do.

Sometimes ago I developed a java application and for the report generator, I wanted to use LaTeX to achieve some very beautiful reports. While trying to achieve my goal I found some tools (some are java archives and some aren't):

  1. New Typesetting System (NTS) is a reimplementation of the typesetting system TeX in Java.
  2. JLR by NIXO SOFT as you have also mentioned in your question.
  3. For math only there is jLaTeXMath which is a fork of jMathTex.
  4. In this StackOverflow question, you can find some suggestions.
  5. Here they explain how to run tex on JVM. Have a look at it.

The problem is, none of the solutions above worked me (However at that time I was not aware of the NTS). What I did at the end, was to create my own mini-latex-distribution consisting binaries and packages that I needed for my reports and deployed it with my java application. Sadly, depending on the type of report you want to generate, this mini-distribution might ended up being several hundred megabytes. I'm afraid I don't know (and I'm not sure if exists) any solution which solely rely on java archives (jar).

Pouya
  • 7,269
3

I'm one of the authors of LaTeX Render Server, which might be used as a starting point. It's just some small REST service, which is accepting raw latex code and will return a url representing a pdf file of the processed output (generated with pdflatex). The output is stored on the file system. The urls are bascically immutable and could be embedded into some webpage/application. It's necessary to use some reverse proxy (nginx/httpd) in front of it for authentication/authorization and failover/scaling purposes.

The library could also be used to embed the renderer with an application, but you'll still need a native installation of LaTeX on the system.

  • You assume that there's an internet connection, don't you? That may not be given. – TeXnician May 14 '17 at 14:43
  • 1
    It's also possible to run the server locally, although it's probably not a desirable solution and it's also adding some overhead.

    In this case it's easier to use the renderer directly and reference the created files. See SynchronousLatexRendererIT as an example.

    LaTeX has to be installed locally in both cases.

    – Alexander Pilch May 18 '17 at 17:13
  • Well, do you see the caveat? The OP explicitly said that it's impossible to install some software and it shall be really portable. – TeXnician May 18 '17 at 17:16
  • 1
    The workaround would be to split the application into a rendering part (hosted on some independent server) and the client/webapp (deployment on restricted server), which is just using/referencing the service. – Alexander Pilch May 18 '17 at 17:19
  • And what about real portability without dependence on a internet connection? – TeXnician May 18 '17 at 17:45
  • 1
    The author was also asking for alternative solutions to this issue. I wouldn't have mentioned it otherwise. I guess there's no 100% java solution to that issue. The mentioned "run latex on jvm" solution won't be that compatible, compared to the real thing. It might work for most of the cases, but you'll most likely run into some unresolved issues. I'd never consider the java only solution as production ready. Just use some official distribution in order to save time, as the LaTeX environment is pretty large and complex. Most existing solutions are based on a wrapper, which is running some – Alexander Pilch May 19 '17 at 01:26
  • 1
    native executables. The NIXO SOFt Library doesn't state its license clearly, so it's not sure if you're allowed to integrate it within some commercial product. So in the end, people start implementing another wrapper like we did. At the time when we started the project, we didn't find a wrapper which was written in java. We didn't want to start mixing different programming languages. – Alexander Pilch May 19 '17 at 01:26