Document Merge Tutorial
Document Merge (sometimes called "Mail Merge") is a powerful feature that allows a unique label or card to be printed for each record in an external data source. It is however, the most mis-understood feature of gLabels. The following examples will step through a couple of common tasks using the document merge feature.
5.1. Example 1: Name Tags Using a CSV File
In this example we are organizing an orientation party for the new crew members of our ship. We have a list of freshman crew members that we created in gnumeric and exported as the following CSV file. We could have created this file by using a text editor, but heck it is the 23rd century.
Name,Department,SN "Jim Kirk",Management,"SC937-0176 CEC" "Mr. Spock",Sciences,S179-276SP "Leonard McCoy",Medicine,unknown "Montgomery Scott",Engineering,SE-197-54T
In gLabels we have created a new gLabels document using the Avery 5395 "Name Badge Labels" template. Next we use the menu item to display the merge properties dialog. We use this dialog to select the source type (in our case CSV) and the merge source (filename) as shown.
Before applying the merge source, we uncheck the first record since it is only column headers from our original gnumeric spreadsheet and would simply waste our first label. We could also unselect any other records that we didn't want to print a label for.
We can also view each record in more detail by clicking on the appropriate expander (the little triangles) as shown. Once we are satisfied with the selections in this dialog we click
to accept the changes.Now we start adding objects to our gLabels document as shown.
In this example we have added three text objects and a barcode object. The first text object contains only simple literal text ("Hello, my name is"). The second text object contains a single merge field ("${1}") corresponding to the first field of a record (first column of a line) which contains the new crew member's full name. The third text field contains both literal text ("Department: ") followed by a single merge field ("${2}") corresponding to the second field or the crew member's department. The barcode object is configured to use field (or key) "3" which contains our crew member's starfleet serial number.
Now we can print our name tags by selecting the
menu item. This will display print dialog as shown below.Just to make sure our labels are going to look okay, we select the Print outlines option and click . This will display a print preview dialog as shown below.
Everything looks good, so we can now load up our printer with the appropriate label stock, print our name tags and start beaming our guests aboard.
5.2. Example 2: Address Labels Using a CSV File
In this example we are going to throw a party and need to print mailing address labels for our invitations. We have a list of our closest friends that we created in gnumeric and exported as the following CSV file. It should be noted that not everyone has a middle initial or a two line address.
LAST,FIRST,MI,ADDR1,ADDR2,CITY,STATE,ZIP ,,,,,,, Critter,Ess,S,"123 Faux St.",,Alexandria,VA,22310 Doe,John,,"Apt 1X","451 Mystery St.",Trenton,NJ,08601 Summers,Joyce,,"1630 Revello Dr",,Sunnydale,CA,95037 McGarret,Steve,O,"404 Piikoi Street",,Honolulu,HI,96813 Kramer,Cosmo,,"Apt 5B","129 W. 81 St.","New York",NY,10024-7207
In gLabels we have created a new gLabels document using the Avery 5512 "Address Labels" template. Next we use the menu item to display the merge properties dialog. We use this dialog to select the source type (in our case CSV) and the merge source (filename) as shown.
Before applying the merge source, we uncheck the first record since it is only column headers from our original gnumeric spreadsheet and would simply waste our first label. We also unselect the second record which is empty (an artifact of our original spreadsheet). We could also unselect any other records that we didn't want to print a label for.
We can also view each record in more detail by clicking on the appropriate expander (the little triangles) as shown. Once we are satisfied with the selections in this dialog we click
to accept the changes.Now we start adding objects to our gLabels document as shown.
In this example we have a single text object. This text object contains all of our merge fields organized on multiple lines as a mailing address. Notice that fields ${4} and ${5} (corresponding to ADDR1 and ADDR2) are each located with no other text on their own lines. When gLabels encounters a field as the only text on a line, it will not expand the line if the field is empty.
Now we can print our address labels by selecting the
menu item. This will display print dialog as shown below.Just to make sure our labels are going to look okay, we select the Print outlines option and click . This will display a print preview dialog as shown below.
Everything looks good, so we can now load up our printer with the appropriate label stock, print our address labels and start mailing our party invitations.
5.3. Example 3: Address Labels Using the Evolution Addressbook
Our last party was a great success, and now we need to print mailing address labels for the invitations to a new one. To simplify this, we can use the Evolution addressbook, because the address data of all our friends is stored there.
Depending on how your copy of gLabels was packaged, this option could be unavailable. Support for the Evolution addressbook will only be available if the evolution-data-server and its development files were present when gLabels was built. Please keep this in mind if you build gLabels directly from source.
If the gLabels package from your distribution lacks this support, you may wish to contact the package maintainer or file a bug against the package to request it.
In glabels we have created a new gLabels document using the Avery 5512 "Address Labels" template. Next we use the menu item to display the Merge properties dialog. We use this dialog to select the source type (in our case Data from default Evolution addressbook) as shown.
Once we have chosen Data from default Evolution addressbook as our merge source, we will get a full list of its content. Initially, all entries are checked. Assuming we were planning a really big party, we could leave this selection untouched (but let's keep our budget in mind). We will now select or unselect certain entries by clicking on the appropriate checkboxes, or we could use the and buttons to activate or deactivate all entries in the address book.
We can also view each entry in more detail by clicking on the appropriate expander (the little triangles) as shown. Once we are satisfied with the selections in this dialog, we will click the
button to accept the changes.Now we start adding objects to our glabels document as shown.
In this example we have a single text object again. This text object contains all of our merge fields organized on multiple lines as a mailing address.
Now we can print our address labels by selecting the
menu item. This will display the print dialog as shown below.Just to make sure our labels are going to look okay, we select the Print outlines option and click . This will display a print preview dialog as shown below.
Everything looks good, so we can now load up our printer with the appropriate label stock, print our address labels and start mailing our party invitations.