trichview.com Forum Index trichview.com
TRichView support forums
 

[Demos] Mail Merge


 
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos
    View previous topic :: View next topic  
Author Message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Sun Aug 28, 2005 11:19 am    Post subject: [Demos] Mail Merge Reply with quote

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

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.
    This demo can be modified. You can set "Allow adding styles dynamically mode", and use any text styles for fields (they will be recognized by tags).
    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.


http://www.trichview.com/support/files/mailmerge3.zip
    Field values are multiline text.
    Works absolutely like MailMerge2, but field values are text, not RVF.
    Has limitations of both MailMerge and MailMerge2, but simpler than
    MailMerge2.


http://www.trichview.com/support/files/mailmerge-labelitem.zip
  • 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

There is an advanced version of this demo in Demos\Delphi\Assorted\Fields\MailMerge-LabelItems\

http://www.trichview.com/support/files/mailmerge-freestyle.zip
    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.


http://www.trichview.com/support/files/mailmerge-text.zip
    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.

--
Updates
2008-Dec-11: for compatibility with TRichView 11 and Delphi 2009.
2011-Oct-2: for compatibility with TRichView 13.4


Last edited by Sergey Tkachenko on Sun Oct 02, 2011 7:20 pm; edited 6 times in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Thu Dec 01, 2005 4:22 pm    Post subject: Reply with quote

http://www.trichview.com/support/files/mailmerge-text2.zip

Almost the same as mailmerge-text.zip demo, but generates one multipage report instead of individual reports for each records.
Template editor and report generator are combined in one application.

Field codes: text in {}, for example {NAME}.
Field values: single line text.
--
2008-Dec-11: updated for compatibility with TRichView 11 and Delphi 2009


Last edited by Sergey Tkachenko on Thu Dec 11, 2008 1:55 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Sun Oct 22, 2006 12:05 pm    Post subject: Reply with quote

http://www.trichview.com/support/files/mailmerge-text3.zip

The same as mailmerge-text2.zip, but allows multiline field values.

Field codes: text in {}, for example {NAME}.
Field values: multiline text.

Note: the same function for inserting multiline text is used in the scripting demo, http://www.trichview.com/forums/viewtopic.php?t=9

2008-Dec-11: updated for compatibility with TRichView 11 and Delphi 2009

http://www.trichview.com/support/files/mailmerge-text3-2.zip
The same demo, but field codes are identifiers started from $, for example $NAME.


Last edited by Sergey Tkachenko on Wed Jun 15, 2011 6:35 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Tue May 05, 2009 1:37 pm    Post subject: Reply with quote

http://www.trichview.com/support/files/mailmerge-text4.zip

The same as mailmerge-text3.zip, but supports several types of field values.

Field codes: text in {}, for example {NAME}.
Field values: multiline text / picture / table.
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Thu Aug 06, 2009 4:36 pm    Post subject: Reply with quote

http://www.trichview.com/support/files/georeport.zip

Field codes: arbitrary fragment.
Field codes: arbitrary fragment.

By functionality, this demo is similar to Demos\Delphi\Assorted\Fields\MailMerge2\, but has an important advantage: new field values can be applied without template reloading (old field values can be replaced with new field values).

In this demo, a field is a set of adjacent items (of any type) marked with the same code. Field code is stored in items tags, in the form "Code|" for normal items, or "Code|Target" for hyperlinks.

This demo supports two sources of field values:
1) an arbitrary document stored in RVF format in TBlobField
2) a single line text stored in TStringField.

This demo consists of 2 projects:
- DataEdit: editing database of field values;
- GeoReport: the main applications.
The applications use a Paradox table, so BDE must be installed.

Exe-demo:
http://www.trichview.com/support/files/georeport-exe.zip
Showing field codes:

Showing field values:


Sample data were taken from wikipedia.
---
Versions:
http://www.trichview.com/support/files/georeport_v1_1.zip . In this version, text styles for text fields are not hard-coded. The font of source text (field code) is used, only colors are changed to black-on-white (more exactly, clWindowText on transparent)

---
Changes:
2010-Oct-21: fix related for using tags in field text (hyperlinks)
2011-Oct-2: update for compatibility with TRichView 13.4
2014-Mar-13: update for compatibility with TRichView 14.x


Last edited by Sergey Tkachenko on Thu Mar 13, 2014 9:51 am; edited 4 times in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Thu Jun 17, 2010 2:51 pm    Post subject: Reply with quote

In the demos above, when the field value is a multiline plain text, this value cannot contain tab characters.

To fix this problem, replace InsertMultilineText function in these demos to the function from this file:
http://www.trichview.com/support/files/insertmultilinetextwithtabs.zip
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Wed Oct 13, 2010 8:40 am    Post subject: Reply with quote

Master-details demo:
http://www.trichview.com/support/files/master-detail.zip

This demo, like mailmerge-text4.zip, supports multiline text and picture fields. Fields are defined as text inside {}.
The main difference:this demo supports a master-detail relationship.
A template in this demo may contain tables linked to datasets. Such tables have a repeated group of rows; they are repeated as many times as many records in the linked dataset. If such table is inserted in a repeated row of another table, a master-detail relationship is established. Tables can be nested on any depth. The demo shows 3 levels of tables.
The demo uses Paradox tables, so BDE is required.

Detailed comments are at the beginning of the main form's unit.
---
2010-Oct-13: 0 matched records in a detail table is processed correctly.
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10708

PostPosted: Fri Jul 13, 2012 7:41 am    Post subject: Reply with quote

Protect-fields demo:
http://www.trichview.com/support/files/protectfields.zip

This demo does not actually make a mail merging.
It shows how to protect text fields.
When the user clicks on the "Protect" button, it searches for all occurrences of text inside {} and apply a special (protected) style to them.

This feature is useful, for example, if you want to have fields protected and store documents in RTF.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group