XpsDocumentWriter.WriteAsync Method

Definition

Writes asynchronously to the XpsDocument or PrintQueue that created the XpsDocumentWriter.

Overloads

WriteAsync(FixedPage, Object)

Writes asynchronously a specified FixedPage to the target XpsDocument or PrintQueue.

WriteAsync(FixedPage, PrintTicket)

Writes asynchronously a specified FixedPage together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(Visual, Object)

Writes asynchronously a specified Visual to the target XpsDocument or PrintQueue.

WriteAsync(Visual, PrintTicket)

Writes asynchronously a specified Visual together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocumentSequence, PrintTicket, Object)

Writes asynchronously a specified FixedDocumentSequence together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocument, PrintTicket, Object)

Writes asynchronously a specified FixedDocument together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(FixedPage, PrintTicket, Object)

Writes asynchronously a specified FixedPage together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(Visual, PrintTicket, Object)

Writes asynchronously a specified Visual together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocumentSequence, PrintTicket)

Writes asynchronously a specified FixedDocumentSequence together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(DocumentPaginator, PrintTicket, Object)

Writes asynchronously paginated content from a specified DocumentPaginator together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocumentSequence, Object)

Writes asynchronously a specified FixedDocumentSequence to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocumentSequence)

Writes asynchronously a specified FixedDocumentSequence to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocument, Object)

Writes asynchronously a specified FixedDocument to the target XpsDocument or PrintQueue.

WriteAsync(DocumentPaginator, PrintTicket)

Writes asynchronously paginated content from a specified DocumentPaginator together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(DocumentPaginator, Object)

Writes asynchronously paginated content from a specified DocumentPaginator to the target XpsDocument or PrintQueue.

WriteAsync(String, XpsDocumentNotificationLevel)

Writes asynchronously a specified XPS document with notification option to the target XpsDocument or PrintQueue.

WriteAsync(Visual)

Writes asynchronously a specified Visual to the target XpsDocument or PrintQueue.

WriteAsync(FixedPage)

Writes asynchronously a specified FixedPage to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocument)

Writes asynchronously a specified FixedDocument to the target XpsDocument or PrintQueue.

WriteAsync(DocumentPaginator)

Writes asynchronously paginated content from a specified DocumentPaginator to the target XpsDocument or PrintQueue.

WriteAsync(String)

Writes asynchronously a specified XPS document to the target XpsDocument or PrintQueue.

WriteAsync(FixedDocument, PrintTicket)

Writes asynchronously a specified FixedDocument together with a PrintTicket to the target XpsDocument or PrintQueue.

WriteAsync(FixedPage, Object)

Writes asynchronously a specified FixedPage to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedPage fixedPage, object userSuppliedState);

Parameters

fixedPage
FixedPage

The page that is written.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedPage, PrintTicket)

Writes asynchronously a specified FixedPage together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedPage fixedPage, System.Printing.PrintTicket printTicket);

Parameters

fixedPage
FixedPage

The page that is written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the page.

Remarks

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(FixedPage, PrintTicket).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(Visual, Object)

Writes asynchronously a specified Visual to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Media.Visual visual, object userSuppliedState);

Parameters

visual
Visual

The Visual that is written.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

To batch write a Visual, use VisualsToXpsDocument.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(Visual, PrintTicket)

Writes asynchronously a specified Visual together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Media.Visual visual, System.Printing.PrintTicket printTicket);

Parameters

visual
Visual

The Visual that is written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the document.

Remarks

To batch write a Visual, use VisualsToXpsDocument.

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(Visual, PrintTicket).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocumentSequence, PrintTicket, Object)

Writes asynchronously a specified FixedDocumentSequence together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocumentSequence fixedDocumentSequence, System.Printing.PrintTicket printTicket, object userSuppliedState);

Parameters

fixedDocumentSequence
FixedDocumentSequence

The set of documents to be written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the set of documents.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

WriteAsync writes a set of documents asynchronously to the XpsDocument or PrintQueue that created the XpsDocumentWriter. The data that is written includes a PrintTicket and additional information that the caller wants to pass to an event handler.

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument or a set of FixedDocument elements to the existing sequence.

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocument, PrintTicket, Object)

Writes asynchronously a specified FixedDocument together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocument fixedDocument, System.Printing.PrintTicket printTicket, object userSuppliedState);

Parameters

fixedDocument
FixedDocument

The document that is written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the document.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument to the set.

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedPage, PrintTicket, Object)

Writes asynchronously a specified FixedPage together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedPage fixedPage, System.Printing.PrintTicket printTicket, object userSuppliedState);

Parameters

fixedPage
FixedPage

The page that is written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the page.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(Visual, PrintTicket, Object)

Writes asynchronously a specified Visual together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Media.Visual visual, System.Printing.PrintTicket printTicket, object userSuppliedState);

Parameters

visual
Visual

The Visual that is written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the document.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

For writing multiple Visual elements, use VisualsToXpsDocument.

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocumentSequence, PrintTicket)

Writes asynchronously a specified FixedDocumentSequence together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocumentSequence fixedDocumentSequence, System.Printing.PrintTicket printTicket);

Parameters

fixedDocumentSequence
FixedDocumentSequence

The set of documents that are written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the set of documents.

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument or a set of FixedDocument elements to the existing set.

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(FixedDocumentSequence, PrintTicket).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(DocumentPaginator, PrintTicket, Object)

Writes asynchronously paginated content from a specified DocumentPaginator together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.DocumentPaginator documentPaginator, System.Printing.PrintTicket printTicket, object userSuppliedState);

Parameters

documentPaginator
DocumentPaginator

An object that contains a pointer to unpaginated source material; also contains methods for paginating the material.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the material.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocumentSequence, Object)

Writes asynchronously a specified FixedDocumentSequence to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocumentSequence fixedDocumentSequence, object userSuppliedState);

Parameters

fixedDocumentSequence
FixedDocumentSequence

The set of documents that are written.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument or a set of FixedDocument elements to the existing set.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocumentSequence)

Writes asynchronously a specified FixedDocumentSequence to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocumentSequence fixedDocumentSequence);

Parameters

fixedDocumentSequence
FixedDocumentSequence

The set of documents that is written.

Examples

The following example shows how to use this method to write to an XPS document.

private void SaveMultipleFixedContentDocumentsAsync(
             XpsDocumentWriter xpsdw, FixedDocumentSequence fds)
{
    _xpsdwActive = xpsdw;

    xpsdw.WritingCompleted +=
        new WritingCompletedEventHandler(AsyncSaveCompleted);

    xpsdw.WritingProgressChanged +=
        new WritingProgressChangedEventHandler(AsyncSavingProgress);

    // Write the FixedDocumentSequence as a
    // collection of documents asynchronously.
    xpsdw.WriteAsync(fds);
}

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument or a set of FixedDocument elements to the existing set.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(FixedDocumentSequence).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocument, Object)

Writes asynchronously a specified FixedDocument to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocument fixedDocument, object userSuppliedState);

Parameters

fixedDocument
FixedDocument

The document that is written.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument to the set.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(DocumentPaginator, PrintTicket)

Writes asynchronously paginated content from a specified DocumentPaginator together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.DocumentPaginator documentPaginator, System.Printing.PrintTicket printTicket);

Parameters

documentPaginator
DocumentPaginator

An object that contains a pointer to unpaginated source material and also contains methods for paginating the material.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the material.

Remarks

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(DocumentPaginator, PrintTicket).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(DocumentPaginator, Object)

Writes asynchronously paginated content from a specified DocumentPaginator to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.DocumentPaginator documentPaginator, object userSuppliedState);

Parameters

documentPaginator
DocumentPaginator

An object that contains a pointer to unpaginated source material; also contains methods for paginating the material.

userSuppliedState
Object

A user-specified object to identify and associate with the asynchronous operation.

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(String, XpsDocumentNotificationLevel)

Writes asynchronously a specified XPS document with notification option to the target XpsDocument or PrintQueue.

public void WriteAsync (string documentPath, System.Windows.Xps.XpsDocumentNotificationLevel notificationLevel);

Parameters

documentPath
String

The path of the source document.

notificationLevel
XpsDocumentNotificationLevel

An indication of whether notification is enabled.

Remarks

When notificationLevel is disabled, the XpsDocumentWriter copies the serialized XPS document to the target XpsDocument or PrintQueue that created the XpsDocumentWriter. When notificationLevel is enabled, the XpsDocumentWriter first deserializes the document, next reserializes it, and then writes it to the target with progress notifications as each page is output.

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds the FixedDocument elements in the source to the sequence of FixedDocument elements in the target XpsDocument or PrintQueue.

If notificationLevel is specified as ReceiveNotificationEnabled, notifications are produced only when the document is serialized, not printed. To receive notifications, the document must be reserialized. When a document is reserialized, all content from the Package that's not required to be preserved by the XML Paper Specification is removed. The reserialization also removes all extensions from the FixedPage markup, including any extended XPS content.

If notificationLevel is specified as ReceiveNotificationDisabled the document will not be reserialized and any extended content will be preserved, even when printed.

By design this WriteAsync method does not call the WritingPrintTicketRequired event.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(String, XpsDocumentNotificationLevel).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(Visual)

Writes asynchronously a specified Visual to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Media.Visual visual);

Parameters

visual
Visual

The Visual that is written.

Examples

The following example shows how to use this method to write a Visual to an XPS document.

private void SaveVisualAsync(XpsDocumentWriter xpsdw, Visual v)
{
    _xpsdwActive = xpsdw;

    xpsdw.WritingCompleted +=
        new WritingCompletedEventHandler(AsyncSaveCompleted);

    xpsdw.WriteAsync(v);    // Write visual to single page.
}

Remarks

To batch write a Visual, use VisualsToXpsDocument.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(Visual).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedPage)

Writes asynchronously a specified FixedPage to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedPage fixedPage);

Parameters

fixedPage
FixedPage

The page that is written.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(FixedPage).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocument)

Writes asynchronously a specified FixedDocument to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocument fixedDocument);

Parameters

fixedDocument
FixedDocument

The document that is written.

Examples

The following example shows how to use this method to write to an XPS document.

private void SaveSingleFixedContentDocumentAsync(
             XpsDocumentWriter xpsdw, FixedDocument fd)
{
    _xpsdwActive = xpsdw;

    xpsdw.WritingCompleted +=
        new WritingCompletedEventHandler(AsyncSaveCompleted);

    // Write the FixedDocument as a document.
    xpsdw.WriteAsync(fd);
}

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument to the set.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(FixedDocument).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(DocumentPaginator)

Writes asynchronously paginated content from a specified DocumentPaginator to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.DocumentPaginator documentPaginator);

Parameters

documentPaginator
DocumentPaginator

An object that contains a pointer to unpaginated source material and also contains methods for paginating the material.

Examples

The following example shows how to use this method to write to an XPS document.

private void SaveSingleFlowContentDocumentAsync(
             XpsDocumentWriter xpsdw, DocumentPaginator idp)
{
    _xpsdwActive = xpsdw;

    xpsdw.WritingCompleted +=
        new WritingCompletedEventHandler(AsyncSaveCompleted);

    // Write the IDP as a document.
    xpsdw.WriteAsync(idp);
}

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(DocumentPaginator).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(String)

Writes asynchronously a specified XPS document to the target XpsDocument or PrintQueue.

public void WriteAsync (string documentPath);

Parameters

documentPath
String

The path of the source document.

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds the FixedDocument elements in the source to the set of FixedDocument elements in the target XpsDocument or PrintQueue.

This WriteAsync method reserializes the specified XPS document, which removes all content from the Package that's not required to be preserved by the XML Paper Specification. The reserialization also removes all extensions from the FixedPage markup, including any extended XPS content.

By design, this WriteAsync method does not call the WritingPrintTicketRequired event.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(String).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

WriteAsync(FixedDocument, PrintTicket)

Writes asynchronously a specified FixedDocument together with a PrintTicket to the target XpsDocument or PrintQueue.

public override void WriteAsync (System.Windows.Documents.FixedDocument fixedDocument, System.Printing.PrintTicket printTicket);

Parameters

fixedDocument
FixedDocument

The document that is written.

printTicket
PrintTicket

A PrintTicket that represents the default printing preferences for the document.

Remarks

Although the XpsDocument class has a singular name, an XpsDocument can be one FixedDocument or a set of multiple documents. This method adds a FixedDocument to the set.

This method does not validate or modify the specified printTicket for a particular PrintQueue. If necessary, use the MergeAndValidatePrintTicket method to create a PrintTicket that is specific to the PrintQueue and is valid for a specified printer.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Write(FixedDocument, PrintTicket).

Applies to

.NET Framework 4.8.1 en andere versies
Product Versies
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9