Skip to main content

DocumentSerializerOptions Class

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents

Shared options for all document serializers (RTF, DOCX, etc.).

public class DocumentSerializerOptions

Inheritance: object -> DocumentSerializerOptions

Remarks​

Replaces the former per-format RtfSerializerOptions and DocxSerializerOptions with a single type. All serializer behavior is derived from Avalonia.Controls.Documents.Serialization.DocumentSerializerOptions.ExportMode:

Constructors​

NameDescription
DocumentSerializerOptionsNo summary available.

DocumentSerializerOptions Constructor​

public DocumentSerializerOptions()

Properties​

NameDescription
ExportModeControls the export strategy for all serializers. Defaults to Avalonia.Controls.Documents.Serialization.DocumentExportMode.RoundTripStrict.
ImageEncodingPolicyHow images whose encoded format the target does not accept are handled. Defaults to Avalonia.Controls.Documents.Serialization.ImageEncodingPolicy.ReencodeFromPixels, which transcodes them to a format the target accepts using the built-in codec.
MaxImageBytesMaximum size, in bytes, of a single embedded image. An image whose payload exceeds this limit is skipped and the surrounding document still loads. (the default) imposes no limit. Use this to guard against hostile or malformed documents with oversized image payloads.

ExportMode Property​

Controls the export strategy for all serializers. Defaults to Avalonia.Controls.Documents.Serialization.DocumentExportMode.RoundTripStrict.

public Avalonia.Controls.Documents.Serialization.DocumentExportMode ExportMode { get; set; }

ImageEncodingPolicy Property​

How images whose encoded format the target does not accept are handled. Defaults to Avalonia.Controls.Documents.Serialization.ImageEncodingPolicy.ReencodeFromPixels, which transcodes them to a format the target accepts using the built-in codec.

public Avalonia.Controls.Documents.Serialization.ImageEncodingPolicy ImageEncodingPolicy { get; set; }

MaxImageBytes Property​

Maximum size, in bytes, of a single embedded image. An image whose payload exceeds this limit is skipped and the surrounding document still loads. (the default) imposes no limit. Use this to guard against hostile or malformed documents with oversized image payloads.

public Nullable<long> MaxImageBytes { get; set; }

Remarks​

Applies to every format that carries image bytes: on read to RTF, DOCX, XAML and HTML, and on write to PDF, where the payload measured is the sample buffer for an image that holds only pixels. Plain text and Markdown carry no embedded images - a Markdown image is always a reference the host resolves - so the limit does not reach them.