[Demos] Mail Merge
Posted: Sun Aug 28, 2005 11:19 am
Information about and comparison of TRichView mail merge demos.
2 of them are included in demo projects, others are available as separate
downloads.
Comparison Chart for TRichView Mail Merging Demos
The recommended way to implement merge fields in our editors is Report Workshop.
Demos\Delphi\Assorted\Fields\MailMerge\
Demos\Delphi\Assorted\Fields\MailMerge2\
MailMerge3
Mailmerge-LabelItem (simple version)
MailMerge-FreeStyle
MailMerge-Text
Read also comments at the beginning of the these demos' main form units.
2 of them are included in demo projects, others are available as separate
downloads.
Comparison Chart for TRichView Mail Merging Demos
The recommended way to implement merge fields in our editors is Report Workshop.
Demos\Delphi\Assorted\Fields\MailMerge\
- all fields are text items of some special text style (with the specified index);
- fields are text items; both initial visible text of these items and tags of these items are set to field name; but visible text is not important;
- tags will be used as field names;
- the template editor does not save collection of styles in template documents (right-click the template editor's TRichViewEdit, choose "Settings" in the context menu. You'll see that properties are set to "Use a predefined set of styles"). So all text formatting in document is defined at design time, in RVStyle.TextStyles collection
- the template editor's RVStyle and the main application's RVStyle have the same TextStyles collections but with one exception: the style for fields. In the template editor's RVStyle, it has a font allowing to see that it is a field clearly, in the main application's RVStyle it looks like a normal text. So, then template document is loaded, fields look like a normal text
- FillFields procedure searches for text item with non-empty tags, and processes them as fields (changes their visible text). You can see limitations of this method:
- field value is one line of plain text;
- you cannot define a font of field value text in the template.
You can use their visible text to make them look like fields (for example, it can be <<Field Name>>) and protection to disallow editing them.
Demos\Delphi\Assorted\Fields\MailMerge2\
- all fields are text items of some special text style (with the specified index); but it's easy to modify this demo: fields can be recognized by tags, or by special properties (protection); this is because the style itself is not important - field will be deleted at the process of mailmerge;
- this demo does not use tags
- template editor saves collections of styles in template documents (right click the template editor's TRichViewEdit, choose "Settings" in the context menu. You'll see that the properties are set to "Allow adding styles dynamically"). This allows to add your own styles, implementing commands like "Bold", "Font", using RichViewActions, etc.
- ReplaceFields deletes fields and inserts field values at their place; during this process, not only styles of the template are used, but also styles from documents representing field values.
You can see limitations of this method: fields are deleted at the process of mailmerge; if you need to perform this procedure for the second time, you need to reload template.
But this is the only method allowing to have arbitrary documents as field
values.
MailMerge3
- Field values are multiline text.
It works absolutely like MailMerge2, but field values are text, not RVF.
Has limitations of both MailMerge and MailMerge2, but simpler than MailMerge2.
This demo requires BDE.
Mailmerge-LabelItem (simple version)
- fields are not text, but special "label item"; label-items show read-only one line of text, unwrappable;
- field name is stored in tags; initial text of label-items is not important;
- you can use "Allow adding styles dynamically" mode with all its bonuses (not shown in this demo);
- FillFields procedure searches for label items, reads their tags and changes their text; font of "label-items" is not changed, so you can define it in the template editor.
- Limitations:
- field values - one line of text
MailMerge-FreeStyle
- It's like Demos\Delphi\Assorted\Fields\MailMerge\ demo, but does not use a fixed set of styles.
Styles for fields are created on the fly, so fields can have different fonts.
MailMerge-Text
- This demo is the same as in Demos\Delphi\Assorted\Fields\MailMerge\, but fields are defined as text between { }
Read also comments at the beginning of the these demos' main form units.