Page 1 of 1
Get text/rtf in local variable
Posted: Tue May 28, 2013 3:10 pm
by retwas
Hi,
I have a RichViewEditor and a local variable rveText : string;
How can I put the text or the rtf in this variable ?
I didn't find any RichViewEditor.gettext or other ..
Thanks !
Posted: Tue May 28, 2013 4:32 pm
by Sergey Tkachenko
As for plain text - you can use GetAllText from RVGetTextW unit (if you need Unicode string result) or from RVGetText unit (if you need ANSI text)
As for RTF string:
Code: Select all
uses RVTypes;
function GetRTFString(rv: TCustomRichView): String;
var Stream: TMemoryStream;
s: TRVAnsiString;
begin
Stream := TMemoryStream.Create;
rv.SaveRTFToStream(Stream, False);
Stream.Position := 0;
SetLength(s, Stream.Size);
Stream.ReadBuffer(PRVAnsiChar(s)^, Length(s));
Stream.Free;
Result := String(s);
end;
Get RTF text
Posted: Tue Dec 08, 2015 1:56 pm
by rafakwolf
Hello...
i'm trying to use this function, but the result is not as i need.
Into my RTF text the word "PARĂ“QUIA" is "PAR\u211 \'d3QUIA"
It is unicode characters ?
Can i get the RTF without them ?
Thanks!
Posted: Tue Dec 08, 2015 5:14 pm
by Sergey Tkachenko
Sorry, you cannot.
TRichView always saves Unicode characters having codes greater than 127 as RTF Unicode characters.
You can only remove non-Unicode duplicates of characters (\'d3 in you example), exclude rvrtfDuplicateUnicode from RTFOptions properties.
Saving Unicode characters as Unicode characters in RTF is necessary.
If we would save only non-Unicode duplicate (\'d3), it can be read correctly only if its Charset is specified correctly. It is not necessary so in TRichView Unicode documents.
And RTF specification does not allow saving characters having codes greater than 127 as they are.
RTF Documentos
Posted: Tue Dec 08, 2015 5:23 pm
by rafakwolf
OK, thanks for your attention