Openening a RVF file
Openening a RVF file
Hello proffesionals,
there is a bit of text inside a RVF file i want to have shown in Memo in delphi.
Also in this file are some images. But these images dont want to have shown.
Does anyone know if this is possible? And maybe have the code to do so? I got a RVF example file here and can send it to you if you need it.
With kind regards,
Gismo.
there is a bit of text inside a RVF file i want to have shown in Memo in delphi.
Also in this file are some images. But these images dont want to have shown.
Does anyone know if this is possible? And maybe have the code to do so? I got a RVF example file here and can send it to you if you need it.
With kind regards,
Gismo.
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You cannot show RVF file without loading it in RichViewEdit (using LoadRVF method). Then you can export it to TMemo.
For Delphi 2009 or newer:
For older versions of Delphi:
For Delphi 2009 or newer:
Code: Select all
var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
RichViewEdit1.SaveTextToStreamW('', Stream, 80, False, False);
Stream.Position := 0;
Memo1.Lines.LoadFromStream(Stream, TEncoding.Unicode);
Stream.Free;
end;
Code: Select all
var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
RichViewEdit1.SaveTextToStream('', Stream, 80, False, False);
Stream.Position := 0;
Memo1.Lines.LoadFromStream(Stream);
Stream.Free;
end;
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Code: Select all
try with table1 do begin {table with 6000 records}
table1.open;
while not table1.eof do
{rvf file that matches a variable of the table}
richviewedit1.Clear;
richviewedit1.Style := rvstyle1;
if FileExists(filename) then begin
richviewedit1.LoadRVF(filename);
end;
richviewedit1.Format;
Stream := TMemoryStream.Create;
RichViewEdit1.SaveTextToStream('', Stream, 80, False, False);
{^seems to cause the eaccessviolation}
Stream.Position := 0;
memo1.lines.add(text);
Memo1.Lines.LoadFromStream(Stream, TEncoding.Unicode);
memo1.lines.add(text);
Stream.Free;
memo1.Lines.add('---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------')
table1.next;
end;
finally
if Memo1.Lines.Count > 0 then
Memo1.Lines.Delete(Memo1.Lines.Count - 1 );
table1.filtered := false;
table1.close;
end;
i tried to copy the code that mathers from my code so might be that i miss a end or something. In anycase it seems tat the loading the RVF goes ok since i checked that myself.
Though it seems it cant put it into a stream. I think this could be cause it contains a picture.
This isnt much of a problem since i need the text without pictures anyway. I just dont know yet how to remove the pictures from the richviewedit.
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I tried it but it didnt work out sadly. Though i managed to get all the code causing the eaccessviolation error in a single button click for testing. If needed i could give the file that might be causing the error. ill keep on tring to find the error. i posted the button code below.
I still get the error on the save to stream part. If needed i can provide the file that could be causing it. Ill keep looking to solve the problem myself aswel.
Code: Select all
var
i: integer;
mychar: char;
Stream: TMemoryStream;
begin
richviewedit1.Clear;
richviewedit1.Style := rvstyle1;
richviewedit1.LoadRVF('c:\memo2_4796.rvf');
richviewedit1.Format;
Stream := TMemoryStream.Create;
RichViewEdit1.SaveTextToStreamw('', Stream, 80, False, False);
Memo1.Lines.LoadFromStream(Stream);
Stream.Position := 0;
memo1.Lines.add('---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
stream.Free;
end;
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
i hope this is what you mean with reproduce in a sample project.
I now made a form with 2 buttons 1 memo 1 richviewedit and a rvstyle.
button1 loads the file
button2 transfers the file to the memo causing a eaccessviolation error
the code looks like this
I now made a form with 2 buttons 1 memo 1 richviewedit and a rvstyle.
button1 loads the file
button2 transfers the file to the memo causing a eaccessviolation error
the code looks like this
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, RVScroll, RichView, RVEdit, RVStyle;
type
TForm1 = class(TForm)
RichViewEdit1: TRichViewEdit;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
RVStyle1: TRVStyle;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
richviewedit1.Clear;
richviewedit1.Style := rvstyle1;
richviewedit1.LoadRVF('c:\artikels.db_memo2_220.rvf');
RichViewedit1.DeleteUnusedStyles(True, True, True);
richviewedit1.Format;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
RichViewEdit1.SaveTextToStreamw('', Stream, 80, False, False);
Stream.Position := 0;
memo1.Lines.LoadFromStream(stream);
stream.Free;
end;
end.
i tried it with the W after savetostream but it ended up with only passing me the first letter of the text (on a rvf file that doesnt have the error) also i found a couple of more files also having this problem they all have the same thing in commen and that is that there is a table or a picture or anything like that present.