LaTeX Document Conversion in C#

LaTeX is a powerful typesetting system widely used by academics, scientists, and professionals. In LaTeX, we can create well formatted documents in the TEX or LTX formats. It provides a high levels of control over formatting and layout. However, as a markup language, LaTeX documents need to be converted into other formats to be easily shared and viewed. In this article, we will dive deep into LaTeX document conversion in C#. So, without further ado, let’s get started!

This article will cover the following topics:

LaTeX Document Conversion API for C#

While LaTeX documents are incredibly useful, they are not universally accessible. To share these documents with others, you need to convert them into more common formats such as PDF, HTML, or an image. This is where the LaTeX document conversion API comes into play.

Aspose provides a dedicated Aspose.TeX for .NET API to work with LaTeX documents. It is designed specifically for converting LaTeX documents to other formats such as XPS, PDF, PNG, JPEG, TIFF, and BMP using C#. It provides a simple, programmable interface for LaTeX document conversion into other formats, enabling seamless integration with your .NET applications.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.TeX

LaTeX Document Conversion to Image in C#

We can easily convert LaTeX document to an image by following the steps below:

  1. Create an instance of the TeXOptions class using the ConsoleAppOptions() method.
  2. Specify typesetting TeX configuration as TeXConfig.ObjectLaTeX.
  3. Set the file system working directory for the output.
  4. Optionally, specify console or memory stream as an output terminal.
  5. After that, initialize specific image save options for saving in desired format.
  6. Finally, call the Run() method for the newly created TexJob class and save the output image with the ImageDevice class object.

The following code example shows how to convert a LaTeX document to a PNG image using C#.

You can read the complete tutorials on converting:

Convert LaTeX Document to PDF in C#

Similarly, we can convert a LaTeX document to a PDF by following the steps below:

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

The following code example shows how to convert a LaTeX document to a PDF document in C#.

Please read our complete tutorial on converting:

C# Document Conversion – Free License

You can get a free temporary license to try the library without evaluation limitations.

LaTeX Document Conversion in C# – Useful Resources

You can learn more about viewing, converting, and merging LaTeX document and explore other features of the library using the resources given below:

Conclusion

In this article, we have explored the LaTeX document conversion API for C#. We’ve discussed how to convert LaTeX documents to images or PDF programmatically in C#. By following this guide, you will be able to integrate LaTeX document conversion API into your applications seamlessly. In case of any ambiguity, please contact us on our free support forum.

See Also