Thread View: comp.lang.postscript
1 messages
1 total messages
Started by David Baraff
Sun, 31 Jan 1988 05:32
Postscript manual-feed envelope program
Author: David Baraff
Date: Sun, 31 Jan 1988 05:32
Date: Sun, 31 Jan 1988 05:32
173 lines
4930 bytes
4930 bytes
Here's a program I use for printing envelopes on an Apple Laser
Writer. It uses the manualfeed option, so you can insert envelopes
into the manual feed. (Actually, push the envelope in until something
inside grabs it. You'll here a click. Then wait a second, and when
it actually starts feeding it in, help it if needed).
I find this produces really good looking envelopes (professional!)
if you use heavy paper for your envelopes. Anyway, here it is
in case you find it useful. Cut out the program below, stick
it in a file (e.g. 'psenv.c') and simply
$ cc psenv.c -o psenv
and
$ psenv adr-file | lpr -Ppostscript (or whatever)
Any comments appreciated.
-----------------------------Cut Here---------------------------------------
/*
David Baraff
Cornell University
Output postscript suitable for an Apple LaserWriter
to print addresses on envelopes (using manual feed).
The envelopes are put in with the upper (long) edge
parallel to the left edge of the manual feed tray.
Note that the text is rotated 90 degrees to account
for this.
I found that "heav-duty" enveloped (e.g. thick yellowish
ones) comd out much better than ordinary white ones, which
have a tendency to either wrinkle or (worse) seal themselves!
(Well, one could always put the letter in the envelope first,
thereby saving even more time!)
-------------------------------------------------------------
An entry in the input file consists of a return address
followed by a sender address, seperated by a line containing only
a '.'. There may be any number of entries in the input
file, each seperated also by a line containing only a '.'.
Each entry generates a seperate envelope.
E.g.:
John Q. Public
13 Main Ave.
Smalltown, KA. 12343
.
Zippy Pinhead
516 Flatstreet
San Jose, CA. 96524
.
Jane Doe
(etc)
.
Tom Smith
(etc)
Usage:
psenv [file]
If file is not present, the standard input is read. Postscript
output is produced on the standard output, and a count of
envelopes is written to standard error.
Enjoy!
*/
#include <stdio.h>
#define FROM_HOFFSET .5 /* return address position */
#define FROM_VOFFSET .5 /* (in inches) */
#define TO_HOFFSET 4.25 /* sendee addres position */
#define TO_VOFFSET 2.5 /* (in inches) */
#define FONT "Helvetica" /* Must be a valid postscript
font name */
#define PS 12 /* point size (in points) */
#define VS 14 /* vertical size (in points) */
static char s[256];
char *readline(f)
FILE *f;
{
if(fgets(s, 256, f) == NULL)
return NULL;
if(s[strlen(s) - 1] == '\n') /* remove newlines */
s[strlen(s) - 1] = '\0';
if(strlen(s) == 1 && s[0] == '.') /* item seperator */
return NULL;
return s;
}
main(argc, argv)
int argc;
char *argv[];
{
FILE *input = stdin;
int ctr = 0;
char *readline(), *buffer;
if(argc > 2)
{
fprintf(stderr, "Usage: %s [file]\n", argv[0]);
exit(-1);
}
if(argc == 2)
if((input = fopen(argv[1], "r")) == NULL)
{
fprintf(stderr, "%s: Cannot read address file '%s'\n",
argv[0], argv[1]);
exit(-1);
}
printf("%%! *** Automatic Envelope Program ***\n");
printf("%% David Baraff\n");
printf("%% Cornell University\n\n");
printf("%%%% Begin Prolog\n\n");
printf("statusdict begin currentdict /manualfeed true put end\n");
printf("/inch { 72 mul } def\n");
printf("-90.0 rotate\n");
printf("-11.0 inch 0 inch translate\n");
printf("/%s findfont %d scalefont setfont\n", FONT, PS);
printf("%%%% End Prolog\n\n");
while(!feof(input))
{
double xpos = FROM_HOFFSET,
ypos = FROM_VOFFSET;
int wrote_something = 0;
printf("%%%% Envelope #%d\n\n", ++ctr);
while((buffer = readline(input)) != NULL)
{
wrote_something = 1;
printf("%g inch %g inch moveto (%s) show\n",
xpos, 8.5 - ypos, buffer);
ypos += (1./72.) * VS;
}
xpos = TO_HOFFSET;
ypos = TO_VOFFSET;
while((buffer = readline(input)) != NULL)
{
wrote_something = 1;
printf("%g inch %g inch moveto (%s) show\n",
xpos, 8.5 - ypos, buffer);
ypos += (1./72.) * VS;
}
if(wrote_something)
printf("\ngsave showpage grestore\n\n");
else
ctr--;
}
fprintf(stderr, "[Printing %d envelopes on standard output]\n", ctr);
}
----------------------Cut Here------------------------------------
David Baraff deb@svax.cs.cornell.edu
Program of Computer Graphics
Cornell University
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads