Skip to content

Exporters ​

The exporters convert the text of an editor into a formatted document, keeping the colors and the styles of the highlighter.

ComponentUnitOutput
TSynExporterHTMLSynEdit.ExportHTMLHTML (a full page or a fragment, with CSS classes or inline styles).
TSynExporterRTFSynEdit.ExportRTFRich Text Format.
TSynExporterTeXSynEdit.ExportTeXTeX.

They derive from TSynCustomExporter (unit SynEdit.Export), the base class to write an exporter for another format.

Using an exporter ​

pascal
SynExporterHTML1.Highlighter := SynPasSyn1;
SynExporterHTML1.Title := 'Unit1.pas';
SynExporterHTML1.ExportAll(SynEdit1.Lines);
SynExporterHTML1.SaveToFile('Unit1.html');
// or: SynExporterHTML1.CopyToClipboard;

For the selected text use ExportRange.

Common properties and methods ​

MemberDescription
HighlighterThe highlighter that gives the colors and styles to the text.
FontThe font of the exported text.
Color, UseBackgroundBackground color, and whether it is exported.
TitleThe title of the document.
EncodingseUTF8 (default), seUTF16LE, seUTF16BE or seAnsi (SupportedEncodings tells which ones the format accepts).
ExportAsTextExports the formatted text as plain text (for the clipboard).
DefaultFilterThe file filter of the format, for the save dialogs.
FormatNameThe name of the format (read only).
ExportAll(Lines)Exports all the lines.
ExportRange(Lines, Start, Stop)Exports a part of the text.
ExportedTextThe text produced.
SaveToFile, SaveToStreamSaves the document.
CopyToClipboardCopies the document to the clipboard in its format.
ClearClears the exporter.

HTML options ​

PropertyDescription
CreateHTMLFragmentProduces only a fragment, without the page header.
InlineCSSWrites the styles inline in each element instead of using the CSS classes.
SuppressFragmentInfoDoes not write the fragment information used by the clipboard.

Released under the MPL 1.1 / GPL 2 dual license.