XpsDocument 构造函数

定义

初始化 XpsDocument 类的新实例。

重载

XpsDocument(Package)

通过访问指定的 XML 纸张规范 (XPS) Package 和使用默认的隔行扫描、资源及压缩选项来初始化 XpsDocument 类的新实例。

XpsDocument(Package, CompressionOption)

用指定的默认隔行扫描、资源和压缩选项初始化指定 XpsDocument 中包含的 Package 类的新实例。

XpsDocument(String, FileAccess)

用默认的隔行扫描、资源和压缩选项初始化指定的 XpsDocument 文件中包含的 Package 类的新实例。

XpsDocument(Package, CompressionOption, String)

用指定的默认隔行扫描、资源和压缩选项初始化指定 XpsDocument 中包含的 Package 类的新实例。

XpsDocument(String, FileAccess, CompressionOption)

用默认的隔行扫描、资源和压缩选项初始化指定的 XpsDocument 文件中包含的 Package 类的新实例。

示例

以下示例演示如何创建和关闭 XpsDocument

// Create an XpsDocument package (without PrintTicket).
{
   Package^ package = Package::Open(packageName);
   try
   {
      XpsDocument^ xpsDocument = gcnew XpsDocument(package);

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

      // Close the package.
      xpsDocument->Close();
   } finally
   {
      delete package;
   }
// 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();
}
' Create an XpsDocument package (without PrintTicket).
Using package1 As Package = Package.Open(packageName)
    Dim xpsDocument As New XpsDocument(package1)

    ' Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, False)

    ' Close the package.
    xpsDocument.Close()
End Using

以下示例还演示如何创建和关闭 XpsDocument

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

XpsDocument(Package)

通过访问指定的 XML 纸张规范 (XPS) Package 和使用默认的隔行扫描、资源及压缩选项来初始化 XpsDocument 类的新实例。

public:
 XpsDocument(System::IO::Packaging::Package ^ package);
public XpsDocument (System.IO.Packaging.Package package);
new System.Windows.Xps.Packaging.XpsDocument : System.IO.Packaging.Package -> System.Windows.Xps.Packaging.XpsDocument
Public Sub New (package As Package)

参数

package
Package

XpsDocument 的目标 XPS 包。

示例

以下示例演示如何创建和关闭 XpsDocument

// Create an XpsDocument package (without PrintTicket).
{
   Package^ package = Package::Open(packageName);
   try
   {
      XpsDocument^ xpsDocument = gcnew XpsDocument(package);

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

      // Close the package.
      xpsDocument->Close();
   } finally
   {
      delete package;
   }
// 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();
}
' Create an XpsDocument package (without PrintTicket).
Using package1 As Package = Package.Open(packageName)
    Dim xpsDocument As New XpsDocument(package1)

    ' Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, False)

    ' Close the package.
    xpsDocument.Close()
End Using

以下示例还演示如何创建和关闭 XpsDocument

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

适用于

XpsDocument(Package, CompressionOption)

用指定的默认隔行扫描、资源和压缩选项初始化指定 XpsDocument 中包含的 Package 类的新实例。

public:
 XpsDocument(System::IO::Packaging::Package ^ package, System::IO::Packaging::CompressionOption compressionOption);
public XpsDocument (System.IO.Packaging.Package package, System.IO.Packaging.CompressionOption compressionOption);
new System.Windows.Xps.Packaging.XpsDocument : System.IO.Packaging.Package * System.IO.Packaging.CompressionOption -> System.Windows.Xps.Packaging.XpsDocument
Public Sub New (package As Package, compressionOption As CompressionOption)

参数

package
Package

XpsDocument 的目标包。

compressionOption
CompressionOption

包压缩选项。

示例

以下示例演示如何创建和关闭 XpsDocument

// Create an XpsDocument package (without PrintTicket).
{
   Package^ package = Package::Open(packageName);
   try
   {
      XpsDocument^ xpsDocument = gcnew XpsDocument(package);

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

      // Close the package.
      xpsDocument->Close();
   } finally
   {
      delete package;
   }
// 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();
}
' Create an XpsDocument package (without PrintTicket).
Using package1 As Package = Package.Open(packageName)
    Dim xpsDocument As New XpsDocument(package1)

    ' Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, False)

    ' Close the package.
    xpsDocument.Close()
End Using

以下示例还演示如何创建和关闭 XpsDocument

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

适用于

XpsDocument(String, FileAccess)

用默认的隔行扫描、资源和压缩选项初始化指定的 XpsDocument 文件中包含的 Package 类的新实例。

public:
 XpsDocument(System::String ^ path, System::IO::FileAccess packageAccess);
public XpsDocument (string path, System.IO.FileAccess packageAccess);
new System.Windows.Xps.Packaging.XpsDocument : string * System.IO.FileAccess -> System.Windows.Xps.Packaging.XpsDocument
Public Sub New (path As String, packageAccess As FileAccess)

参数

path
String

Package 的目标 XpsDocument 的路径和文件名。

packageAccess
FileAccess

用于打开 XpsDocument 的文件 I/O 模式。

示例

以下示例演示如何创建和关闭 XpsDocument

// Create an XpsDocument package (without PrintTicket).
{
   Package^ package = Package::Open(packageName);
   try
   {
      XpsDocument^ xpsDocument = gcnew XpsDocument(package);

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

      // Close the package.
      xpsDocument->Close();
   } finally
   {
      delete package;
   }
// 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();
}
' Create an XpsDocument package (without PrintTicket).
Using package1 As Package = Package.Open(packageName)
    Dim xpsDocument As New XpsDocument(package1)

    ' Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, False)

    ' Close the package.
    xpsDocument.Close()
End Using

以下示例还演示如何创建和关闭 XpsDocument

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

适用于

XpsDocument(Package, CompressionOption, String)

用指定的默认隔行扫描、资源和压缩选项初始化指定 XpsDocument 中包含的 Package 类的新实例。

public:
 XpsDocument(System::IO::Packaging::Package ^ package, System::IO::Packaging::CompressionOption compressionOption, System::String ^ path);
public XpsDocument (System.IO.Packaging.Package package, System.IO.Packaging.CompressionOption compressionOption, string path);
new System.Windows.Xps.Packaging.XpsDocument : System.IO.Packaging.Package * System.IO.Packaging.CompressionOption * string -> System.Windows.Xps.Packaging.XpsDocument
Public Sub New (package As Package, compressionOption As CompressionOption, path As String)

参数

package
Package

XpsDocument 的目标包。

compressionOption
CompressionOption

包压缩选项。

path
String

字符串形式的文档的统一资源标识符 (URI)。

示例

以下示例演示如何创建和关闭 XpsDocument

// Create an XpsDocument package (without PrintTicket).
{
   Package^ package = Package::Open(packageName);
   try
   {
      XpsDocument^ xpsDocument = gcnew XpsDocument(package);

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

      // Close the package.
      xpsDocument->Close();
   } finally
   {
      delete package;
   }
// 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();
}
' Create an XpsDocument package (without PrintTicket).
Using package1 As Package = Package.Open(packageName)
    Dim xpsDocument As New XpsDocument(package1)

    ' Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, False)

    ' Close the package.
    xpsDocument.Close()
End Using

以下示例还演示如何创建和关闭 XpsDocument

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

适用于

XpsDocument(String, FileAccess, CompressionOption)

用默认的隔行扫描、资源和压缩选项初始化指定的 XpsDocument 文件中包含的 Package 类的新实例。

public:
 XpsDocument(System::String ^ path, System::IO::FileAccess packageAccess, System::IO::Packaging::CompressionOption compressionOption);
public XpsDocument (string path, System.IO.FileAccess packageAccess, System.IO.Packaging.CompressionOption compressionOption);
new System.Windows.Xps.Packaging.XpsDocument : string * System.IO.FileAccess * System.IO.Packaging.CompressionOption -> System.Windows.Xps.Packaging.XpsDocument
Public Sub New (path As String, packageAccess As FileAccess, compressionOption As CompressionOption)

参数

path
String

Package 的目标 XpsDocument 的路径和文件名。

packageAccess
FileAccess

用于打开 XpsDocument 的文件 I/O 模式。

compressionOption
CompressionOption

包压缩选项。

示例

以下示例演示如何创建和关闭 XpsDocument

// Create an XpsDocument package (without PrintTicket).
{
   Package^ package = Package::Open(packageName);
   try
   {
      XpsDocument^ xpsDocument = gcnew XpsDocument(package);

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

      // Close the package.
      xpsDocument->Close();
   } finally
   {
      delete package;
   }
// 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();
}
' Create an XpsDocument package (without PrintTicket).
Using package1 As Package = Package.Open(packageName)
    Dim xpsDocument As New XpsDocument(package1)

    ' Add the package content (false=without PrintTicket).
    AddPackageContent(xpsDocument, False)

    ' Close the package.
    xpsDocument.Close()
End Using

以下示例还演示如何创建和关闭 XpsDocument

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

适用于