How to Render LaTeX to PNG using C++

This interesting topic provides demonstration on how to render LaTeX to PNG using C++. We also call the LaTeX files as .tex files and one may easily render LaTeX to PNG in C++ with simple API properties and methods. One good thing about using this example is that API calls are not dependent on any other application software or third party tools for their execution.

Steps to Render LaTeX to PNG using C++

  1. Install Aspose.Tex.Cpp using NuGet package Manager tool
  2. Include reference to Aspose::TeX, Aspose::TeX::IO and Aspose::TeX::Presentation::Image namespaces
  3. Instantiate TeXOptions Class object for setting configurations
  4. Instantiate PngSaveOptions Class object for saving LaTeX to PNG image
  5. Initialize the ImageDevice for rendering
  6. Use TexJob for rendering LaTeX to PNG image

LaTeX documents are meant for scientific and research purpose that can be used by technical users and contain information in plain text form. In order to export LaTeX to PNG image in C++, we will first create an instance of TeXOptions class for setting configurations involving input directory, output directory and console options. In subsequent steps, we will set PngSaveOptions properties like image resolution. Finally, we will initialize ImageDevice and by using TexJob render LaTeX to PNG image using C++.

Code to Convert LaTeX to PNG in C++

In this topic, we have learnt how C++ create PNG image from LaTeX using simple API calls. If you are interested in learning other features like rendering MPP files then refer to the article on how to convert MPP to XPS using C++.