Table of Contents

Import and export

HTML with TTMSFNCRichEditorIO

TTMSFNCRichEditorIO handles HTML import and export. Drop it on the form or create it in code:

var IO: TTMSFNCRichEditorIO;
begin
  IO := TTMSFNCRichEditorIO.Create(nil);
  try
    IO.RichEditor := RichEditor1;

    // Import HTML from file
    IO.LoadFromFile('document.html');

    // Import HTML from string
    IO.LoadFromString('<b>Hello</b> <i>World</i>');

    // Export to HTML file
    IO.SaveToFile('output.html');

    // Export to HTML string
    var html := IO.SaveToString;
  finally
    IO.Free;
  end;
end;

PDF output with TTMSFNCRichEditorPDFIO

TTMSFNCRichEditorPDFIO converts editor content to PDF:

var PDF: TTMSFNCRichEditorPDFIO;
begin
  PDF := TTMSFNCRichEditorPDFIO.Create(nil);
  try
    PDF.RichEditor := RichEditor1;
    PDF.SaveToFile('output.pdf');
  finally
    PDF.Free;
  end;
end;

TTMSFNCRichEditorPrintIO sends editor content to the system print dialog:

var Print: TTMSFNCRichEditorPrintIO;
begin
  Print := TTMSFNCRichEditorPrintIO.Create(nil);
  try
    Print.RichEditor := RichEditor1;
    Print.Print;
  finally
    Print.Free;
  end;
end;

Combining HTML and PDF export with progress handling

procedure TForm1.SaveDocument;
var
  IO: TTMSFNCRichEditorIO;
  PDF: TTMSFNCRichEditorPDFIO;
begin
  IO := TTMSFNCRichEditorIO.Create(nil);
  PDF := TTMSFNCRichEditorPDFIO.Create(nil);
  try
    IO.RichEditor := RichEditor1;
    PDF.RichEditor := RichEditor1;

    IO.SaveToFile('report.html');
    PDF.SaveToFile('report.pdf');
  finally
    IO.Free;
    PDF.Free;
  end;
end;

See also