XpsDocument.Close 方法

定义

关闭 XPS 文档 Package

public:
 void Close();
public void Close ();
member this.Close : unit -> unit
Public Sub Close ()

示例

以下示例演示如何打开、插入内容和关闭内容 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

调用后 Close ,无法使用此 XpsDocument 实例访问文档的各个部分。

适用于