Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
XpsDocument Class
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
XpsDocument Class

Provides a Package that holds the content of an XPS document.

Namespace:  System.Windows.Xps.Packaging
Assembly:  ReachFramework (in ReachFramework.dll)
Visual Basic (Declaration)
Public Class XpsDocument _
    Inherits XpsPartBase _
    Implements IDisposable
Visual Basic (Usage)
Dim instance As XpsDocument
C#
public class XpsDocument : XpsPartBase, 
    IDisposable
Visual C++
public ref class XpsDocument : public XpsPartBase, 
    IDisposable
JScript
public class XpsDocument extends XpsPartBase implements IDisposable
XAML
You cannot directly create an instance of this class in XAML.

An XpsDocument contains a FixedDocumentSequence that comprises one or more FixedDocument elements.

The XpsDocument constructor is passed a reference to a Package for writing, storing, and reading the content elements of the document.

A new empty XPS Package is created by using the Package constructor.

An existing XPS Package is opened by using the Package..::.Open method.

A FixedDocumentSequence root is added to an empty XPS Package by calling the AddFixedDocumentSequence method.

PrintTicket elements with printer information and control can also be associated with the FixedDocumentSequence, or on individual FixedDocument and FixedPage elements that are stored in the XpsDocument.

For more information about XPS see the XML Paper Specification (XPS) available for download at http://go.microsoft.com/fwlink/?LinkID=65761.

For a list of XPS related example programs, see the following topics:

System..::.Object
  System.Windows.Xps.Packaging..::.XpsPartBase
    System.Windows.Xps.Packaging..::.XpsDocument
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Creating an XPS Document from a WPF FlowDocument      Simon Guest   |   Edit   |   Show History
Did you know, it's possible to generate an XPS Document from a WPF FlowDocument as follows:

MemoryStream ms = new MemoryStream();
Package _container = Package.Open(ms, FileMode.Create);
using (XpsDocument xpsd = new XpsDocument(_container))
{
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsd);
writer.Write(((IDocumentPaginatorSource)doc).DocumentPaginator);
}
_container.Close();
byte[] xpsDocBytes = ms.ToArray();
ms.Close();

doc is your input FlowDocument. xpsDocBytes is the output, which can be written to filestream and saved to disk.
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker