groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Groff] Printing address labels


From: Ted Harding
Subject: RE: [Groff] Printing address labels
Date: Wed, 13 Oct 2004 20:18:54 +0100 (BST)

On 13-Oct-04 John Poltorak wrote:
> 
> Can I use GROFF to print address labels from an SQL database?

You can certainly use it to print address labels.

However, there's no built-in mechanism for accessing an SQL
database.

What follows as a suggestion (it's what I've used for a standard
A4 sheet of 8 gummed address labels, 2 across by 4 down). You should
adjust the metrics in the macro to your own needs.

You would first need to get your SQL DB to issue a file "labels.tr"
like

.label 1
[first address]
./label
.label 2
[second address]
./label
....
.label 7
[7th address]
./label
.label 8
[8th address]
./label
.bp
.label 1
[9th address]
./label
....

i.e. you recycle the label numbers 1 ... 8 (maybe you can feed
the DB output to 'awk' or similar to obtain a file like the above).

Then process this file with groff as in

groff -Tps -mlabels label.tr > labels.ps

after which you can just print out the file "labels.ps" using
the label sheet (no other macro package is needed and, indeed,
is best avoided).

The contents of the macro file "label.tmac" (which should live
in the "tmac" directory) which I use are:

.de label
.nr PL 6.77c
.nr LL 9.91c
.if '\\$1'1' \{
. nr HM 1.3c
. nr PO 0.45c
.\}
.if '\\$1'2' \{
. nr HM 1.3c
. nr PO 10.36c
.\}
.if '\\$1'3' \{
. nr HM 8.07c
. nr PO 0.45c
.\}
.if '\\$1'4' \{
. nr HM 8.07c
. nr PO 10.36c
.\}
.if '\\$1'5' \{
. nr HM 14.84c
. nr PO 0.45c
.\}
.if '\\$1'6' \{
. nr HM 14.84c
. nr PO 10.36c
.\}
.if '\\$1'7' \{
. nr HM 21.61c
. nr PO 0.45c
.\}
.if '\\$1'8' \{
. nr HM 21.61c
. nr PO 10.36c
.\}
.vs 18p
.di envel_div
.br
.nf
.ad l
\f[HB]\s[12]\c
..
.de /label
.br
.di
.po \\n[PO]u+((\\n[LL]u-\\n[dl]u)/2u)
.sp |\\n[HM]u+((\\n[PL]u-\\n[dn]u)/2u)
.envel_div
.br
..

This then prints labels with the following layout:

 +-------------------+
 |         |         |
 |    1    |    2    |
 |         |         |
 +-------------------+
 |         |         |
 |    3    |    4    |
 |         |         |
 +-------------------+
 |         |         |
 |    5    |    6    |
 |         |         |
 +-------------------+
 |         |         |
 |    7    |    8    |
 |         |         |
 +-------------------+

with the dimensions, etc., as specified in the macros.

Of course, you may want to simply print directly onto envelopes,
in which case you don't need anything fancy: just position the
address within the frame of the envelope. Your only problem
then is getting the addresses out of the DB.

No doubt other readers have devised their own solutions to
this common sitation, and it will be interesting to study how
they've done it!

I hope this helps,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 13-Oct-04                                       Time: 20:18:54
------------------------------ XFMail ------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]