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#

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:

Repository:

``````<repositories>
<repository>
<id>snapshots</id>
<name>repo</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
</repositories>
``````

Dependency:

``````<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:

1. Load the input LTX or TEX file.
2. Create conversion options for LaTeX format with TeXOptions class.
3. Initialize PngSaveOptions for saving image in PNG format.
4. 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:

1. Load the source LaTeX file.
2. Create options using the TeXOptions class object.
3. Specify JpegSaveOptions class object.
4. Run LaTeX to JPG using the TexJob class.

The following code elaborates how to convert TeX to JPG image programmatically using Java: