TeX is a typesetting system that has been noted as one of the most sophisticated digital typographical systems. TeX is used for typesetting documents and generating outputs like PDF, XPS, and different image formats. There might be situations where you need to design a bunch of documents uniformly. For that, creating a custom TeX format will prove to be helpful. To that end, this article will teach you how to create a custom TeX format and typeset it to PDF and XPS formats using C++.
- C++ API for Creating Custom TeX Format and Typesetting it to PDF and XPS
- Create a Custom TeX Format using C++
- Typeset Custom TeX Format to XPS Format
- Typeset Custom TeX Format to PDF Format
C++ API for Creating Custom TeX Format and Typesetting it to PDF and XPS
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, create custom TeX format, 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
Create a Custom TeX Format using C++
The following are the steps to create a custom TeX format.
- Create an instance of the TeXOptions class using the TeXConfig::get_ObjectIniTeX() property value.
- Specify the input and output working directories.
- Create the format using the TeX::CreateFormat(System::String path, System::SharedPtr<TeXOptions> options) method.
The following sample code demonstrates how to create a custom TeX format using C++.
Typeset Custom TeX Format to XPS Format
The following are the steps for typesetting custom TeX format to XPS format.
- Create an instance of the IWorkingDirectory class to represent the input working directory.
- Load the TeX file using the FormatProvider class.
- Create an instance of the TeXOptions class using the FormatProvider object created previously.
- Set the JobName, InputWorkingDirectory, and OutputWorkingDirectory.
- Use the Typeset(System::SharedPtr<System::IO::Stream> stream, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method and pass XpsDevice object as an argument to create the XPS output.
The following is the sample code to typeset a custom TeX format to XPS format.
Typeset Custom TeX Format to PDF Format
The following are the steps for typesetting custom TeX format to PDF format.
- Create an instance of the IWorkingDirectory class to represent the input working directory.
- Load the TeX file using the FormatProvider class.
- Create an instance of the TeXOptions class using the FormatProvider object created previously.
- Set the JobName, InputWorkingDirectory, and OutputWorkingDirectory.
- Create an instance of the PdfSaveOptions class and pass it to TeXOptions->set_SaveOptions(System::SharedPtr<Aspose::TeX::Presentation::SaveOptions> value) method.
- Use the Typeset(System::SharedPtr<System::IO::Stream> stream, System::SharedPtr<Presentation::Device> device, System::SharedPtr<TeXOptions> options) method and pass PdfDevice object as an argument to create the PDF output.
The following sample code shows how to typeset a custom TeX format to PDF format.
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 create a custom TeX format using C++. Furthermore, you have learned how to typeset a custom TeX format to PDF and XPS formats using Aspose.TeX for C++ API. 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.