migrating application --> html / RTF (stored in db)

General TRichView support forum. Please post your questions here
Post Reply
dgriessinger
Posts: 10
Joined: Tue Jan 06, 2009 1:27 pm

migrating application --> html / RTF (stored in db)

Post by dgriessinger »

Hi everybody, and happy new year.

I need to transform internal application to use Trichview as editor.

The editor store into database, in RTF format (it's working)

My problem is that I need at the end to combine all field into new and single file (RTF and HTML), I want to do that without use visual component, I think it's possible, but I don't see how.

For HTML export, I try this :

Code: Select all

function RTFToHtml(rtf:string): string;
var Stream: TStringStream;
    rv:TCustomRichView;
    st:TRVStyle;
begin
 st:=TRVStyle.Create(nil);
 rv:=TCustomRichView.Create(nil);
 rv.Style:=st;
 RTFStringToRv(rv,rtf);
 Stream := TStringStream.Create('');
 rv.SaveHTMLToStreamEx(Stream, '', '', '', '', '', '',[rvsoUseCheckpointsNames, rvsoUTF8]);
 result:= Stream.DataString;
 stream.free;
 rv.Free;
 st.Free;
end;
But error occurs (no parent...), is it possible to convert in html without TRichView component (rvdata ???)



My second point is to combine rtf fields to make one big rtf file.
a kind of function like rvdata.insertRawRTF('{\rtf1\ansi\ansicpg0\uc1\deff0\deflang0\deflangfe0{\fonttbl ...........'); exists ?


Thank you for your help
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Use rv.LoadRTFFromStream to add RTF document to the end of rv.
LoadRTFFromStream does not clear the existing document before loading, so you can use it to create a large document from several source documents.

In the current version of the components, TRichView must have an assigned parent. Do you have some form in your application? Assign it to rv.Parent, and assign rv.Visible := False.

But loading RTF files and saving HTML do not require formatting, so they can be implemented without assigning parent and without calling rv.Format.
As for saving RTF files, if they contain tables, TRichView must be formatted. And width of TRichView may affect to width of tables, so it's recommended to assign rv.Width equal to desired width out the resulting document.
Post Reply