Create Custom TeX (LaTeX) Format and Typeset to PDF, XPS in Java

custom tex typeset pdf xps

Many books and journals related to Computer Science, Mathematics, and Engineering are published using TeX. You can create a custom TeX (LaTeX) format and typeset it to different formats like XPS, PDF, or image. Custom TeX is helpful when you need to design many documents in a uniform way. The following sections include further details about creating and typesetting custom TeX format:

Creating and Typesetting Custom TeX (LaTeX) Format – Java API Installation

Aspose.TeX for Java has been designed to programmatically work with TeX files. It does not depend on any 3rd party application so you do not need to install or configure any additional software. Simply download the JAR file from the New Releases section, or install it with 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.4</version>
    </dependency>
</dependencies>

Create a Custom TeX Format Programmatically using Java

Please follow the steps below for creating a custom TeX format:

  1. Create typesetting options for no format on ObjectTeX engine extension.
  2. Specify the file system working directory for input and output.
  3. Run format creation with createFormat() method.

The following code shows how to create custom TeX (LaTeX) format using Java:

Please notice that the code is using objectIniTeX() method which gets the configuration of the Object TeX engine extension with no preloaded format. This lets you create a custom format from scratch.

Typeset or Convert Custom TeX (LaTeX) to PDF Programmatically with Java

You can typeset or convert custom TeX to PDF with the following steps:

  1. Create a file system input and output working directory.
  2. Create a format provider.
  3. Set typesetting options for a custom format on ObjectTeX engine extension.
  4. Initialize PdfSaveOptions class object.
  5. Finally, run typesetting to PDF file with typeset() method.

The following code explains how to typeset or convert custom TeX (LaTeX) to PDF using Java:

Typeset or Convert Custom TeX (LaTeX) to XPS File with Java

You can convert or typeset custom TeX to XPS with below steps:

  1. Create a file system input working directory.
  2. Create a format provider with FormatProvider class.
  3. Set typesetting options for a custom format on ObjectTeX engine extension.
  4. Finally, run typesetting by passing XpsDevice as an argument to typeset() method.

The code below demonstrates how to convert custom TeX to XPS using Java:

Get Free API License

You can test all the features of the API without any limitations by requesting a Free Temporary License.

Conclusion

In this article, you have explored how to create a custom TeX (LaTeX) format programmatically using Java. Moreover, you have also learned how to typeset or convert TeX files to PDF or XPS file format using Java. You can further explore the API Documentation for more details of the API. Please feel free to contact us at the Free Support Forum in case of any queries!

See Also

Convert PUB to PDF Programmatically in Java