Modifier

Partager via


SerializerWriter.Write Method

Definition

When overridden in a derived class, synchronously writes content to the serialization Stream.

Overloads

Write(Visual, PrintTicket)

When overridden in a derived class, synchronously writes a given Visual element together with an associated PrintTicket to the serialization Stream.

Write(FixedPage, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.

Write(FixedDocument, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.

Write(DocumentPaginator, PrintTicket)

When overridden in a derived class, synchronously writes paginated content together with an associated PrintTicket to the serialization Stream.

Write(FixedDocumentSequence, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.

Write(FixedPage)

When overridden in a derived class, synchronously writes a given FixedPage to the serialization Stream.

Write(FixedDocumentSequence)

When overridden in a derived class, synchronously writes a given FixedDocumentSequence to the serialization Stream.

Write(FixedDocument)

When overridden in a derived class, synchronously writes a given FixedDocument to the serialization Stream.

Write(DocumentPaginator)

When overridden in a derived class, synchronously writes the content of a given DocumentPaginator to the serialization Stream.

Write(Visual)

When overridden in a derived class, synchronously writes a given Visual element to the serialization Stream.

Examples

The following example shows the use of the Write method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

Write(Visual, PrintTicket)

When overridden in a derived class, synchronously writes a given Visual element together with an associated PrintTicket to the serialization Stream.

public:
 abstract void Write(System::Windows::Media::Visual ^ visual, System::Printing::PrintTicket ^ printTicket);
public abstract void Write (System.Windows.Media.Visual visual, System.Printing.PrintTicket printTicket);
abstract member Write : System.Windows.Media.Visual * System.Printing.PrintTicket -> unit
Public MustOverride Sub Write (visual As Visual, printTicket As PrintTicket)

Parameters

visual
Visual

The Visual element to write to the serialization Stream.

printTicket
PrintTicket

The default print preferences for the visual element.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

printTicket can be null if there are no preferred print settings.

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

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(FixedPage, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::FixedPage ^ fixedPage, System::Printing::PrintTicket ^ printTicket);
public abstract void Write (System.Windows.Documents.FixedPage fixedPage, System.Printing.PrintTicket printTicket);
abstract member Write : System.Windows.Documents.FixedPage * System.Printing.PrintTicket -> unit
Public MustOverride Sub Write (fixedPage As FixedPage, printTicket As PrintTicket)

Parameters

fixedPage
FixedPage

The page to write to the serialization Stream.

printTicket
PrintTicket

The default print preferences for the fixedPage content.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

printTicket can be null if there are no preferred print settings.

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

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(FixedDocument, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::FixedDocument ^ fixedDocument, System::Printing::PrintTicket ^ printTicket);
public abstract void Write (System.Windows.Documents.FixedDocument fixedDocument, System.Printing.PrintTicket printTicket);
abstract member Write : System.Windows.Documents.FixedDocument * System.Printing.PrintTicket -> unit
Public MustOverride Sub Write (fixedDocument As FixedDocument, printTicket As PrintTicket)

Parameters

fixedDocument
FixedDocument

The document to write to the serialization Stream.

printTicket
PrintTicket

The default print preferences for the fixedDocument content.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

printTicket can be null if there are no preferred print settings.

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

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(DocumentPaginator, PrintTicket)

When overridden in a derived class, synchronously writes paginated content together with an associated PrintTicket to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::DocumentPaginator ^ documentPaginator, System::Printing::PrintTicket ^ printTicket);
public abstract void Write (System.Windows.Documents.DocumentPaginator documentPaginator, System.Printing.PrintTicket printTicket);
abstract member Write : System.Windows.Documents.DocumentPaginator * System.Printing.PrintTicket -> unit
Public MustOverride Sub Write (documentPaginator As DocumentPaginator, printTicket As PrintTicket)

Parameters

documentPaginator
DocumentPaginator

The document paginator that defines the content to write to the serialization Stream.

printTicket
PrintTicket

The default print preferences for the documentPaginator content.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

printTicket can be null if there are no preferred print settings.

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

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(FixedDocumentSequence, PrintTicket)

When overridden in a derived class, synchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::FixedDocumentSequence ^ fixedDocumentSequence, System::Printing::PrintTicket ^ printTicket);
public abstract void Write (System.Windows.Documents.FixedDocumentSequence fixedDocumentSequence, System.Printing.PrintTicket printTicket);
abstract member Write : System.Windows.Documents.FixedDocumentSequence * System.Printing.PrintTicket -> unit
Public MustOverride Sub Write (fixedDocumentSequence As FixedDocumentSequence, printTicket As PrintTicket)

Parameters

fixedDocumentSequence
FixedDocumentSequence

The document sequence that defines the content to write to the serialization Stream.

printTicket
PrintTicket

The default print preferences for the fixedDocumentSequence content.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

printTicket can be null if there are no preferred print settings.

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

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(FixedPage)

When overridden in a derived class, synchronously writes a given FixedPage to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::FixedPage ^ fixedPage);
public abstract void Write (System.Windows.Documents.FixedPage fixedPage);
abstract member Write : System.Windows.Documents.FixedPage -> unit
Public MustOverride Sub Write (fixedPage As FixedPage)

Parameters

fixedPage
FixedPage

The page to write to the serialization Stream.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(FixedDocumentSequence)

When overridden in a derived class, synchronously writes a given FixedDocumentSequence to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::FixedDocumentSequence ^ fixedDocumentSequence);
public abstract void Write (System.Windows.Documents.FixedDocumentSequence fixedDocumentSequence);
abstract member Write : System.Windows.Documents.FixedDocumentSequence -> unit
Public MustOverride Sub Write (fixedDocumentSequence As FixedDocumentSequence)

Parameters

fixedDocumentSequence
FixedDocumentSequence

The document sequence that defines the content to write to the serialization Stream.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(FixedDocument)

When overridden in a derived class, synchronously writes a given FixedDocument to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::FixedDocument ^ fixedDocument);
public abstract void Write (System.Windows.Documents.FixedDocument fixedDocument);
abstract member Write : System.Windows.Documents.FixedDocument -> unit
Public MustOverride Sub Write (fixedDocument As FixedDocument)

Parameters

fixedDocument
FixedDocument

The document to write to the serialization Stream.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(DocumentPaginator)

When overridden in a derived class, synchronously writes the content of a given DocumentPaginator to the serialization Stream.

public:
 abstract void Write(System::Windows::Documents::DocumentPaginator ^ documentPaginator);
public abstract void Write (System.Windows.Documents.DocumentPaginator documentPaginator);
abstract member Write : System.Windows.Documents.DocumentPaginator -> unit
Public MustOverride Sub Write (documentPaginator As DocumentPaginator)

Parameters

documentPaginator
DocumentPaginator

The document paginator that defines the content to write to the serialization Stream.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to

Write(Visual)

When overridden in a derived class, synchronously writes a given Visual element to the serialization Stream.

public:
 abstract void Write(System::Windows::Media::Visual ^ visual);
public abstract void Write (System.Windows.Media.Visual visual);
abstract member Write : System.Windows.Media.Visual -> unit
Public MustOverride Sub Write (visual As Visual)

Parameters

visual
Visual

The Visual element to write to the serialization Stream.

Examples

The following example shows the use of the Write(DocumentPaginator, PrintTicket) method to serialize a flow document to an output file.

// Create a SerializerProvider for accessing plug-in serializers.
SerializerProvider serializerProvider = new SerializerProvider();

// Locate the serializer that matches the fileName extension.
SerializerDescriptor selectedPlugIn = null;
foreach ( SerializerDescriptor serializerDescriptor in
                serializerProvider.InstalledSerializers )
{
    if ( serializerDescriptor.IsLoadable &&
         fileName.EndsWith(serializerDescriptor.DefaultFileExtension) )
    {   // The plug-in serializer and fileName extensions match.
        selectedPlugIn = serializerDescriptor;
        break; // foreach
    }
}

// If a match for a plug-in serializer was found,
// use it to output and store the document.
if (selectedPlugIn != null)
{
    Stream package = File.Create(fileName);
    SerializerWriter serializerWriter =
        serializerProvider.CreateSerializerWriter(selectedPlugIn,
                                                  package);
    IDocumentPaginatorSource idoc =
        flowDocument as IDocumentPaginatorSource;
    serializerWriter.Write(idoc.DocumentPaginator, null);
    package.Close();
    return true;
}

Remarks

The output Stream of the write operation is normally specified as a parameter to the constructor of the derived class that implements SerializerWriter.

See also

Applies to