Package atessera.comp
Class PdfLatex
java.lang.Object
atessera.comp.PdfLatex
Facade for compiling LaTeX documents to PDF using
pdflatex.
This class encapsulates a three-pass pdflatex pipeline:
- First pass — resolves cross-references.
- Second pass — resolves table of contents and bibliography.
- Third pass — finalises all references and produces the definitive PDF.
All three passes run with --interaction=batchmode to suppress
interactive prompts. The LaTeX source is written as main.tex in
the working directory. Additional text files (e.g. code listings) and
binary files (e.g. images) can be supplied alongside.
After a successful compilation the resulting PDF is available via
getOutput(). On failure the contents of main.log are
available via getLog().
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancompile()Runs the three-passpdflatexpipeline.getLog()Returns the contents ofmain.logafter a failed compilation.byte[]Returns the compiled PDF document.Returns the raw stderr captured from each command in the pipeline.Returns the raw stdout captured from each command in the pipeline.Returns the stack trace if an internal exception occurred during compilation.
-
Constructor Details
-
PdfLatex
public PdfLatex(Compiler compiler, List<String> source, Map<String, byte[]> images, Map<String, List<String>> listings) Constructs a newPdfLatexcompilation facade.- Parameters:
compiler- the underlyingCompilerto use; must not benullsource- the LaTeX source as a list of lines; must not benullimages- binary image files to include; keys are file names, values are raw bytes; must not benulllistings- additional text files (e.g. code listings); keys are file names, values are lists of lines; must not benull
-
-
Method Details
-
compile
public boolean compile()Runs the three-passpdflatexpipeline.- Returns:
trueif all three passes completed successfully and the PDF was produced;falseotherwise- Throws:
IllegalStateException- if the compiler result is inconsistent (e.g. zero exit code but no PDF, or non-zero exit code but no log file)
-
getOutput
public byte[] getOutput()Returns the compiled PDF document.- Returns:
- the PDF as a byte array, or
nullif compilation has not been run or was unsuccessful
-
getLog
Returns the contents ofmain.logafter a failed compilation.- Returns:
- the log file as a list of lines, or
nullif the log was not captured (e.g. because compilation succeeded or has not been run)
-
getRawOutput
Returns the raw stdout captured from each command in the pipeline.- Returns:
- an unmodifiable view of the captured stdout, or
nullbefore compilation
-
getRawErrorOutput
Returns the raw stderr captured from each command in the pipeline.- Returns:
- an unmodifiable view of the captured stderr, or
nullbefore compilation
-
getStackTrace
Returns the stack trace if an internal exception occurred during compilation.- Returns:
- the stack trace as a string, or
nullif no exception was thrown
-