Bewerken

Delen via


XpsDocument.Close Method

Definition

Closes the XPS document Package.

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

Examples

The following example shows how to open, insert content, and close an 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

The following example also shows how to open, write to, and close an XpsDocument.

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

Remarks

If the XpsDocument was opened for write access, data buffers are written to the store and the physical document Package is closed.

After Close has been called, no parts of the document can be accessed with this XpsDocument instance.

Applies to