SerializerWriter.Write 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在派生类中重写时,将内容同步写入序列化 Stream。
重载
Write(Visual, PrintTicket) |
在派生类中重写时,将给定的 Visual 元素与关联的 PrintTicket 一起同步写入序列化 Stream。 |
Write(FixedPage, PrintTicket) |
在派生类中重写时,将给定的 FixedPage 与关联的 PrintTicket 一起同步写入序列化 Stream。 |
Write(FixedDocument, PrintTicket) |
在派生类中重写时,将给定的 FixedDocument 与关联的 PrintTicket 一起同步写入序列化 Stream。 |
Write(DocumentPaginator, PrintTicket) |
在派生类中重写时,将已分页的内容与关联的 PrintTicket 一起同步写入序列化 Stream。 |
Write(FixedDocumentSequence, PrintTicket) |
在派生类中重写时,将给定的 FixedDocumentSequence 与关联的 PrintTicket 一起同步写入序列化 Stream。 |
Write(FixedPage) | |
Write(FixedDocumentSequence) |
在派生类中重写时,将给定的 FixedDocumentSequence 同步写入序列化 Stream。 |
Write(FixedDocument) |
在派生类中重写时,将给定的 FixedDocument 同步写入序列化 Stream。 |
Write(DocumentPaginator) |
在派生类中重写时,将给定 DocumentPaginator 的内容同步写入序列化 Stream。 |
Write(Visual) |
示例
以下示例演示如何使用 Write 该方法将流文档序列化为输出文件。
// 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;
}
注解
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
Write(Visual, PrintTicket)
在派生类中重写时,将给定的 Visual 元素与关联的 PrintTicket 一起同步写入序列化 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)
参数
- printTicket
- PrintTicket
visual
元素的默认打印首选项。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
printTicket
如果没有首选打印设置,可以 null
。
此方法不会验证或修改 printTicket
给定 PrintQueue的特定项。 如果需要,请使用 PrintQueue.MergeAndValidatePrintTicket 方法创建特定于 PrintQueue 的 PrintTicket(对给定打印机有效)。
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(FixedPage, PrintTicket)
在派生类中重写时,将给定的 FixedPage 与关联的 PrintTicket 一起同步写入序列化 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)
参数
- printTicket
- PrintTicket
fixedPage
内容的默认打印首选项。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
printTicket
如果没有首选打印设置,可以 null
。
此方法不会验证或修改 printTicket
给定 PrintQueue的特定项。 如果需要,请使用 PrintQueue.MergeAndValidatePrintTicket 方法创建特定于 PrintQueue 的 PrintTicket(对给定打印机有效)。
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(FixedDocument, PrintTicket)
在派生类中重写时,将给定的 FixedDocument 与关联的 PrintTicket 一起同步写入序列化 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)
参数
- fixedDocument
- FixedDocument
要写入序列化 Stream 的文档。
- printTicket
- PrintTicket
fixedDocument
内容的默认打印首选项。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
printTicket
如果没有首选打印设置,可以 null
。
此方法不会验证或修改 printTicket
给定 PrintQueue的特定项。 如果需要,请使用 PrintQueue.MergeAndValidatePrintTicket 方法创建特定于 PrintQueue 的 PrintTicket(对给定打印机有效)。
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(DocumentPaginator, PrintTicket)
在派生类中重写时,将已分页的内容与关联的 PrintTicket 一起同步写入序列化 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)
参数
- documentPaginator
- DocumentPaginator
定义写入序列化 Stream 中的内容的文档分页符。
- printTicket
- PrintTicket
documentPaginator
内容的默认打印首选项。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
printTicket
如果没有首选打印设置,可以 null
。
此方法不会验证或修改 printTicket
给定 PrintQueue的特定项。 如果需要,请使用 PrintQueue.MergeAndValidatePrintTicket 方法创建特定于 PrintQueue 的 PrintTicket(对给定打印机有效)。
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(FixedDocumentSequence, PrintTicket)
在派生类中重写时,将给定的 FixedDocumentSequence 与关联的 PrintTicket 一起同步写入序列化 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)
参数
- fixedDocumentSequence
- FixedDocumentSequence
一个文档序列,用于定义要写入序列化 Stream 的内容。
- printTicket
- PrintTicket
fixedDocumentSequence
内容的默认打印首选项。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
printTicket
如果没有首选打印设置,可以 null
。
此方法不会验证或修改 printTicket
给定 PrintQueue的特定项。 如果需要,请使用 PrintQueue.MergeAndValidatePrintTicket 方法创建特定于 PrintQueue 的 PrintTicket(对给定打印机有效)。
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(FixedPage)
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)
参数
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(FixedDocumentSequence)
在派生类中重写时,将给定的 FixedDocumentSequence 同步写入序列化 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)
参数
- fixedDocumentSequence
- FixedDocumentSequence
一个文档序列,用于定义要写入序列化 Stream 的内容。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(FixedDocument)
在派生类中重写时,将给定的 FixedDocument 同步写入序列化 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)
参数
- fixedDocument
- FixedDocument
要写入序列化 Stream 的文档。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(DocumentPaginator)
在派生类中重写时,将给定 DocumentPaginator 的内容同步写入序列化 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)
参数
- documentPaginator
- DocumentPaginator
定义写入序列化 Stream 中的内容的文档分页符。
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。
另请参阅
适用于
Write(Visual)
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)
参数
示例
以下示例演示如何使用 Write(DocumentPaginator, PrintTicket) 该方法将流文档序列化为输出文件。
// 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;
}
注解
写入操作的输出 Stream 通常指定为实现 SerializerWriter的派生类的构造函数的参数。