sgcRichEdit: a Word Processor Inside Your Own Application

· Components
sgcRichEdit: a Word Processor Inside Your Own Application
✦  sgcUI · sgcRichEdit

A word processor.
Inside your application.

sgcRichEdit is the new rich text document editor of sgcUI. Your users write letters, contracts, notes and reports with styles, lists, tables, images and links. Your code reads and writes RTF, HTML, Markdown and JSON, and exports DOCX, PDF and PNG pages.

  • VCL
  • FireMonkey
  • C++ Builder
  • WinForms
  • WPF
  • Avalonia

↔  Drag the handle to switch from light to dark

sgcRichEdit Editor—□✕
The sgcRichEdit Editor demo with the Fluent preset, light
The same document with the Fluent preset, dark
LightDark
4formats in and out
3export formats
5UI frameworks
12editor languages

Sooner or later every business application needs real documents. A CRM writes letters to customers, a practice management tool keeps case notes, an ERP stores quotation templates, and a help desk answers in formatted text. A plain memo is not enough for any of that.

sgcRichEdit is a complete document editor built into sgcUI. It keeps a real document model with named styles, multilevel lists, tables with merged cells, inline images and hyperlinks, and it lays the document out in pages. One document model drives the VCL, FireMonkey, WinForms, WPF and Avalonia controls, and the same model loads, converts and exports documents without any window at all.

sgcRichEdit in 60 Seconds

Styles, tables, every language, light and dark, every format and every platform in one minute. Also on YouTube.

A Real Document, Not a Text Box

Contracts, reports and letters must look the same every time they are opened. sgcRichEdit stores paragraphs with named styles, and formatting comes from a style chain plus direct formatting, so changing the Heading 1 style changes every heading of the document at once.

AaAaAa
Named stylesNormal, Heading 1 to 6, Title, Subtitle, Quote, Code, List Paragraph, Hyperlink and Table Grid are built in.
Lists with 9 levelsBullets, numbers, letters and roman numerals, with a command to promote or demote a level.
TablesCells merged across columns and rows, header rows, borders, backgrounds and nested tables.
Images and linksInline images and hyperlinks, with Ctrl+click and an OnLinkClick event.
↺↻
Undo and redoA full history, with typing grouped into words, so one undo removes one word.
growth in Q3, growth in Europe
Find and replaceAcross paragraphs and table cells, with regular expressions and Replace All as one undo step.

Up Close

Bold, italic, underline, strikeout, superscript and subscript, font names, sizes, colours and highlights, alignment, indents and line spacing. Here is the formatting of the document above at 200% zoom.

Character formatting at 200% zoom

Tables, Images and Pages

The editor paginates the document with its own page settings. Paragraphs split by lines, the header rows of a table repeat on each page, and page breaks are kept, so what users see is what they print. Print and PrintPreview work on the desktop, and ExportToPNG renders any page at the resolution you choose.

sgcRichEdit Editor—□✕
A table with a coloured header row, a merged cell and an inline chart image
Page 1 of the document, exported to PNG
Page 1
Page 2 of the document, exported to PNG
Page 2
Page 3 of the document, exported to PNG
Page 3

The three pages of the document in the screenshots, written by ExportToPNG at 150 DPI.

Every Language, Every User

Japanese, Chinese and Korean users type through an input method editor, and Arabic and Hebrew users write from right to left, often with English words in the same sentence. sgcRichEdit shows the IME composition inline at the caret and commits it as one undo step. Bidirectional paragraphs keep the caret and the selection where the reader expects them, and each paragraph has its own direction.

sgcRichEdit Editor—□✕
Arabic right to left text mixed with English, and Japanese, Chinese, Korean and Russian paragraphs, dark theme

Light, Dark, Fluent or Classic

sgcRichEdit is an sgcUI control, so it follows the application theme like the rest of the suite. Pick the Fluent preset and the editor and the ribbon take the Windows 11 look. Switch to dark and the ribbon, the status bar and the backstage go dark, while the page stays white, like paper.

sgcRichEdit Editor—□✕
sgcRichEdit with the Fluent preset, light
sgcRichEdit with the Classic preset
sgcRichEdit with the Fluent preset, dark
uses
  sgcUICore_Theme;

// the Windows 11 look for every sgcUI control, sgcRichEdit included
sgcUISetApplicationThemePreset('Fluent');
// follow the light / dark setting of Windows, live
sgcUISetApplicationThemeFollow(utfSystem, True);

One Document, Every Format

Documents arrive as RTF from Word, as HTML from a browser or an email, and as Markdown from a developer tool. sgcRichEdit reads and writes all of them and keeps its own native JSON format, which stores every detail of the document. LoadFromFile detects the format, SaveToFile takes the format you ask for, and AsHTML, AsRTF and AsMarkdown read and write the document as a string.

Load

RTFfrom Word
HTMLwith CSS
Markdowntables too
JSONnative
One document model Styles, lists, tables, images and links, laid out in pages

Save and export

DOCXfor Word
PDFtagged
PNGany DPI
RTF, HTML, MDand JSON

Each format unit in the uses clause registers its reader or writer, and sgcUIPDF_Export connects the PDF export to the sgcPDF engine, which is installed with sgcRichEdit.

uses
  sgcRichEdit_Formats, sgcRichEdit_VCL,
  sgcRichEdit_RTF_Reader, sgcRichEdit_HTML_Writer, sgcRichEdit_Markdown,
  sgcRichEdit_DOCX, sgcUIPDF_Export;

procedure TForm1.ConvertContract;
begin
  sgcVCLRichEdit1.LoadFromFile('contract.rtf');
  sgcVCLRichEdit1.SaveToFile('contract.html', refHTML);
  sgcVCLRichEdit1.SaveToFile('contract.md', refMarkdown);
  sgcVCLRichEdit1.SaveToFile('contract.docx', refDOCX);
  sgcVCLRichEdit1.ExportToPDF('contract.pdf');
  sgcVCLRichEdit1.ExportToPNG('page1.png', 0, 150);
end;

Editing That Feels Familiar

Users bring their word processor habits with them. The editor answers the usual shortcuts (Ctrl+B, Ctrl+I, Ctrl+U, alignment, headings, bullets and Ctrl+K for links), keeps a full undo and redo history, and finds and replaces text across paragraphs and table cells.

sgcRichEdit Editor—□✕
The find and replace bar of the Editor demo

Every command is available from code through ExecuteCommand and CommandState, and through VCL and FireMonkey actions, so your own toolbar or an sgcToolbar ribbon stays in sync with the selection.

uses
  sgcRichEdit_Commands;

procedure TForm1.btnBoldClick(Sender: TObject);
begin
  sgcVCLRichEdit1.ExecuteCommand(recBold);
end;

procedure TForm1.sgcVCLRichEdit1SelectionChange(Sender: TObject);
begin
  // the button shows the state of the selection
  btnBold.Down := sgcVCLRichEdit1.CommandState(recBold).Checked;
end;

Your Documents, in Your Database

Notes, letters and templates usually live in a database field. TsgcVCLDBRichEdit and TsgcFMXDBRichEdit connect to a TDataSource, read memo and BLOB fields, put the dataset in edit mode on the first change and write the document back when the user leaves the control. Escape restores the field value, and AutoDisplay loads large documents on demand.

uses
  sgcRichEdit_Formats, sgcRichEdit_VCL_DB;

sgcVCLDBRichEdit1.DataSource := dsNotes;
sgcVCLDBRichEdit1.DataField := 'NOTE';
// store the documents as JSON; refAuto, the default, detects the format
sgcVCLDBRichEdit1.FieldFormat := refJSON;

Headless, Even on Linux64

Documents often have to be converted on a server: RTF to HTML for a portal, JSON to PDF for an archive, a page to PNG for a thumbnail. The document model, the formats, the layout and the exports do not depend on VCL or FireMonkey, so a Windows service or a Linux64 daemon (Delphi 10.2 and later) can load, change, render and export documents without a window, with the same page layout as the visual controls.

uses
  sgcRichEdit_Model, sgcRichEdit_Formats, sgcRichEdit_Print,
  sgcRichEdit_RTF_Reader, sgcRichEdit_HTML_Writer, sgcUIPDF_Export;

var
  oDocument: TsgcRichDocument;
begin
  oDocument := TsgcRichDocument.Create;
  try
    sgcRichLoadFromFile(oDocument, 'letter.rtf');
    sgcRichSaveToFile(oDocument, 'letter.html', refHTML);
    // tagged PDF, no window and no VCL or FireMonkey needed
    sgcRichExportPDF(oDocument, nil, 'letter.pdf');
  finally
    oDocument.Free;
  end;
end;

For .NET Too

The .NET controls for WinForms, WPF and Avalonia use the same names as the Delphi ones. The core library targets .NET Standard 2.0, .NET Framework 4.7.2 and .NET 6, 8, 9 and 10, and the DocumentText property binds to your data in all three frameworks.

using esegece.sgcRichEdit;
using esegece.sgcUICore;

// once at startup: PDF export through the esegece.sgcUICore.sgcPDF package
TsgcUIPDFExporter.Register();

richEdit.LoadFromFile("contract.rtf");
richEdit.SaveToFile("contract.html", TsgcRichEditFormat.refHTML);
richEdit.SaveToFile("contract.docx", TsgcRichEditFormat.refDOCX);
richEdit.ExportToPDF("contract.pdf");

Run the Demos

The Delphi and C++ Builder demos install with the sgcUI trial, and the .NET demos ship with the Registered .NET download.

Where sgcRichEdit Is Included

sgcRichEdit is sold on its own for Delphi and C++ Builder and for .NET, and it is included in sgcUI Enterprise and in the All-Access bundle. The single package installs sgcPDF too, so PDF export always works. There is no free Community edition. See the pricing page for the details.

Give Your Users a Word Processor

sgcRichEdit arrives with sgcUI 2026.11 for Delphi and C++ Builder, on VCL and FireMonkey, and for .NET on WinForms, WPF and Avalonia.

Questions or feedback? Get in touch, you will get a reply from the people who wrote the code.