XpsDocument Constructors

Definition

Initializes a new instance of the XpsDocument class.

Overloads

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.

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.

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.

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.

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.

Examples

The following example shows how to create and close an XpsDocument.

C#
// Create an XpsDocument package (without PrintTicket).
using (Package package = Package.Open(packageName))
{
    XpsDocument xpsDocument = new XpsDocument(package);

    // Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, false);

    // Close the package.
    xpsDocument.Close();
}

The following example also shows how to create and close an XpsDocument.

C#
// Save as a WordXML document.
WordXmlSerializer.SaveToFile(fileName, flowDocument.ContentStart, flowDocument.ContentEnd);
return true;

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.

C#
public XpsDocument(System.IO.Packaging.Package package);

Parameters

package
Package

The target XPS package for the XpsDocument.

Examples

The following example shows how to create and close an XpsDocument.

C#
// Create an XpsDocument package (without PrintTicket).
using (Package package = Package.Open(packageName))
{
    XpsDocument xpsDocument = new XpsDocument(package);

    // Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, false);

    // Close the package.
    xpsDocument.Close();
}

The following example also shows how to create and close an XpsDocument.

C#
// Save as a WordXML document.
WordXmlSerializer.SaveToFile(fileName, flowDocument.ContentStart, flowDocument.ContentEnd);
return true;

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

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.

C#
public XpsDocument(System.IO.Packaging.Package package, System.IO.Packaging.CompressionOption compressionOption);

Parameters

package
Package

The target package for the XpsDocument.

compressionOption
CompressionOption

The package compression option.

Examples

The following example shows how to create and close an XpsDocument.

C#
// Create an XpsDocument package (without PrintTicket).
using (Package package = Package.Open(packageName))
{
    XpsDocument xpsDocument = new XpsDocument(package);

    // Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, false);

    // Close the package.
    xpsDocument.Close();
}

The following example also shows how to create and close an XpsDocument.

C#
// Save as a WordXML document.
WordXmlSerializer.SaveToFile(fileName, flowDocument.ContentStart, flowDocument.ContentEnd);
return true;

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

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.

C#
public XpsDocument(string path, System.IO.FileAccess packageAccess);

Parameters

path
String

The path and file name of the target Package for the XpsDocument.

packageAccess
FileAccess

The file I/O mode in which to open the XpsDocument.

Examples

The following example shows how to create and close an XpsDocument.

C#
// Create an XpsDocument package (without PrintTicket).
using (Package package = Package.Open(packageName))
{
    XpsDocument xpsDocument = new XpsDocument(package);

    // Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, false);

    // Close the package.
    xpsDocument.Close();
}

The following example also shows how to create and close an XpsDocument.

C#
// Save as a WordXML document.
WordXmlSerializer.SaveToFile(fileName, flowDocument.ContentStart, flowDocument.ContentEnd);
return true;

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

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.

C#
public XpsDocument(System.IO.Packaging.Package package, System.IO.Packaging.CompressionOption compressionOption, string path);

Parameters

package
Package

The target package for the XpsDocument.

compressionOption
CompressionOption

The package compression option.

path
String

The uniform resource identifier (URI) for the document as a string.

Examples

The following example shows how to create and close an XpsDocument.

C#
// Create an XpsDocument package (without PrintTicket).
using (Package package = Package.Open(packageName))
{
    XpsDocument xpsDocument = new XpsDocument(package);

    // Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, false);

    // Close the package.
    xpsDocument.Close();
}

The following example also shows how to create and close an XpsDocument.

C#
// Save as a WordXML document.
WordXmlSerializer.SaveToFile(fileName, flowDocument.ContentStart, flowDocument.ContentEnd);
return true;

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

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.

C#
public XpsDocument(string path, System.IO.FileAccess packageAccess, System.IO.Packaging.CompressionOption compressionOption);

Parameters

path
String

The path and file name of the target Package for the XpsDocument.

packageAccess
FileAccess

The file I/O mode in which to open the XpsDocument.

compressionOption
CompressionOption

The package compression option.

Examples

The following example shows how to create and close an XpsDocument.

C#
// Create an XpsDocument package (without PrintTicket).
using (Package package = Package.Open(packageName))
{
    XpsDocument xpsDocument = new XpsDocument(package);

    // Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, false);

    // Close the package.
    xpsDocument.Close();
}

The following example also shows how to create and close an XpsDocument.

C#
// Save as a WordXML document.
WordXmlSerializer.SaveToFile(fileName, flowDocument.ContentStart, flowDocument.ContentEnd);
return true;

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10