LaTeX enables us to create technical and scientific documentation. LaTeX files in the TEX or LTX formats contain various commands to specify the format of the document, including text, symbols, mathematical expressions, and graphics. In certain cases, we may need to convert LaTeX output from TEX or LTX files into TIFF images programmatically. In this article, we will learn how to convert LaTeX to TIFF in Java.
The following topics shall be covered in this article:
- Java API to Convert LaTeX to TIFF – Free Download
- Convert LaTeX (TeX) to TIFF in Java
- Convert LaTeX (LTX) to TIFF in Java
Java API to Convert LaTeX to TIFF – Free Download
To convert LaTeX files into TIFF images, we will be using the Aspose.TeX for Java API. We can typeset TeX files and present the input into various other formats such as XPS, PDF, PNG, JPEG, TIFF, and BMP using the API.
The TeXOptions class of the API enables setting or getting TeX file processing options. The available TeX configurations such as ObjectLaTeX, ObjectIniTeX are provided in the TeXConfig class. The objectLaTeX gets the configuration of ObjectTeX engine extension with ObjectLaTeX format preloaded. The TiffSaveOptions class of the API represents options for saving LaTeX to TIFF image. We have the TeXJob class to implement the features of a TeX job using the TeXJob.run() method. This method takes the ImageDevice class object as a parameter. This class implements the interface for outputting text and graphic content to image(s).
Please either download the JAR of the API or add the following pom.xml configuration in a Maven-based Java application.
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>https://repository.aspose.com/repo/</url> </repository>
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-tex</artifactId> <version>22.6</version> </dependency>
Convert LaTeX (TeX) to TIFF in Java
We can create a TIFF image from a LaTeX (TeX) source file by following the steps given below:
- Firstly, create an instance of the TeXOptions class using the consoleAppOptions() method.
- Next, set typesetting TeX configuration as TeXConfig.objectLaTeX.
- Then, set the file system working directory for the output.
- Optionally, specify console or memory stream as an output terminal.
- After that, Initialize TiffSaveOptions for saving in TIFF format.
- Finally, call the run() method for the newly created TexJob class and save the output TIFF with the ImageDevice class object.
The following code example shows how to convert a LaTeX source to a TIFF image output file using Java.
LaTeX (LTX) to TIFF using Java
LaTeX also uses an LTX file extension for typesetting markup tags and properties to define the document structure and content. We can convert LaTeX (LTX) file output to a TIFF image as well by following the steps mentioned earlier. However, we just need to input the source file with the .ltx extension in the last step.
The following code example shows how to convert an LTX source file to a TIFF image using Java
Get a Free License
You can get a free temporary license to try the library without evaluation limitations.
In this article, we have learned how to generate a TIFF image from the LaTeX source files (TeX or LTX) in Java. Besides, you can learn more about Aspose.TeX for Java API using the documentation. In case of any ambiguity, please feel free to contact us on our forum.