Aspose.Page XPS Converter for .NET

Aspose.Page XPS Converter for .NET enables developers to seamlessly transform XPS documents into universally compatible PDFs and a range of popular image formats such as JPEG, TIFF, PNG, BMP, and GIF. Whether generating print-ready PDFs or raster images for web and mobile publishing, this plugin offers fine-grained control over output quality, compression, color profiles, and metadata—all through a straightforward .NET API.

System Requirements

  • Microsoft Windows, Linux, or macOS with .NET Framework or .NET Core.
  • Compatible with Visual Studio, JetBrains Rider, MonoDevelop, and VS Code.
  • Supports .NET Standard 2.0/2.1 and .NET 5+.

Installation and Setup

To get started, install Aspose.Page for .NET via NuGet:

Aspose.Page.Metered metered = new Aspose.Page.Metered();
metered.SetMeteredKey("PublicKey", "PrivateKey");

Features and Functionalities

XPS to PDF Conversion

  • Convert XPS pages into high-fidelity PDFs.
  • Control page sizing, margins, and scaling.
  • Embed or subset fonts automatically.
  • Add metadata (author, title, keywords).
  • Apply encryption, password protection, and user permissions.

XPS to Image Conversion

  • Export to JPEG, PNG, TIFF, BMP, GIF, EMF.
  • Adjust resolution (DPI), color depth, and compression.
  • Create multi-page TIFFs with compression (CCITT, LZW).
  • Preserve transparency for supported formats.

Stream-Based Processing

  • Read input directly from file, memory, or network streams.
  • Write output to streams for integration with web apps.
  • Support for asynchronous I/O in high-throughput scenarios.

Format-Specific Options

  • PDF: set compliance (PDF/A), flatten transparency, configure fonts.
  • TIFF: choose compression (LZW, CCITT Group 4).
  • JPEG: control chroma subsampling and quality.
  • PNG: adjust zlib compression and transparency.

Performance and Resource Management

  • Batch conversion across multiple documents.
  • Parallel processing with multi-threading.
  • Caching for repeated page renders.
  • Built-in disposal of unmanaged resources.

Error Handling and Logging

  • Detailed exception messages with page and parameter context.
  • Input validation for corrupted or unsupported XPS files.
  • Event hooks for progress reporting and performance metrics.

Example: Convert XPS to PDF

using Aspose.Page.XPS;
using Aspose.Page.XPS.Presentation.Pdf;

// Load XPS document
XpsDocument xpsDoc = new XpsDocument("input.xps");

// Create PDF save options
PdfSaveOptions options = new PdfSaveOptions();
options.Compliance = PdfCompliance.PdfA_1b;

// Save as PDF
xpsDoc.Save("output.pdf", options);

Example: Convert XPS to PNG

using Aspose.Page.XPS;
using Aspose.Page.XPS.Presentation.Image;

XpsDocument xpsDoc = new XpsDocument("input.xps");

ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Png);
options.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

xpsDoc.Save("output.png", options);

Tips and Best Practices

  • Validate XPS input before conversion to reduce failures.
  • Align DPI and color space settings with target medium (screen vs. print).
  • Use stream-based APIs for serverless/containerized deployments.
  • Reuse converter instances for large-scale services.
  • Dispose of objects in using blocks to release resources.
  • Test PDF/A outputs with validators for compliance.
 English