LaTeX to PDF

Convert LaTeX documents to PDF using node-latex. Supports standard LaTeX packages and custom document classes.

Overview

This node converts LaTeX documents to PDF format. It supports input as either raw LaTeX text or a LaTeX file from a binary property. Users can specify the LaTeX engine (pdflatex, xelatex, or lualatex), the number of compilation passes, and additional options such as directories for assets and fonts. The node validates the LaTeX content for common issues before compilation and produces a PDF output stored in a specified binary property. This node is useful for automating the generation of PDF documents from LaTeX source in workflows, such as generating reports, academic papers, or formatted documents dynamically.

Use Case Examples

  1. Generating a PDF report from LaTeX source text provided directly in the node.
  2. Converting a LaTeX file uploaded as binary data into a PDF document.
  3. Using custom LaTeX engines and multiple compilation passes for complex documents.
  4. Specifying directories for additional LaTeX assets like images, custom classes, or fonts.

Properties

Name Meaning
Input Type Specifies whether the LaTeX input is provided as text or as a binary file property.
LaTeX Content The raw LaTeX source code to convert to PDF. Used only if Input Type is 'Text'.
Input Binary Property The name of the binary property containing the LaTeX file. Used only if Input Type is 'Binary'.
Output Binary Property Name The name of the binary property where the generated PDF will be stored.
LaTeX Command The LaTeX engine command to use for compilation (pdflatex, xelatex, or lualatex).
Number of Passes Number of compilation passes to run, useful for documents requiring multiple passes.
Additional Options Additional options including paths to directories for LaTeX assets and fonts.

Output

Binary

The node outputs the generated PDF as binary data stored in the specified binary property.

JSON

  • success - Indicates whether the PDF conversion was successful.
  • filename - The filename of the generated PDF.
  • mimeType - The MIME type of the output file, typically 'application/pdf'.
  • fileSize - The size of the generated PDF file in bytes.
  • warnings - Any warnings detected during LaTeX validation, such as missing commands or package issues.
  • error - Error message if the conversion failed.

Dependencies

  • node-latex package for LaTeX compilation
  • File system access for temporary directories

Troubleshooting

  • Common errors include missing LaTeX packages or files (.cls, .sty), which can be resolved by installing required packages or specifying the inputs directory.
  • Undefined control sequence errors usually indicate missing \usepackage declarations or typos in LaTeX commands.
  • The 'adjustwidth' environment error suggests using the 'changepage' package instead of 'adjustwidth'.
  • TeX capacity exceeded errors often result from infinite loops in command definitions or very deep nesting; simplifying the document can help.
  • If LaTeX compilation produces no output, check the LaTeX syntax and required packages.

Links

  • LaTeX Project - Official LaTeX project site for documentation and package information.
  • node-latex NPM Package - The underlying package used for LaTeX to PDF compilation in this node.

Discussion