trichview.com

trichview.support




Re: Saving RVF


Return to index


Author

Message

Sergey Tkachenko

Posted: 08/14/2002 13:02:54


RVF is a binary format

(it will be a text format if:

a) it does not contain Unicode

b) it does not contain styles, layout, background, images, tables, or

rvfoBinary is excluded from RVFOptions).


So you cannot use methods assuming text contents, such as

StringList.LoadFromFiles, or methods for TextFile (such as ReadLn).


1) Saving RVF to string:


Stream := TStringStream.Create('');

rv.SaveRVFToStream(Stream);

s := Stream.DataString;

Stream.Free;


s is a result.


2) Saving RVF string to file:


Stream := TFileStream.Create('aaa.rvf', fmCreate);

Stream.WriteBuffer(PChar(s)^, Length(s));

Stream.Free;


3) Loading RVF file to string:


Stream := TFileStream.Create('aaa.rvf', fmOpenRead);

SetLength(s, Stream.Size);

Stream.ReadBuffer(PChar(s)^, Stream.Size);

Stream.Free;


s is a result.


4) Loading RVF file to TMemoryStream:


ResultStream := TMemoryStream.Create;


Stream := TFileStream.Create('aaa.rvf', fmOpenRead);

ResultStream.CopyFrom(Stream, Stream.Size);

Stream.Free;



> Hello all,

> I have the following problem : if i try to save the contents of a

> RichViewEdit to a RVF file. i can simply use RVE.SaveToRVF(). However, I

> want to do something a bit more different -> to save the RVF to a stream,

> and then save the stream as a string, and then save the string to a file

F.

> Then, instead of using RVE.LoadRVF(), i read the file F and insert the

> contents in a stream S, and finally, I use  LoadRVFFromStream(S). However,

> this doesn't work. If I compare the contents of a string just converted

from

> RVE to Stream to String, it's a bit different from the string I obtain

when

> I open the file and Readln() from it. So, if I save it that way, some data

> is lost. How is this solved, i.e. I do not use Readln() and Writeln(), or

I

> use a file diffrenet from TextFile....

>

> Best regards,

> Slavi

>

>





Powered by ABC Amber Outlook Express Converter