TeX files are used for typesetting different documents and books containing text, symbols, and arithmetic expressions. In addition, these files can generate outputs like PDF, XPS, and various image formats. In this article, you will learn how to convert TeX files to XPS and PDF format using C++.
- C++ API for Converting TeX to PDF and XPS Format
- Convert TeX to XPS Format using C++
- Converting TeX to PDF Format using C++
- Convert TeX ZIP directory to PDF ZIP Directory using C++
C++ API for Converting TeX to PDF and XPS Format
Aspose.TeX for C++ is a C++ library for working with TeX files without requiring any additional software to be installed. The API allows you to typeset TeX files and generate output in formats like XPS, PDF, PNG, JPEG, TIFF, BMP. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.TeX.Cpp
Convert TeX to XPS Format using C++
You can convert TeX files to XPS format in just a few lines of code. To achieve this, please follow the steps given below.
- Create an instance of the TeXOptions class using the TeXConfig::ObjectTeX(System::SharedPtr<Aspose::TeX::ResourceProviders::FormatProvider> formatProvider = nullptr) member function.
- Specify the input and output working directories.
- Specify console or memory stream as an output terminal.
- Save the output XPS file using the TeX::Typeset(System::String path, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method with an instance of the XpsDevice class.
The following sample code demonstrates how to convert a TeX file to XPS format using C++.
Converting TeX to PDF Format using C++
The following are the steps to convert TeX files to PDF format.
- Create an instance of the TeXOptions class using the TeXConfig::ObjectTeX(System::SharedPtr<Aspose::TeX::ResourceProviders::FormatProvider> formatProvider = nullptr) member function.
- Specify the input and output working directories.
- Specify console or memory stream as an output terminal.
- Pass an instance of the PdfSaveOptions class to the TeXOptions->set_SaveOptions(System::SharedPtr<Aspose::TeX::Presentation::SaveOptions> value) method.
- Save the output PDF file using the TeX::Typeset(System::String path, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method with an instance of the PdfDevice class.
The following sample code shows how to convert a TeX file to PDF format using C++.
Convert TeX ZIP directory to PDF ZIP Directory using C++
In order to convert multiple TeX files to PDF format in one go, you can add the TeX files to a ZIP archive and convert them to zipped PDF files. The following are the steps to achieve this.
- Load the input and output ZIP archives in streams.
- Create an instance of the TeXOptions class using the TeXConfig::ObjectTeX(System::SharedPtr<Aspose::TeX::ResourceProviders::FormatProvider> formatProvider = nullptr) member function.
- Set the input and output working directories.
- Specify console or memory stream as an output terminal.
- Pass an instance of the PdfSaveOptions class to the TeXOptions->set_SaveOptions(System::SharedPtr<Aspose::TeX::Presentation::SaveOptions> value) method.
- Save the zipped output PDF file using the TeX::Typeset(System::String path, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method with an instance of the PdfDevice class.
The following sample code shows how to convert TeX ZIP archive to PDF ZIP archive using C++.
Get a Free License
You can try the API without evaluation limitations by requesting a free temporary license.
Conclusion
In this article, you have learned how to convert TeX files to XPS and PDF format using C++. Furthermore, you have learned how to convert TeX files in a ZIP archive to zipped PDF files. Aspose.TeX for C++ 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 questions, please feel free to reach us on our free support forum.