Document templates and variable substitution

General TRichView support forum. Please post your questions here
Post Reply
was
Posts: 2
Joined: Tue Aug 10, 2010 12:27 pm
Location: Rio Grande do Sul, Brasil

Document templates and variable substitution

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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)
was
Posts: 2
Joined: Tue Aug 10, 2010 12:27 pm
Location: Rio Grande do Sul, Brasil

Post by was »

Thanks! That was a big help! :D
Post Reply