Convertion from RTF to TEXT.

General TRichView support forum. Please post your questions here
Post Reply
maazevedo13
Posts: 6
Joined: Mon Dec 18, 2006 6:17 pm

Convertion from RTF to TEXT.

Post by maazevedo13 »

Hi there,

I would like to convert a RTF data in TEXT data avoiding the format characters.

Is it possible ? How can I do that ?



Thanks
Marco
maazevedo13
Posts: 6
Joined: Mon Dec 18, 2006 6:17 pm

Post by maazevedo13 »

Sorry if my questions sound a little newbie. Actually, I am a begginer yet. I've discovered how to save as text through SaveText method. Now I need to save it in a data field and the SaveText method does not allow me do that.

How can I do that ?


Thanks
Marco
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For example,

Code: Select all

function SaveTextToField(rv: TCustomRichView; tbl: TTable;
  const FieldName: String): Boolean;
var Stream: TStream;
begin
  Stream := TMemoryStream.Create;
  try
    Result := rv.SaveTextToStream('', Stream, 60, False, False);
    Stream.Position := 0;
    TBlobField(tbl.FieldByName(FieldName)).LoadFromStream(Stream);
  finally
    Stream.Free;
  end;
end;
Using:

Code: Select all

  Table1.Edit;
  SaveTextToField(RichViewEdit1, Table1, 'TextField');
  Table1.Post;
maazevedo13
Posts: 6
Joined: Mon Dec 18, 2006 6:17 pm

Post by maazevedo13 »

Hi Sergey,


I tried your suggestion and the text has been saved in the data field. However, some characters have been changed after the process.

e.g.

The original text:
artigo 20, inciso III, alínea “b”, da Lei Complementar nº 11/91
The text after saved in the data field:
artigo 20, inciso III, alínea ¿b¿, da Lei Complementar nº 11/91
See the “ character has been changed by ¿ character .

When saving text in text file the problem does not happen.


Do you have any idea how I could solve that ?

Thanks
Marco
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

SaveText and SaveTextToStream produce exactly the same output (because SaveText calls SaveTextToStream inside).

If the file and the table content is different, that means that the database itself has modified it. Does it allow specifying language for the field or for the table?
Post Reply