Convert TeX (LaTeX) to PDF or XPS File Programmatically using C#

Convert TeX to PDF XPS

A TeX file may contain text, symbols, or arithmetic expressions. These are used for typesetting the documents and you can typeset TeX input to PDF, XPS, and several other supported formats. In this article, you will be learning how to convert TeX to PDF or XPS files programmatically using C#. The following sections explain the topic in detail:

TeX to PDF or XPS Converter – C# API Installation

Aspose.TeX for .NET API has been designed for typesetting TeX files to different file formats like PDF, XPS, or images. You can quickly configure the API by downloading the DLL file from the Downloads section, or you can install it from NuGet with the following installation command:

PM> Install-Package Aspose.TeX

Convert TeX (LaTeX) to PDF Programmatically using C#

You can convert TeX to PDF file with the steps below:

  1. Create typesetting options for default ObjectTeX format.
  2. Specify console or memory stream as an output terminal.
  3. Set options for rendering into PDF format.
  4. Call Typeset() method and save output PDF with PdfDevice class object.

The following code snippet explains how to convert TeX to PDF file programmatically using C#:

The arguments passed to the Typeset() method are noteworthy here. The first one refers to the path to the input TeX file, the second is Device type while the third one refers to TexOptions.

Convert TeX ZIP directory to PDF ZIP Directory using C#

You may need to convert multiple TeX files to PDF at a time. In such cases, you may convert TeX file in a ZIP archive to PDF document in zipped form. You need to follow the steps below:

  1. Open streams on ZIP archives as the input and output working directory.
  2. Create typesetting options using the TeXOptions class object.
  3. Create and specify saving options with PdfSaveOptions.
  4. Run typesetting with Typeset() method.

The code below elaborates how to convert TeX ZIP archive to PDF ZIP archive programmatically using C#:

Convert TeX (LaTeX) to XPS File Programmatically using C#

You can convert TeX to XPS file with the following steps:

  1. Create typesetting options on ObjectTeX engine extension.
  2. Specify a file system working directory for input and output.
  3. Convert TeX to XPS by running Typesetting with XpsDevice.

The following code shows how to convert TeX file to XPS programmatically using C#:

Get Free API License

You can evaluate the API with full access by requesting a Free Temporary License.


In this article, you have explored how to convert TeX files to PDF or XPS files programmatically using C#. Moreover, you have also learned how to convert a TeX file in a ZIP archive and create an output ZIP directory. You can have a look at several other features by visiting the API Documentation. Please feel free to contact us at the Free Support Forum in case of any concerns.

See Also

Convert XPS or OXPS to PDF Programmatically using C#