XpsDocument Class (System.Windows.Xps.Packaging)

Switch View :
ScriptFree
.NET Framework Class Library
XpsDocument Class

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

Inheritance Hierarchy

System.Object
  System.Windows.Xps.Packaging.XpsPartBase
    System.Windows.Xps.Packaging.XpsDocument

Namespace:  System.Windows.Xps.Packaging
Assembly:  ReachFramework (in ReachFramework.dll)
Syntax

Visual Basic
Public Class XpsDocument _
	Inherits XpsPartBase _
	Implements IDisposable
C#
public class XpsDocument : XpsPartBase, 
	IDisposable
Visual C++
public ref class XpsDocument : public XpsPartBase, 
	IDisposable
F#
type XpsDocument =  
    class
        inherit XpsPartBase
        interface IDisposable
    end

The XpsDocument type exposes the following members.

Constructors

  Name Description
Public method XpsDocument(Package) Initializes a new instance of the XpsDocument class with access to a specified XML Paper Specification (XPS) Package and default interleaving, resource, and compression options.
Public method XpsDocument(Package, CompressionOption) Initializes a new instance of the XpsDocument class that is contained in a specified Package with specified default interleaving, resource, and compression options.
Public method XpsDocument(String, FileAccess) Initializes a new instance of the XpsDocument class that is contained in a specified Package file with default interleaving, resource, and compression options.
Public method XpsDocument(Package, CompressionOption, String) Initializes a new instance of the XpsDocument class that is contained in a specified Package with the specified default interleaving, resource, and compression options.
Public method XpsDocument(String, FileAccess, CompressionOption) Initializes a new instance of the XpsDocument class that is contained in a specified Package file with default interleaving, resource, and compression options.
Top
Properties

  Name Description
Public property CoreDocumentProperties Gets the core PackageProperties of the XPS document.
Public property FixedDocumentSequenceReader Gets an IXpsFixedDocumentSequenceReader for reading the document.
Public property IsReader Gets a value that indicates whether the package is readable.
Public property IsSignable Gets a value that indicates whether the package can be digitally signed.
Public property IsWriter Gets a value that indicates whether the package is writable.
Public property Signatures Gets a collection of XML Paper Specification (XPS) signatures that are associated with the package.
Public property Thumbnail Gets or sets the XML Paper Specification (XPS) thumbnail image that is associated with the document.
Public property Uri Gets or sets the uniform resource identifier (URI) of the part. (Inherited from XpsPartBase.)
Top
Methods

  Name Description
Public method AddFixedDocumentSequence Adds a root FixedDocumentSequence to the package and returns a writer.
Public method AddThumbnail Adds a thumbnail image to the package.
Public method Close Closes the XPS document Package.
Public method Static member CreateXpsDocumentWriter Creates an XpsDocumentWriter for writing an XpsDocument.
Protected method Dispose Releases the unmanaged resources that are used by the XpsDocument and optionally, releases the managed resources.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetFixedDocumentSequence Returns the fixed-document sequence at the root of the package.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method RemoveSignature Deletes a signature from the package.
Public method SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions) Signs a collection of package parts with a specified X.509 certificate.
Public method SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid) Signs a collection of package parts by using a specified X.509 certificate.
Public method SignDigitally(X509Certificate, Boolean, XpsDigSigPartAlteringRestrictions, Guid, Boolean) Signs a collection of package parts with a specified X.509 certificate.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
Explicit Interface Implementations

  Name Description
Explicit interface implemetation Private method IDisposable.Dispose This member supports the Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. Use the type-safe Dispose method instead.
Top
Remarks

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.

Version Information

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Reference

Other Resources

Community Content

Antonio H Lopes
Using a XpsDocument with a DocumentViewer

<Window x:Class="PrintSystem.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xps="clr-namespace:System.Windows.Documents;assembly=PresentationFramework"
        Title="Main Window" Height="350" Width="525"
        Loaded="Window_Loaded">
    <DocumentViewer Name="viewer" />
</Window>
   
Code Behind class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Xps.Packaging;

namespace PrintSystem
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            XpsDocument doc = new XpsDocument("xpsFileName.xps", System.IO.FileAccess.Read);
            viewer.Document = doc.GetFixedDocumentSequence();
        }
    }
}
   
antonio h lopes

Shizuoka