Steps to Render LaTeX to PNG in C#
- Install Aspose.TeX for .NET package from NuGet.org
- Include Aspose.TeX, Aspose.TeX.IO, and Aspose.TeX.Presentation.Image namespaces
- Apply license to Aspose.TeX for .NET using SetLicense method
- Create TeXOptions object with TeXConfig settings
- Set input and output working directory to read and save files
- Set TerminalOutput option to OutputFileTerminal
- Create PngSaveOptions object and set properties
- Create ImageDevice object to be passed to Typeset method
- Run typesetting operation using Typesetting method
The above steps will help convert TeX to PNG in C# easily. The input TeX file will be read from the working directory specified in the options and the output PNG files will be placed in the output working directory.
Code to Render LaTeX to PNG in C#
The code snippet shown above makes it clear how to render TeX to PNG in C# in a few steps. As we’re saving the output to the file system, so instead of console output terminal, we have specified file terminal as our output terminal.
Using this tutorial, you can easily build your own LaTeX renderer for C# and .NET applications.