Typesetting TeX to XPS in .NET

Introduction

Welcome to our step-by-step guide on typesetting TeX to XPS in .NET using the powerful Aspose.TeX library. If you’re looking to seamlessly convert TeX documents to XPS format in your .NET applications, you’ve come to the right place. In this tutorial, we’ll walk you through the entire process, breaking down each step to ensure a smooth implementation.

Prerequisites

Before we dive into the tutorial, make sure you have the following prerequisites in place:

  • Aspose.TeX for .NET: Ensure that you have the Aspose.TeX library installed. You can download it here.

  • Documentation: Familiarize yourself with the library by referring to the documentation here.

  • Input and Output Directories: Set up your input and output directories as specified in the example code.

Now that you have everything set up, let’s proceed with the step-by-step guide.

Import Namespaces

In your .NET application, begin by importing the necessary namespaces. This ensures that you have access to the Aspose.TeX functionalities required for typesetting TeX to XPS.

using Aspose.TeX.IO;
using Aspose.TeX.Presentation.Xps;
using System.IO;

Step 1: Set Conversion Options

Define the conversion options, specifying the ObjectTeX format upon the ObjectTeX engine extension. Also, set the job name, input and output directories, and terminal output details.

// Create conversion options for default ObjectTeX format upon ObjectTeX engine extension.
TeXOptions options = TeXOptions.ConsoleAppOptions(TeXConfig.ObjectTeX());
// Specify a job name.
options.JobName = "external-file-stream";
// Specify a file system working directory for input.
options.InputWorkingDirectory = new InputFileSystemDirectory("Your Input Directory");
// Specify a file system working directory for output.
options.OutputWorkingDirectory = new OutputFileSystemDirectory("Your Output Directory");
// 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);

Step 2: Create XPS Document Stream

Open a stream to write the typeset XPS document. The file name is not necessarily the same as the job name.

using (Stream stream = File.Open(Path.Combine("Your Output Directory", options.JobName + ".xps"), FileMode.Create))

Step 3: Run the TeX Job

Initiate and run the TeX job, specifying the document name, XpsDevice, and conversion options.

new TeXJob("hello-world", new XpsDevice(stream), options).Run();

Congratulations! You’ve successfully typeset TeX to XPS in .NET using Aspose.TeX. Feel free to explore more features and options based on your specific requirements.

Conclusion

In this tutorial, we covered the essential steps to seamlessly convert TeX documents to XPS format in .NET using Aspose.TeX. By following this guide, you’ve gained valuable insights into the library’s capabilities and how to leverage them for your projects.

FAQ’s

Q1: Is Aspose.TeX compatible with .NET Core?

A1: Yes, Aspose.TeX is fully compatible with .NET Core.

Q2: Can I use Aspose.TeX for commercial projects?

A2: Absolutely! Aspose.TeX is available for both commercial and personal use.

Q3: Where can I find additional examples and resources?

A3: Explore the Aspose.TeX documentation here for more examples and detailed resources.

Q4: How can I get support for Aspose.TeX?

A4: Visit the Aspose.TeX support forum here to get assistance from the community.

Q5: Is there a free trial available?

A5: Yes, you can access a free trial here.