HTML from RTF de-encapsulation

<< Click to display table of contents >>

HTML from RTF de-encapsulation

unit [VCL/FMX] RVRTFDeEncapsulation / fmxRVRTFDeEncapsulation;

type
  TRVAttachmentPositionEvent = procedure (Pos: Integer;
    var TextToInsert: TRVUnicodeStringof object;
 
  TRVRTFEncapsulationType = (rvrtfetNone, rvrtfetHTML, 
    rvrtfetText, rvrtfetError);
 
function GetRTFEncapsulationType(

  RTFStream: TStream): TRVRTFEncapsulationType;
function ExtractEncapsulatedHTMLFromRTF(RTFStream, HTMLStream: TStream;
  OnAttachmentPosition: TRVAttachmentPositionEvent = nil): Boolean;

HTML-in-RTF encapsulation is performed by Microsoft Outlook/Exchange. A result is an RTF file created from HTML. It looks close to the original HTML file (i.e. it contains RTF code that mimics the original HTML document), but also contains data allowing to extract the original HTML document unchanged.

GetRTFEncapsulationType checks if the specified stream contains HTML or a plain text encapsulated in RTF. Possible result values:

rvrtfetNone –- RTF without encapsulation

rvrtfetHTML– RTF containing encapsulated HTML

rvrtfetText – RTF containing encapsulated plain text

rvrtfetError – not RTF

ExtractEncapsulatedHTMLFromRTF performs extraction of encapsulated HTML or plain text from RTF (from RTFStream to HTMLStream).

Also, if the callback function OnAttachmentPosition is provided, it calls it when it finds an attachment position (you can store the position of HTMLStream where this attachment is located, and/or insert some text in resulting HTML/text in this position).

See also

Additional information about HTML-in-RTF encapsulation