In a Delphi 10 Seattle console application with no visible console window, I need to extract plain text from a .RTF file. So I wrote this code:
procedure ExtractPlainTextFromRTFFile(const ARTFFile, OutputTextFile: string);
var
RE: Vcl.ComCtrls.TRichEdit;
begin
RE := Vcl.ComCtrls.TRichEdit.Create(nil);
try
RE.Lines.LoadFromFile(ARTFFile);
TFile.WriteAllText(OutputTextFile, RE.Text);
finally
RE.Free;
end;
end;
However this creates an error at run-time:
EInvalidOperation with message Control has no parent window
since TRichEdit
needs a parent window.
So how can I extract plain text from .RTF file in a Delphi console application?