Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/0fbd18cd8c28d5ed12e19cd52634ebd4 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/0fbd18cd8c28d5ed12e19cd52634ebd4 to your computer and use it in GitHub Desktop.
Work with file system, ZIP archives, and streams for TeX I/O with .NET

Aspose.TeX for .NET – Working with I/O Examples

These snippets demonstrate input and output concepts in Aspose.TeX for .NET. Learn how to work with directories, ZIP archives, and terminals for flexible TeX document processing.

Key Use Cases

Input Directory

  • Getting file input from the disk file system
  • Getting file input from a ZIP archive

Input Terminal

  • Getting terminal input from the console

Output Directory

  • Writing file output to the disk file system
  • Writing file output to a ZIP archive

Output Terminal

  • Writing terminal output to the console
  • Writing terminal output to a file

How to Run Examples

  1. Reference Aspose.TeX for .NET: Aspose.TeX on Windows; Aspose.TeX.Drawing on non‑Windows.
  2. Copy a snippet into your project.
  3. Apply a temporary license as described in the licensing guide.
  4. Build and run.

Restrictions

In evaluation mode, the output may contain watermarks and limitations. Apply a valid license to unlock full features.

Related Documentation

More about input/output in Aspose.TeX:

Related Resources

Requirements

  • .NET 6.0+, .NET Core, or .NET Framework
  • Aspose.TeX for .NET library

Examples Overview

The Concept of the Input Directory

Since I/O primitives of the TeX language can only deal with file names, Aspose.TeX defines a directory as a mapping between names and bulks of data (files, streams, arrays, etc.).

1. Input File System Directory

Work with file system directories for input. This is the most straightforward approach for desktop applications.

2. Input ZIP Directory

Use ZIP archives as virtual file systems for input. Perfect for packaging TeX documents with all dependencies.

The Concept of the Input Terminal

Aspose.TeX defines the input terminal through the IInputTerminal interface.

3. Input Console Terminal

Get terminal input from the console. This is the default setting for interactive scenarios.

The Concept of the Output Directory

Similar to input, Aspose.TeX defines output directories as mappings for storing generated files.

4. Output File System Directory

Write output files to the disk file system. Most common use case for desktop applications.

5. Output ZIP Directory

Write output files to a ZIP archive. Useful for packaging all output files together.

The Concept of the Output Terminal

Aspose.TeX defines the output terminal through the IOutputTerminal interface.

6. Output Console Terminal

Write terminal output to the console. This is the default setting (arbitrary assignment shown for demonstration).

7. Output File Terminal

Write terminal output to a file. The file is named <job_name>.trm and stored in the output working directory.

Aspose.TeX for .NET – Working with I_O Examples
// Getting terminal input from the console
// Learn more: https://docs.aspose.com/tex/net/aspose-tex-input/
// Create conversion options instance.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// ...
// Specify the console as the input terminal.
options.TerminalIn = new InputConsoleTerminal(); // Default. Arbitrary assignment.
// Getting file input from the disk file system
// Learn more: https://docs.aspose.com/tex/net/aspose-tex-input/
// Create conversion options instance.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// ...
// Specify a file system working directory for the input.
options.InputWorkingDirectory = new InputFileSystemDirectory(DataDir);
// Getting file input from a ZIP archive
// Learn more: https://docs.aspose.com/tex/net/aspose-tex-input/
// Open the stream for the ZIP archive that will serve as the input working directory.
using (Stream inZipStream = File.Open(Path.Combine(DataDir, "zip-in.zip"), FileMode.Open))
{
// Create conversion options instance.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// ...
// Specify a ZIP archive working directory for the input. You can also specify a path inside the archive.
options.InputWorkingDirectory = new InputZipDirectory(inZipStream, "in");
// Writing terminal output to the console
// Learn more: https://docs.aspose.com/tex/net/aspose-tex-output/
// Create conversion options instance.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// ...
// Specify the console as the output terminal.
options.TerminalOut = new OutputConsoleTerminal(); // Default value. Arbitrary assignment.
// Writing file output to the disk file system
// Learn more: https://docs.aspose.com/tex/net/aspose-tex-output/
// Create conversion options instance.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// ...
// Specify a file system working directory for the output.
options.OutputWorkingDirectory = new OutputFileSystemDirectory(OutputDir);
// Writing terminal output to a file
// Learn more: https://docs.aspose.com/tex/net/aspose-tex-output/
// Create conversion options instance.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// ...
// Specify that the terminal output must be written to a file in the output working directory.
// The file name is <job_name>.trm.
options.TerminalOut = new OutputFileTerminal(options.OutputWorkingDirectory);
// Writing file output to a ZIP archive
// Learn more: https://docs.aspose.com/tex/net/aspose-tex-output/
// Open the stream for the ZIP archive that will serve as the output working directory.
using (Stream outZipStream = File.Open(Path.Combine(OutputDir, "zip-pdf-out.zip"), FileMode.Create))
{
// Create conversion options instance.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// ...
// Specify a ZIP archive working directory for the output.
options.OutputWorkingDirectory = new OutputZipDirectory(outZipStream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment