(Delphi ActiveX) Convert HTML to Plain Text
Demonstrates how to convert HTML to plain text.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
h2t: THtmlToText;
html: WideString;
plainText: WideString;
begin
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
h2t := THtmlToText.Create(Self);
html := h2t.ReadFileToString('c:/temp/test.html','utf-8');
if (h2t.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(h2t.LastErrorText);
Exit;
end;
plainText := h2t.ToText(html);
if (h2t.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(h2t.LastErrorText);
Exit;
end;
Memo1.Lines.Add(plainText);
end;
|