TeX is a typesetting system that has been noted as one of the most sophisticated digital typographical systems. TeX files are used for typesetting different documents and books containing text, symbols, and arithmetic expressions. Furthermore, these files can generate output in PNG, JPEG, TIFF, and BMP image formats. In this article, you will learn how to convert TeX files to images using C++.
- C++ API for Converting TeX Files to Images
- Convert TeX Files to JPG Images using C++
- Converting TeX Files to PNG Images using C++
- Convert TeX Files to TIFF Images using C++
- Converting TeX Files to BMP Images using C++
C++ API for Converting TeX Files to Images
Aspose.TeX for C++ is a C++ library for working with TeX files without installing any additional software. The API allows you to typeset TeX files and generate output in PNG, JPEG, TIFF, and BMP image formats. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.TeX.Cpp
Convert TeX Files to JPG Images using C++
The following are the steps to convert TeX files to JPG images.
- Create an instance of the TeXOptions class using the TeXOptions::ConsoleAppOptions(System::SharedPtr<TeXConfig> config) method.
- Specify the input and output working directories.
- Specify console or memory stream as an output terminal.
- Set the save options to the instance of the JpegSaveOptions class.
- Save the output JPG image using the TeX::Typeset(System::String path, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method with an instance of the ImageDevice class.
The following sample code shows how to convert a TeX file to a JPG image using C++.
Converting TeX Files to PNG Images using C++
In order to convert TeX Files to PNG images, follow the steps given below.
- Create an instance of the TeXOptions class using the TeXOptions::ConsoleAppOptions(System::SharedPtr<TeXConfig> config) method.
- Specify the input and output working directories.
- Specify console or memory stream as an output terminal.
- Set the save options to the instance of the PngSaveOptions class.
- Save the output PNG image using the TeX::Typeset(System::String path, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method with an instance of the ImageDevice class.
The following sample code demonstrates how to convert a TeX file to a PNG image using C++.
Convert TeX Files to TIFF Images using C++
The following are the steps to convert TeX Files to TIFF images using C++.
- Create an instance of the TeXOptions class using the TeXOptions::ConsoleAppOptions(System::SharedPtr<TeXConfig> config) method.
- Specify the input and output working directories.
- Specify console or memory stream as an output terminal.
- Set the save options to the instance of the TiffSaveOptions class.
- Save the output TIFF image using the TeX::Typeset(System::String path, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method with an instance of the ImageDevice class.
The following sample code shows how to convert a TeX file to a TIFF image using C++.
Converting TeX Files to BMP Images using C++
The following are the steps to convert TeX files to BMP images using C++.
- Create an instance of the TeXOptions class using the TeXOptions::ConsoleAppOptions(System::SharedPtr<TeXConfig> config) method.
- Specify the input and output working directories.
- Specify console or memory stream as an output terminal.
- Set the save options to the instance of the BmpSaveOptions class.
- Save the output BMP image using the TeX::Typeset(System::String path, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method with an instance of the ImageDevice class.
The following sample code shows how to convert a TeX file to a BMP image using C++.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to convert TeX files to images using C++. Specifically, you have learned how to convert TeX files to JPG, PNG, TIFF, and BMP image formats using Aspose.TeX for C++ API. The API provides many additional features for working with TeX files. You can explore the API in detail by visiting the official documentation. In case of any queries, please feel free to reach us at our free support forum.