Page 1 of 1

Document templates and variable substitution

Posted: Tue Aug 10, 2010 12:41 pm
by was
I got the component RichView a short time and I'm having some difficulties to develop what I need. I am developing a software for civil registration, registration of birth, marriage and death, you know? The software is based on document templates.

Here are some questions:

1 - How do I save the document resulting from ScaleRichView directly into the database in RTF, without saving it on my computer before? And how do I view it later?

2 - I need to develop a software that has document templates with variables like "@NAME", "@GENDER", etc.. and then to register this information in the database, replace the variables in the text for information registered. Any ideas?

If you can answer these questions will be grateful.

Sorry for my english, I'm from Brazil and used the google translator.

William Antunes.

Posted: Tue Aug 10, 2010 3:48 pm
by Sergey Tkachenko
1) You can use TDBSRichViewEdit.
Or, if you use TSRichViewEdit:

Code: Select all

var Stream: TStream;
// saving
  Table.Edit;
  Stream := Table.CreateBlobStream(Table.FieldByName(FieldName), bmWrite);
  SRichViewEdit1.RichViewEdit.SaveRTFToStream(Stream, False);
  Stream.Free;
  Table.Post;
// loading
  Stream := Table.CreateBlobStream(Table.FieldByName(FieldName), bmRead);
  SRichViewEdit1.RVHeader.Clear;
  SRichViewEdit1.RVFooter.Clear;
  SRichViewEdit1.RichViewEdit.Clear;
  SRichViewEdit1.RichViewEdit.LoadRTFFromStream(Stream);
  Stream.Free;
  SRichViewEdit1.RVHeader.Format;
  SRichViewEdit1.RVFooter.Format;
  SRichViewEdit1.SetRVMargins;

Posted: Tue Aug 10, 2010 3:53 pm
by Sergey Tkachenko
2) As for variable substitution, see http://www.trichview.com/forums/viewtopic.php?t=8
Specifically:
http://www.trichview.com/support/files/ ... e-text.zip (values of fields (variables) are single-line text strings)
http://www.trichview.com/support/files/ ... -text3.zip (values of fields (variables) are multiline text strings)

(all other demos, without "text" in the zip's file name, require storing document in RVF, not RTF format)

Posted: Tue Aug 10, 2010 6:26 pm
by was
Thanks! That was a big help! :D