Skip to content
Advertisement

Java Process executes “pdflatex” successfully but generates empty .pdf file

I want to compile a .tex file from a Java program. I wrote the following code, and it successfully executes, but when I try to open the .pdf file generated, the OS pops a message saying that the file is completely empty (link to image).

By the way, when I run the command pdflatex tarea0.tex directly from terminal, it generates the non-empty .pdf file I want to get from the Java program.

JavaScript

Here is the link to all the files

Advertisement

Answer

You need to wait for the process to conclude. I’m guessing that exiting the JVM before waiting for the process to conclude causes pdflatex to receive a signal causing it to terminate abruptly.

So adding a line:

JavaScript

after the p.start() should have the desired effect.

Advertisement