XpsDocument.Close Método

Definição

Fecha o Package do documento XPS.Closes the XPS document Package.

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

Exemplos

O exemplo a seguir mostra como abrir, inserir conteúdo e fechar um XpsDocument.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

O exemplo a seguir também mostra como abrir, gravar e fechar um XpsDocument.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;

Comentários

Se o XpsDocument tiver sido aberto para acesso de gravação, os buffers de dados serão gravados no repositório e o documento físico Package será fechado.If the XpsDocument was opened for write access, data buffers are written to the store and the physical document Package is closed.

Depois que Close for chamado, nenhuma parte do documento poderá ser acessada com essa instância de XpsDocument.After Close has been called, no parts of the document can be accessed with this XpsDocument instance.

Aplica-se a