Converting Word to XPS in C#

About XPS

The XML Paper Specification(XPS) specifies a set of document layout functionality for paged, printable documents. Like Adobe System's PDF format, XPS is a fixed-layout document designed to preserve document fidelity, providing device-independent document appearance.

Converting Word to XPS

A conversion that many of our customers have requested is DOC/DOCX to XPS in.NET: converting a Word document to an XPS file. Spire.Doc for .NET allows you to convert Word(Doc/Docx) to XPS. You can convert word document using the method of spire.doc assembly.

[C#]
using System;
using System.Collections.Generic;
using System.Text;
using Spire.Doc;
namespace Doc_to_xps
{
    class Program
    {
        static void Main(string[] args)
        {
             //doc file
            String file = "doc to xpsdoc.docx";
            //open doc document
            Document doc = new Document(file);
            //convert to xps file.
            doc.SaveToFile("doc to xpsSample.xps", FileFormat.XPS);
            System.Diagnostics.Process.Start("doc to xpsSample.xps");

        }
    }
}

Viewing the following C# code , firstly Instantiate an object of document and load a doc document by calling the Load File method. Then save this document data as an XPS format.

[C#]
//doc file
String file = "doc to xpsdoc.docx";
//open doc document
Document doc = new Document(file);
//convert to xps file.
doc.SaveToFile("doc to xpsSample.xps", FileFormat.XPS);
System.Diagnostics.Process.Start("doc to xpsSample.xps");

The following screenshot shows the result of converting Word to XPS.