Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-gists/36b5e72851c49250c8747cab3a94a381 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/36b5e72851c49250c8747cab3a94a381 to your computer and use it in GitHub Desktop.
Read the complete article about converting TeX files to images using C++ by visiting the following link.
https://blog.aspose.com/2021/08/06/convert-tex-files-to-images-using-cpp/
// Create typesetting options for default ObjectTeX format on ObjectTeX engine extension.
System::SharedPtr<TeXOptions> options = TeXOptions::ConsoleAppOptions(TeXConfig::ObjectTeX());
// Specify a file system working directory for input.
options->set_InputWorkingDirectory(System::MakeObject<InputFileSystemDirectory>(u"SourceDirectory"));
// Specify a file system working directory for output.
options->set_OutputWorkingDirectory(System::MakeObject<OutputFileSystemDirectory>(u"OutputDirectory"));
// Specify console as output terminal.
options->set_TerminalOut(System::MakeObject<Aspose::TeX::IO::OutputConsoleTerminal>());
// Default. No need to specify.
// Specify memory stream as output terminal, if you don't want terminal output to be written to console.
//options.TerminalOut = new OutputMemoryTerminal();
// Set the save options
options->set_SaveOptions([&] {
auto tmp_0 = System::MakeObject<BmpSaveOptions>();
tmp_0->set_Resolution(300);
return tmp_0;
}());
// Run typesetting.
Aspose::TeX::TeX::Typeset(u"hello-world", System::MakeObject<ImageDevice>(), options);
// Create typesetting options for default ObjectTeX format on ObjectTeX engine extension.
System::SharedPtr<TeXOptions> options = TeXOptions::ConsoleAppOptions(TeXConfig::ObjectTeX());
// Specify a file system working directory for input.
options->set_InputWorkingDirectory(System::MakeObject<InputFileSystemDirectory>(u"SourceDirectory"));
// Specify a file system working directory for output.
options->set_OutputWorkingDirectory(System::MakeObject<OutputFileSystemDirectory>(u"OutputDirectory"));
// Specify console as output terminal.
options->set_TerminalOut(System::MakeObject<Aspose::TeX::IO::OutputConsoleTerminal>());
// Default. No need to specify.
// Specify memory stream as output terminal, if you don't want terminal output to be written to console.
// options.TerminalOut = new OutputMemoryTerminal();
// Set the save options
options->set_SaveOptions([&] {
auto tmp_0 = System::MakeObject<JpegSaveOptions>();
tmp_0->set_Resolution(300);
return tmp_0;
}());
// Run typesetting.
Aspose::TeX::TeX::Typeset(u"hello-world", System::MakeObject<ImageDevice>(), options);
// Create typesetting options for default ObjectTeX format on ObjectTeX engine extension.
System::SharedPtr<TeXOptions> options = TeXOptions::ConsoleAppOptions(TeXConfig::ObjectTeX());
// Specify a file system working directory for input.
options->set_InputWorkingDirectory(System::MakeObject<InputFileSystemDirectory>(u"SourceDirectory"));
// Specify a file system working directory for output.
options->set_OutputWorkingDirectory(System::MakeObject<OutputFileSystemDirectory>(u"OutputDirectory"));
// Specify console as output terminal.
options->set_TerminalOut(System::MakeObject<Aspose::TeX::IO::OutputConsoleTerminal>());
// Default. No need to specify.
// Specify memory stream as output terminal, if you don't want terminal output to be written to console.
//options.TerminalOut = new OutputMemoryTerminal();
// Set the save options
options->set_SaveOptions([&] {
auto tmp_0 = System::MakeObject<PngSaveOptions>();
tmp_0->set_Resolution(300);
return tmp_0;
}());
// Run typesetting.
Aspose::TeX::TeX::Typeset(u"hello-world", System::MakeObject<ImageDevice>(), options);
// Create typesetting options for default ObjectTeX format on ObjectTeX engine extension.
System::SharedPtr<TeXOptions> options = TeXOptions::ConsoleAppOptions(TeXConfig::ObjectTeX());
// Specify a file system working directory for input.
options->set_InputWorkingDirectory(System::MakeObject<InputFileSystemDirectory>(u"SourceDirectory"));
// Specify a file system working directory for output.
options->set_OutputWorkingDirectory(System::MakeObject<OutputFileSystemDirectory>(u"OutputDirectory"));
// Specify console as output terminal.
options->set_TerminalOut(System::MakeObject<Aspose::TeX::IO::OutputConsoleTerminal>());
// Default. No need to specify.
// Specify memory stream as output terminal, if you don't want terminal output to be written to console.
//options.TerminalOut = new OutputMemoryTerminal();
// Set the save options
options->set_SaveOptions([&] {
auto tmp_0 = System::MakeObject<TiffSaveOptions>();
tmp_0->set_Resolution(300);
return tmp_0;
}());
// Run typesetting.
Aspose::TeX::TeX::Typeset(u"hello-world", System::MakeObject<ImageDevice>(), options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment