Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 29, 2021 19:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aspose-com-gists/40e8f14be490f4edc3d8854f824459e4 to your computer and use it in GitHub Desktop.
Convert LaTeX TeX LTX File to PNG JPG Image Programmatically in C# .NET
// Load the input LTX or TEX file
byte[] bytes = File.ReadAllBytes("helloworld.ltx");
Stream stream = new MemoryStream(bytes);
// Create conversion options for Object LaTeX format on Object TeX engine extension.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);
// Specify the file system working directory for the output.
options.OutputWorkingDirectory = new OutputFileSystemDirectory(dataDir);
// Initialize the options for saving in JPG format.
options.SaveOptions = new JpegSaveOptions();
// Run LaTeX to JPG conversion.
new TeXJob(stream, new ImageDevice(), options).Run();
// Load the input LTX or TEX file
byte[] bytes = File.ReadAllBytes("helloworld.ltx");
Stream stream = new MemoryStream(bytes);
// Create conversion options for Object LaTeX format on Object TeX engine extension.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectLaTeX);
// Specify the file system working directory for the output.
options.OutputWorkingDirectory = new OutputFileSystemDirectory(dataDir);
// Initialize PngSaveOptions for saving image in PNG format.
options.SaveOptions = new PngSaveOptions();
// Run LaTeX to PNG conversion.
new TeXJob(stream, new ImageDevice(), options).Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment