Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SerializerWriter.Write Method

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

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Write(DocumentPaginator) When overridden in a derived class, synchronously writes the content of a given DocumentPaginator to the serialization Stream.
Public method Write(FixedDocument) When overridden in a derived class, synchronously writes a given FixedDocument to the serialization Stream.
Public method Write(FixedDocumentSequence) When overridden in a derived class, synchronously writes a given FixedDocumentSequence to the serialization Stream.
Public method Write(FixedPage) When overridden in a derived class, synchronously writes a given FixedPage to the serialization Stream.
Public method Write(Visual) When overridden in a derived class, synchronously writes a given Visual element to the serialization Stream.
Public method Write(DocumentPaginator, PrintTicket) When overridden in a derived class, synchronously writes paginated content together with an associated PrintTicket to the serialization Stream.
Public method Write(FixedDocument, PrintTicket) When overridden in a derived class, synchronously writes a given FixedDocument together with an associated PrintTicket to the serialization Stream.
Public method Write(FixedDocumentSequence, PrintTicket) When overridden in a derived class, synchronously writes a given FixedDocumentSequence together with an associated PrintTicket to the serialization Stream.
Public method Write(FixedPage, PrintTicket) When overridden in a derived class, synchronously writes a given FixedPage together with an associated PrintTicket to the serialization Stream.
Public method Write(Visual, PrintTicket) When overridden in a derived class, synchronously writes a given Visual element together with an associated PrintTicket to the serialization Stream.
Top

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

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;
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.