We create technical and scientific documentation using LaTeX in the TEX or LTX formats. A LaTeX file contains various commands to specify the format of the document, including text, symbols, mathematical expressions, and graphics. In certain cases, we may need to render or convert TeX or LTX files into TIFF images programmatically. In this article, we will learn how to convert LaTeX to TIFF using C#.
The following topics shall be covered in this article:
- LaTeX to TIFF Converter – C# API
- Convert LaTeX (TeX) to TIFF in C#
- Convert LaTeX (LTX) to TIFF using C#
LaTeX to TIFF Converter – C# API
For converting LaTeX files into TIFF images, we will be using the Aspose.TeX for .NET API. It allows the typesetting of TeX files and presents TeX input in various graphic formats like XPS, PDF, PNG, JPEG, TIFF, and BMP. Please either download the DLL of the API or install it using NuGet.
PM> Install-Package Aspose.TeX
Convert LaTeX (TeX) to TIFF in C#
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 C#.
LaTeX (LTX) to TIFF using C#
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 C#
Get a Free License
You can evaluate Aspose.TeX for .NET without any limitations by getting a temporary license.
Conclusion
In this article, we have learned how to generate a TIFF image from the LaTeX source files (TeX or LTX) in C#. Besides, you can learn more about Aspose.TeX for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.