XpsDocumentWriter.Write Method

Definition

Overloads

Write(Visual, PrintTicket)

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

Write(FixedPage, PrintTicket)

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

Write(FixedDocumentSequence, PrintTicket)

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

Write(FixedDocument, PrintTicket)

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

Write(String, XpsDocumentNotificationLevel)

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

Write(DocumentPaginator, PrintTicket)

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

Write(FixedPage)

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

Write(FixedDocumentSequence)

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

Write(FixedDocument)

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

Write(DocumentPaginator)

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

Write(String)

Synchronously writes a specified XPS document to the target XpsDocument or PrintQueue.

Write(Visual)

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

Write(Visual, PrintTicket)

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

C#
public override void Write(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.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(FixedPage, PrintTicket)

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

C#
public override void Write(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.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(FixedDocumentSequence, PrintTicket)

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

C#
public override void Write(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.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(FixedDocument, PrintTicket)

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

C#
public override void Write(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.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(String, XpsDocumentNotificationLevel)

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

C#
public void Write(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 serializedXPS 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 (XPS) is removed. The reserialization will also remove 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 Write method does not call the WritingPrintTicketRequired event.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(DocumentPaginator, PrintTicket)

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

C#
public override void Write(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 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.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(FixedPage)

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

C#
public override void Write(System.Windows.Documents.FixedPage fixedPage);

Parameters

fixedPage
FixedPage

A page that is written to the XpsDocument.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(FixedDocumentSequence)

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

C#
public override void Write(System.Windows.Documents.FixedDocumentSequence fixedDocumentSequence);

Parameters

fixedDocumentSequence
FixedDocumentSequence

A set of documents that is written to the XpsDocument.

Examples

The following example shows how to use the Write method to write a sequence of XPS documents.

C#
private void SaveMultipleFixedContentDocuments(
             XpsDocumentWriter xpsdw, FixedDocumentSequence fds)
{
    // Write the FixedDocumentSequence as a collection of documents
    xpsdw.Write(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.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(FixedDocument)

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

C#
public override void Write(System.Windows.Documents.FixedDocument fixedDocument);

Parameters

fixedDocument
FixedDocument

A document that is written to the XpsDocument.

Examples

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

C#
private void SaveSingleFixedContentDocument(
             XpsDocumentWriter xpsdw, FixedDocument fd)
{
    xpsdw.Write(fd);        // Write the FixedDocument as a 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.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(DocumentPaginator)

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

C#
public override void Write(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 the Write method to write to an XPS document.

C#
private void SaveSingleFlowContentDocument(
             XpsDocumentWriter xpsdw, DocumentPaginator docPaginator)
{
    xpsdw.Write(docPaginator); // Write the DocPaginator as a document.
}

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(String)

Synchronously writes a specified XPS document to the target XpsDocument or PrintQueue.

C#
public void Write(string documentPath);

Parameters

documentPath
String

The path of the source document.

Remarks

Although the XpsDocumentWriter class has a singular name, an XpsDocumentWriter 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 XpsDocumentWriter or PrintQueue.

This Write method reserializes the specified XPS document, which removes all content from the Package that isn't 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 Write method does not raise the WritingPrintTicketRequired event.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10

Write(Visual)

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

C#
public override void Write(System.Windows.Media.Visual visual);

Parameters

visual
Visual

The Visual that is written.

Examples

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

C#
private void SaveVisual(XpsDocumentWriter xpsdw, Visual v)
{
    xpsdw.Write(v); // Write visual to single page
}

Remarks

To batch write a Visual, use VisualsToXpsDocument.

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.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, 10