Export (0) Print
Expand All

IXpsFixedPageWriter.Commit Method

Flushes and closes the fixed-page writer.

Namespace:  System.Windows.Xps.Packaging
Assembly:  ReachFramework (in ReachFramework.dll)

void Commit()

Based on settings of XpsSerializationManager and XpsPackagingPolicy, such as FontSubsetterCommitPolicies and PackageInterleavingOrder, the flush operation of the Commit method may be delayed until the complete XpsDocument is closed.

The following example shows how to flush and close the fixed-page writer with the Commit method.

// ------------------------- AddDocumentContent --------------------------- 
/// <summary> 
///   Adds a predefined set of content to a given document writer.</summary> 
/// <param name="fixedDocumentWriter">
///   The document writer to add the content to.</param> 
private void AddDocumentContent(IXpsFixedDocumentWriter fixedDocumentWriter)
{
    // Collection of image and font resources used on the current page. 
    //   Key: "XpsImage", "XpsFont" 
    //   Value: List of XpsImage or XpsFont resources
    Dictionary<string, List<XpsResource>> resources;

    try
    {
        // Add Page 1 to current document.
        IXpsFixedPageWriter fixedPageWriter =
            fixedDocumentWriter.AddFixedPage();

        // Add the resources for Page 1 and get the resource collection.
        resources = AddPageResources(fixedPageWriter);

        // Write page content for Page 1.
        WritePageContent(fixedPageWriter.XmlWriter,
            "Page 1 of " + fixedDocumentWriter.Uri.ToString(), resources);

        // Commit Page 1.
        fixedPageWriter.Commit();

        // Add Page 2 to current document.
        fixedPageWriter = fixedDocumentWriter.AddFixedPage();

        // Add the resources for Page 2 and get the resource collection.
        resources = AddPageResources(fixedPageWriter);

        // Write page content to Page 2.
        WritePageContent(fixedPageWriter.XmlWriter,
            "Page 2 of " + fixedDocumentWriter.Uri.ToString(), resources);

        // Commit Page 2.
        fixedPageWriter.Commit();
    }
    catch (XpsPackagingException xpsException)
    {
        throw xpsException;
    }
}// end:AddDocumentContent()

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft