TCustomRichView.LoadFromStream, LoadFromStreamEx

<< Click to display table of contents >>

TCustomRichView.LoadFromStream, LoadFromStreamEx

The methods load a document from Stream, autodetecting its format (RVF/RTF/HTML/DocX/Markdown/text)

function LoadFromStream(Stream: TStream; IsTextUnicode: TRVYesNoAuto

  AllowMarkdown: Boolean = False; 

  const Path: TRVUnicodeString = '';

  CodePage: TRVCodePage = RV_CP_DEFAULT): Boolean;

function LoadFromStreamEx(Stream: TStream

  IsTextUnicode: TRVYesNoAuto; AllowedFormats: TRVLoadFormats;
  out Unicode: Boolean; out LoadedFormat: TRVLoadFormat;
  const Path: TRVUnicodeString = '';

  CodePage: TRVCodePage = RV_CP_DEFAULT): Boolean;): Boolean;

(introduced in version 10, modified in version 21 and 23)

These methods can detect both normal RTF, and RTF converted to Unicode (UTF-16) string.

HTML is detected by the presence of '<html' or '<head' within the leading 1024 characters.

Text or Markdown is loaded if the stream does not contain RVF, RTF, HTML or DocX.  The methods do not load text or Markdown if Stream contains characters having codes less than ord(' ').

Path is the base path for images that may be referred from a document.

IsTextUnicode specifies whether the text/Markdown is Unicode (UTF-16):

rvynaNo not Unicode (i.e, not UTF-16);

rvynaYes Unicode (UTF-16);

rvynaAuto autodetecting ANSI/Unicode (a wrong detection is possible).

If Unicode is specified or detected, a text or a Markdown is loaded using UTF-16 encoding.

If Unicode is not specified or detected, a text and Markdown is loaded using the code page specified in the CodePage parameter. The default value of CodePage = RV_CP_DEFAULT (meaning UTF-8 for Markdown, default ANSI code page for plain text in Windows, UTF-8 for plain text in non-Windows).

LoadFromStream: if AllowMarkdown = True, a Markdown is loaded; otherwise, a plain text is loaded.

LoadFromStreamEx: allowed formats are listed in AllowedFormats. If it contains both rvlfText and rvlfMarkdown, Markdown is loaded. The loaded format is returned in LoadedFormat. If the loaded text/markdown/HTML/RTF is stored as UTF-16 or UTF-8, Unicode = True on exit.

Methods type: viewerstyle viewer-style.

Return value:

"Was reading successful?"


See also methods of TRichView:

LoadFromFile, LoadFromFileEx






LoadTextFromStream, LoadTextFromStreamW.