You can read all the details at: Convert TeX (LaTeX) to PDF or XPS File Programmatically using C#
Last active
December 23, 2021 07:08
-
-
Save aspose-com-gists/b6ff8a0d32ac7353678b69d23db6e8c6 to your computer and use it in GitHub Desktop.
Convert TeX (LaTeX) to PDF or XPS File Programmatically using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = @"D:\test\"; | |
// Create typesetting options for default ObjectTeX format. | |
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX()); | |
// Specify a file system working directory for input. | |
options.InputWorkingDirectory = new InputFileSystemDirectory(dataDir); | |
// Specify a file system working directory for output. | |
options.OutputWorkingDirectory = new OutputFileSystemDirectory(dataDir); | |
// Specify memory stream as output terminal. | |
options.TerminalOut = new OutputMemoryTerminal(); | |
// Set options for rendering into PDF format. | |
options.SaveOptions = new PdfSaveOptions(); | |
// Run typesetting. | |
new TeXJob("hello-world", new PdfDevice(), options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = @"D:\test\"; | |
// Create typesetting options for default ObjectTeX format on ObjectTeX engine extension. | |
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX()); | |
// Specify a file system working directory for input. | |
options.InputWorkingDirectory = new InputFileSystemDirectory(dataDir); | |
// Specify a file system working directory for output. | |
options.OutputWorkingDirectory = new OutputFileSystemDirectory(dataDir); | |
// Specify console as output terminal. | |
options.TerminalOut = new OutputConsoleTerminal(); | |
// Run Typesetting | |
new TeXJob("hello-world", new XpsDevice(), options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = @"D:\test\"; | |
// Open a stream on a ZIP archive that will serve as the input working directory. | |
using (Stream inZipStream = File.Open(Path.Combine(dataDir, "zip-in.zip"), FileMode.Open)) | |
// Open a stream on a ZIP archive that will serve as the output working directory. | |
using (Stream outZipStream = File.Open(Path.Combine(dataDir, "terminal-out-to-zip.zip"), FileMode.Create)) | |
{ | |
// Create typesetting options for default ObjectTeX format on ObjectTeX engine extension. | |
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX()); | |
// Specify the job name. | |
options.JobName = "terminal-output-to-zip"; | |
// Specify a ZIP archive working directory for input. | |
options.InputWorkingDirectory = new InputZipDirectory(inZipStream, "in"); | |
// Specify a ZIP archive working directory for output. | |
options.OutputWorkingDirectory = new OutputZipDirectory(outZipStream); | |
// Specify that the terminal output must be written to a file in the output working directory. | |
options.TerminalOut = new OutputFileTerminal(options.OutputWorkingDirectory); | |
// Create and specify saving options. | |
options.SaveOptions = new PdfSaveOptions(); | |
// Run typesetting. | |
new TeXJob("hello-world", new PdfDevice(), options); | |
// Finalize output ZIP archive. | |
((OutputZipDirectory)options.OutputWorkingDirectory).Finish(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment