LaTeX is used to prepare documents with high-quality typesetting. The TeX format is used for communicating or publishing technical and scientific documents. In certain cases, you may need to convert TeX files to images like PNG or JPG. In this article, you will learn how to convert TeX files to PNG or JPG images programmatically in Java. Please go through the following sections for more information.
- LTX/TeX to PNG or JPG Converter – Java API Installation
- Convert TeX (LaTeX) to PNG Image in Java
- Convert LaTeX (TeX) to JPG Image Programmatically using Java
LTX/TeX to PNG or JPG Converter – Java API Installation
Aspose.TeX for Java API supports working with LTX, TeX, PNG, JPG, and other supported formats. You can easily configure the API by downloading its JAR file from the Downloads section, or using the following Maven configurations:
<repositories> <repository> <id>snapshots</id> <name>repo</name> <url>http://repository.aspose.com/repo/</url> </repository> </repositories>
<dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-tex</artifactId> <version>21.11</version> </dependency> </dependencies>
Convert TeX (LaTeX) to PNG Image in Java
You can convert an LTX or TeX file to a PNG image with the following steps:
- Load the input LTX or TEX file.
- Create conversion options for LaTeX format with TeXOptions class.
- Initialize PngSaveOptions for saving image in PNG format.
- Run LaTeX to PNG conversion with TexJob class.
The code snippet below explains how to convert TeX to PNG image programmatically in Java:
Convert LTX or TeX to JPG Image using Java
You can convert a LaTeX file with LTX or TEX file extension, to a JPG image with the steps below:
- Load the source LaTeX file.
- Create options using the TeXOptions class object.
- Specify JpegSaveOptions class object.
- Run LaTeX to JPG using the TexJob class.
The following code elaborates how to convert TeX to JPG image programmatically using Java:
Get Free Evaluation License
You can evaluate the API without any limitations by requesting a free temporary license.
In this article, you have learned how to render LaTeX files in TeX or LTX file format to a PNG or JPG image programmatically in Java. Moreover, you can visit the documentation to check several other features of the API. Please feel free to write to us at the forum for any of your inquiries.