Page 1 of 1

Convertion from RTF to TEXT.

Posted: Mon Dec 18, 2006 6:40 pm
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

Posted: Mon Dec 18, 2006 8:52 pm
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

Posted: Tue Dec 19, 2006 12:35 pm
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;

Posted: Tue Dec 19, 2006 1:31 pm
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

Posted: Tue Dec 19, 2006 3:25 pm
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?