Exporters
The exporters convert the text of an editor into a formatted document, keeping the colors and the styles of the highlighter.
| Component | Unit | Output |
|---|---|---|
TSynExporterHTML | SynEdit.ExportHTML | HTML (a full page or a fragment, with CSS classes or inline styles). |
TSynExporterRTF | SynEdit.ExportRTF | Rich Text Format. |
TSynExporterTeX | SynEdit.ExportTeX | TeX. |
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
| Member | Description |
|---|---|
Highlighter | The highlighter that gives the colors and styles to the text. |
Font | The font of the exported text. |
Color, UseBackground | Background color, and whether it is exported. |
Title | The title of the document. |
Encoding | seUTF8 (default), seUTF16LE, seUTF16BE or seAnsi (SupportedEncodings tells which ones the format accepts). |
ExportAsText | Exports the formatted text as plain text (for the clipboard). |
DefaultFilter | The file filter of the format, for the save dialogs. |
FormatName | The name of the format (read only). |
ExportAll(Lines) | Exports all the lines. |
ExportRange(Lines, Start, Stop) | Exports a part of the text. |
ExportedText | The text produced. |
SaveToFile, SaveToStream | Saves the document. |
CopyToClipboard | Copies the document to the clipboard in its format. |
Clear | Clears the exporter. |
HTML options
| Property | Description |
|---|---|
CreateHTMLFragment | Produces only a fragment, without the page header. |
InlineCSS | Writes the styles inline in each element instead of using the CSS classes. |
SuppressFragmentInfo | Does not write the fragment information used by the clipboard. |
