C#/VB.NET: Convert Word to XPS

2022-08-05 06:45:00 Written by  daisy zhang
Rate this item
(0 votes)

XPS (XML Paper Specification) is a fixed-layout document format designed to preserve document fidelity and provide device-independent document appearance. It is similar to PDF, but is based on XML rather than PostScript. If you want to save a Word document to a fixed-layout file format, XPS would be an option. This article will demonstrate how to convert Word documents to XPS in C# and VB.NET using Spire.Doc for .NET.

Install Spire.Doc for .NET

To begin with, you need to add the DLL files included in the Spire.Doc for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Doc

Convert Word to XPS in C# and VB.NET

The following are the detailed steps to convert a Word document to XPS using Spire.Doc for .NET:

  • Initialize an instance of Document class.
  • Load a Word document using Document.LoadFromFile() method.
  • Save the Word document to XPS using Document.SaveToFile(string filePath, FileFormat fileFormat) method.
  • C#
  • VB.NET
using Spire.Doc;
namespace ConvertWordToXps
    class Program
        static void Main(string[] args)
            //Create a Document instance
            Document doc = new Document();
            //Load a Word document
            //convert the document to XPS
            doc.SaveToFile("ToXPS.xps", FileFormat.XPS);

C#/VB.NET: Convert Word to XPS

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Additional Info

  • tutorial_title:
Last modified on Wednesday, 31 May 2023 08:50