-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpostscri.c
763 lines (619 loc) · 24 KB
/
postscri.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
/*
* $Id: postscri.c,v 1.2 1992/10/02 01:02:32 craigs Exp $
*
* This code was written by Craig Southeren whilst under contract
* to Computer Sciences of Australia, Systems Engineering Division.
* It has been kindly released by CSA into the public domain.
*
* Neither CSA or me guarantee that this source code is fit for anything,
* so use it at your peril. I don't even work for CSA any more, so
* don't bother them about it. If you have any suggestions or comments
* (or money, cheques, free trips =8^) !!!!! ) please contact me
* care of [email protected]
*
* Latin1 caracter set handling and fraction point sizes added by
* Jonas Lagerblad ([email protected]).
*
* handling for different classification banners for 1st page added by
* Daniel Risacher ([email protected])
*/
#include "machdep.h"
#include "defs.h"
#include "paper.h"
#include "postscri.h"
#include "fontwidt.h"
#include "font_lis.h"
#include <ctype.h>
/********************************
defines
********************************/
#define TAB 0x9
/********************************
imports
********************************/
#include "main.h"
/********************************
exports
********************************/
/********************************
globals
********************************/
static int touched_page = False;
static char *CurrentFilename;
static int WrapFlag;
static int GaudyFlag;
static int TabStop;
static long Columns; /* number of columns */
static long X;
static long Y;
static long BFH; /* body font height */
static long BFW; /* body font width */
static long TFH; /* title font height */
static long PageNum; /* page number within each documenr printed */
static long PageCount; /* total number of pages printed */
static int TitleEnabled; /* True if title to be displayed */
static long PW; /* page width transformed for landscape mode */
static long PH; /* page height transformed for landscape mode */
static long LM; /* left margin */
static long RM; /* right margin */
static long TM; /* top */
static long BM; /* bottom margin */
static long WW; /* width of current print window */
static unsigned int CPL; /* characters per line */
static long CC; /* current column */
static long LineNumber; /* number of line on page (1 top n) */
static long LinesPerPage; /* number of lines per page, or 0 if to use default */
static char *Classification_1st; /* points to string to use for classification */
static char *Classification; /* points to string to use for classification */
static long ColumnSep; /* width between columns */
static long ClassY; /* Y location to print classification at */
static long TitleY; /* Y location to print title at */
static long StartY; /* Y location to print text from */
static long EndY; /* Y location to print text down to */
static long ClassBottomY; /* Y location to print bottom classification at */
/*
* forward declarations if in ANSI mode
*/
#ifdef __STDC__
void PrintPSString (FILE *, unsigned char *, long);
void EndPage (FILE *);
void StartPage (FILE *);
void PrintLine (FILE *, char *, long, int);
static char * ExtractFontSize (char *, long *);
char *font;
#endif
/********************************
PrintPSString
Print a string of ASCII characters of length "len" as a
PostScript string, i.e. enclosed in brackets and with appropriate
escape characters.
********************************/
void PrintPSString (stream, line, len)
FILE *stream;
unsigned char *line;
long len;
{
register long i;
register unsigned char * str = line;
fprintf (stream, "(");
for (i = 0; i < len ; i++)
if ( str[i] & 0x80 )
fprintf (stream, "\\%03o", str[i]);
else
fprintf (stream, "%s%c", str[i] == ')' ||
str[i] == '(' ||
str[i] == '\\' ? "\\" : "", str[i]);
fprintf (stream, ")");
}
/********************************
ExtractFontSize
Extracts the fontsize from a font type description like "Courier10".
Also, copy the font name to the fontname ptr
********************************/
static char * ExtractFontSize (font, fontsize)
char *font;
long *fontsize;
{
char *p, *s, *t;
int i;
extern double atof();
/* get ptr to end of string */
p = &font[strlen(font)-1];
/* move backwards until we find a character that is not a digit */
while (p > font && (isdigit (*p) || *p == '.'))
p--;
/* extract the font size */
*fontsize = atof (++p) * SCALE;
/* now duplicate and copy the font name */
t = s = (char *)malloc (p - font + 1);
for (i = p - font; i> 0;i--)
*t++ = *font++;
*t = '\0';
return s;
}
/********************************
StartPage
Called to start a new page
********************************/
void StartPage (stream)
FILE *stream;
{
/* insert a page marker as per the Structuring conventions */
fprintf (stream, "%%%%Page: %li %li\n", PageNum, PageCount);
/* call the StartPage procedure with the appropriate arguments */
fprintf (stream, "(%li) ", PageNum);
PrintPSString (stream, CurrentFilename, strlen (CurrentFilename));
fprintf (stream, " StartPage\n");
/* set X and Y location */
X = LM;
Y = StartY;
/* set the column back to column 0 */
CC = 0;
/* set the line number to line # 1 */
LineNumber = 1;
/* we have now touched the page */
touched_page = True;
}
/********************************
EndPage
Called to complete a page
********************************/
void EndPage (stream)
FILE *stream;
{
/* call the end page procedure */
fprintf (stream, "EndPage\n");
/* increment both the job and document page counters */
PageNum++;
PageCount++;
/* now we haven't touched the page */
touched_page = False;
}
/*******************************
EndColumn
*******************************/
void EndColumn (stream)
FILE *stream;
{
LineNumber = 1;
CC++;
if (CC == Columns)
EndPage (stream);
else {
X += (ColumnSep * SCALE) + WW;
Y = StartY;
}
}
/********************************
PrintLine
Called to print a line which has been chopped to
the correct length already. The "first" flag indicates
whether the line is a normal line or a continuation line.
This routine performs the skipping for indents.
********************************/
void PrintLine (stream, line, count, first)
FILE *stream;
char *line;
long count;
int first;
{
long i;
if (!touched_page)
StartPage (stream);
/* make i point to the first non-blank character on the line */
for (i = 0; i < count && line[i] == ' ';i++)
;
if (i < count) {
if (!first)
fprintf (stream, "%li %li K ", Y, X);
PrintPSString (stream, &line[i], count - i);
if (i > 0)
fprintf (stream, " %li %li %i L\n", Y, X, i);
else
fprintf (stream, " %li %li T\n", Y, X);
}
Y -= BFH * 11 / 10; /* put a little bit of extra spacing between the characters */
LineNumber++;
if (Y < EndY || (LinesPerPage > 0 && LineNumber > LinesPerPage))
EndColumn (stream);
}
/********************************
WriteLine
Writes a line to the output. This routine performs the wrapping and tab expansion
********************************/
void WriteLine (stream, line)
FILE *stream;
char *line;
{
int first = True;
char *p;
char *q;
int col;
int i;
char full_line[8192];
/* expand tabs if we have to */
if (strchr (line, TAB) != NULL) {
col = 0;
q = full_line;
for (p = line; *p ; p++)
if (*p != TAB) {
*q++ = *p;
col = (col + 1) % TabStop;
} else {
for (i = TabStop - col; i > 0; i--)
*q++ = ' ';
col = 0;
}
*q = 0;
line = full_line;
}
if (WrapFlag) {
while (strlen(line) > CPL) {
PrintLine (stream, line, CPL, first);
first = False;
line += CPL;
}
PrintLine (stream, line, strlen(line), first);
} else
PrintLine (stream, line, MIN(strlen(line), CPL), True);
}
/********************************
StartDocument
Called when a new document is to be printed. Not to be confused with
starting the job.
********************************/
void StartDocument (stream, filename)
FILE *stream;
char *filename;
{
/* restart the internal page number */
PageNum = 1;
/* indicate that the first page has not yet been touched */
touched_page = False;
/* and set the current filename */
CurrentFilename = filename;
}
/********************************
EndDocument
Called when a document has been completed.
********************************/
void EndDocument (stream)
FILE *stream;
{
/* if we have drawn a partial page, finish it off properly */
if (touched_page)
EndPage (stream);
}
static char pspro_latin1_data[] = { "\
/newcodes % foreign character encodings\n\
[\n\
160/space 161/exclamdown 162/cent 163/sterling 164/currency\n\
165/yen 166/brokenbar 167/section 168/dieresis 169/copyright\n\
170/ordfeminine 171/guillemotleft 172/logicalnot 173/hyphen 174/registered\n\
175/macron 176/degree 177/plusminus 178/twosuperior 179/threesuperior\n\
180/acute 181/mu 182/paragraph 183/periodcentered 184/cedilla\n\
185/onesuperior 186/ordmasculine 187/guillemotright 188/onequarter\n\
189/onehalf 190/threequarters 191/questiondown 192/Agrave 193/Aacute\n\
194/Acircumflex 195/Atilde 196/Adieresis 197/Aring 198/AE 199/Ccedilla\n\
200/Egrave 201/Eacute 202/Ecircumflex 203/Edieresis 204/Igrave 205/Iacute\n\
206/Icircumflex 207/Idieresis 208/Eth 209/Ntilde 210/Ograve 211/Oacute\n\
212/Ocircumflex 213/Otilde 214/Odieresis 215/multiply 216/Oslash\n\
217/Ugrave 218/Uacute 219/Ucircumflex 220/Udieresis 221/Yacute 222/Thorn\n\
223/germandbls 224/agrave 225/aacute 226/acircumflex 227/atilde\n\
228/adieresis 229/aring 230/ae 231/ccedilla 232/egrave 233/eacute\n\
234/ecircumflex 235/edieresis 236/igrave 237/iacute 238/icircumflex\n\
239/idieresis 240/eth 241/ntilde 242/ograve 243/oacute 244/ocircumflex\n\
245/otilde 246/odieresis 247/divide 248/oslash 249/ugrave 250/uacute\n\
251/ucircumflex 252/udieresis 253/yacute 254/thorn 255/ydieresis\n\
] def\n\
\n\
/reencdict 12 dict def\n\
\n\
" };
static char pspro_latin1_func[] = { "\n\
% change fonts using ISO Latin1 characters\n\
/ChgFnt % size psname natname => font\n\
{\n\
dup FontDirectory exch known % is re-encoded name known?\n\
{ exch pop } % yes, get rid of long name\n\
{ dup 3 1 roll ReEncode } ifelse % no, re-encode it\n\
findfont exch scalefont setfont\n\
} def\n\
\n\
/ReEncode %\n\
{\n\
reencdict begin\n\
/newname exch def\n\
/basename exch def\n\
/basedict basename findfont def\n\
/newfont basedict maxlength dict def\n\
basedict\n\
{ exch dup /FID ne\n\
{ dup /Encoding eq\n\
{ exch dup length array copy newfont 3 1 roll put }\n\
{ exch newfont 3 1 roll put } ifelse\n\
}\n\
{ pop pop } ifelse\n\
} forall\n\
newfont /FontName newname put\n\
newcodes aload pop newcodes length 2 idiv\n\
{ newfont /Encoding get 3 1 roll put } repeat\n\
newname newfont definefont pop\n\
end\n\
} def\n\
\n\
" };
/********************************
StartJob
Called when a new job is to be started. This performs all of the
PostScript initialisation
********************************/
void StartJob (stream, filename, landscape, columns, BodyFont,
TitleFont, wrap, enabletitle, title, copies, gaudy, force_lines, classification_1st, classification, papermetrics, tabstop)
FILE * stream;
int landscape;
int columns;
char *BodyFont;
char *TitleFont;
int wrap;
int enabletitle;
char *title;
int copies;
int gaudy;
int force_lines;
char *filename;
char *classification_1st;
char *classification;
struct PaperMetrics *papermetrics;
int tabstop;
{
char *bodyfont;
char *titlefont;
char *gaudyPNfont;
char *gaudytitlefont;
char *gaudydatefont;
char *classfont;
long gaudyPNfontsize;
long gaudytitlefontsize;
long gaudydatefontsize;
long classfontsize;
time_t thetime = time(NULL);
char * timestring = strtok(ctime (&thetime), "\n"); /* a simple time string */
struct tm *tm = localtime (&thetime);
char tm_string[15];
char dt_string[15];
/* get the time and date strings */
GETDATE (tm, dt_string);
GETTIME (tm, tm_string);
/* make local copies of various flags */
WrapFlag = wrap;
GaudyFlag = gaudy && enabletitle;
TitleEnabled = enabletitle;
Columns = columns;
LinesPerPage = force_lines;
Classification_1st = classification_1st;
Classification = classification;
ColumnSep = papermetrics->ColumnSep;
TabStop = tabstop;
/* get the size and width of the font used for the body of the text */
bodyfont = ExtractFontSize (BodyFont, &BFH);
BFW = GetFontWidth (bodyfont, BFH);
/* extract various font sizes */
gaudyPNfont = ExtractFontSize (papermetrics->GaudyPNFont, &gaudyPNfontsize);
gaudytitlefont = ExtractFontSize (papermetrics->GaudyTitleFont, &gaudytitlefontsize);
gaudydatefont = ExtractFontSize (papermetrics->GaudyDateFont, &gaudydatefontsize);
/* get the size of the font used for the title */
titlefont = ExtractFontSize (TitleFont, &TFH);
/* now the classification font, if there is one */
if (Classification != NULL || Classification_1st != NULL)
classfont = ExtractFontSize (papermetrics->ClassificationFont, &classfontsize);
/* output obligatory Postscript header */
fprintf (stream, "%%!PS-Adobe-1.0\n");
/* output the filename of the first file as the title */
fprintf (stream, "%%%%Title: %s\n", filename);
/* put version of program in as creator */
fprintf (stream, "%%%%Creator: %s\n", version_string);
/* extract the users full name and put in as the creator */
fprintf (stream, "%%%%For: %s\n", USERNAME);
/* put in the time as a string */
fprintf (stream, "%%%%CreationDate: %s\n", timestring);
/* output the font list */
add_font_to_list (titlefont);
add_font_to_list (bodyfont);
if (GaudyFlag) {
add_font_to_list (gaudyPNfont);
add_font_to_list (gaudydatefont);
add_font_to_list (gaudytitlefont);
}
if (Classification != NULL || Classification_1st != NULL)
add_font_to_list (classfont);
fprintf (stream, "%%%%DocumentFonts: ");
enumerate_fonts (stream);
fprintf (stream, "\n");
/* initialise the document page counter and indicate that the page count info
can be found at the end of the document. This copout means we don't have
to store the output data in a temporary file (like enscript) just so we can
find out how many pages there are */
PageCount = 1;
fprintf (stream, "%%%%Pages: (atend)\n");
/* End of header marker */
fprintf (stream, "%%%%EndComments\n");
/* allow Latin-1 character set by remapping most characters above 127 */
fprintf (stream, "%s\n%s", pspro_latin1_data, pspro_latin1_func);
/* scale the coordinate system by SCALE so we can use integer arithmetic
without losing accuracy */
fprintf (stream, "1 %li div dup scale\n", SCALE);
/* use the Postscript mechanism for duplicating pages, rather than using a flag to lpr.
This mechanism means less data (I think!!) but it requires you to edit the file
if you want to print a different number of copies later. It is so rarely used that
it isn't really an issue anyway!! */
fprintf (stream, "/#copies %i def\n", copies);
/* rotate the page if using landscape mode, and set PW and PH to the page width and height
as determined by the SCALE factor */
if (landscape) {
PW = papermetrics->PaperHeight * SCALE;
PH = papermetrics->PaperWidth * SCALE;
LM = PAGE_BOT_MARGIN * SCALE;
RM = PAGE_TOP_MARGIN * SCALE;
TM = PAGE_LEFT_MARGIN * SCALE;
BM = PAGE_RIGHT_MARGIN * SCALE;
fprintf (stream, "90 rotate %li %li translate\n",PAGE_LANDSCAPE_XOFFS, PAGE_LANDSCAPE_YOFFS - PH);
} else {
PH = papermetrics->PaperHeight * SCALE;
PW = papermetrics->PaperWidth * SCALE;
LM = PAGE_LEFT_MARGIN * SCALE;
RM = PAGE_RIGHT_MARGIN * SCALE;
TM = PAGE_TOP_MARGIN * SCALE;
BM = PAGE_BOT_MARGIN * SCALE;
}
/* calculate the width of the "window" in which we draw text, and from that calculate the
number of characters per line (CPL) */
WW = (PW - (LM + RM) - ((columns - 1) * papermetrics->ColumnSep * SCALE)) / columns;
CPL = (unsigned int)(WW / BFW);
/* calculate the top position at which we start drawing text */
StartY = PH - TM;
/* adjust starting position if we are printing security classification */
if (Classification != NULL || Classification_1st != NULL) {
StartY -= classfontsize;
ClassY = StartY;
}
/* adjust starting position if we are printing title */
if (TitleEnabled) {
if (GaudyFlag) {
TitleY = StartY;
StartY -= (papermetrics->GaudyBoxHeight * SCALE) + BFH; /* StartY -= BH + BFH; */
} else {
StartY -= TFH;
TitleY = StartY;
StartY -= BFH;
}
}
/* move down one line below for start of text */
StartY -= BFH;
/* calculate the last location on the page to be printing text */
EndY = BM;
if (Classification != NULL || Classification_1st != NULL) {
ClassBottomY = BM;
EndY += classfontsize;
}
/* define a variable for our body font, and calculate the character width for later use */
fprintf (stream, "/BodyF { %li /%s /%s-Latin1 ChgFnt } def\n", BFH, bodyfont,
bodyfont);
fprintf (stream, "/CW BodyF ( ) stringwidth pop def\n");
/* define variables for various other font used - title, gaudy page number, gaudy date, gaudy title */
fprintf (stream, "/Titlef { %li /%s /%s-Latin1 ChgFnt } def\n", TFH, titlefont,
titlefont);
if (GaudyFlag) {
fprintf (stream, "/Gpnf { %li /%s /%s-Latin1 ChgFnt } def\n", gaudyPNfontsize,
gaudyPNfont, gaudyPNfont);
fprintf (stream, "/Gdatef { %li /%s /%s-Latin1 ChgFnt } def\n",
gaudydatefontsize, gaudydatefont, gaudydatefont);
fprintf (stream, "/Gtitlef { %li /%s /%s-Latin1 ChgFnt } def\n",
gaudytitlefontsize, gaudytitlefont, gaudytitlefont);
}
/* define procedures for drawing continuation line markers, continuation lines, normal lines, and performing indents */
fprintf (stream, "/K { -2 CW mul add exch moveto (+) show } def\n");
fprintf (stream, "/L { CW mul add exch moveto show } def\n");
fprintf (stream, "/T { exch moveto show } def\n");
fprintf (stream, "/M { CW mul 0 rmoveto } def\n");
fprintf (stream, "/Centre { dup stringwidth pop 2 div neg 0 rmoveto } def\n");
/* define procedures for drawing gaudy page numbers, gaudy boxes, gaudy bars and gaudy titles */
if (GaudyFlag) {
fprintf (stream, "/Gb { newpath moveto %li 0 rlineto 0 %li rlineto -%li 0 rlineto fill } def\n",
papermetrics->GaudyBoxWidth * SCALE, /* BW */
papermetrics->GaudyBoxHeight * SCALE, /* BH */
papermetrics->GaudyBoxWidth * SCALE); /* BW */
fprintf (stream, "/Gr { newpath moveto %li 0 rlineto 0 %li rlineto -%li 0 rlineto fill } def\n",
PW - (LM + RM) - (2 * papermetrics->GaudyBoxWidth * SCALE), papermetrics->GaudyBarHeight * SCALE,
PW - (LM + RM) - (2 * papermetrics->GaudyBoxWidth * SCALE));
fprintf (stream, "/G { %s setgray %li %li Gb %li %li Gb %s setgray %li %li Gr } def\n",
BOXGRAY,
LM, TitleY - (papermetrics->GaudyBoxHeight * SCALE), /* pos of left box */
PW - RM - (papermetrics->GaudyBoxWidth * SCALE), TitleY - (papermetrics->GaudyBoxHeight * SCALE), /* pos of right box */
BARGRAY,
LM + (papermetrics->GaudyBoxWidth * SCALE), TitleY - (papermetrics->GaudyBoxHeight * SCALE)); /* pos of bar */
}
/* define stuff for security strings */
if (Classification != NULL || Classification_1st != NULL) {
fprintf (stream, "/Classf { %li /%s /%s-Latin1 ChgFnt } def\n", classfontsize, classfont, classfont);
fprintf (stream, "/ClassString ");
if (Classification != NULL) {
PrintPSString (stream, Classification, strlen(classification));
} else {
fprintf (stream, " () ");
}
fprintf (stream, " def\n");
fprintf (stream, "/Class1String ");
if (Classification_1st != NULL) {
PrintPSString (stream, Classification_1st, strlen(classification_1st));
} else if (Classification != NULL) {
PrintPSString (stream, Classification, strlen(classification));
} else {
fprintf (stream, " () ");
}
fprintf (stream, " def\n");
}
/* if we have titles enabled, define an appropriate procedure for drawing it */
/* define the start page procedure used to start every page */
fprintf (stream, "/StartPage { /SavedPage save def\n");
if (Classification != NULL || Classification_1st != NULL) {
fprintf (stream, " Classf %li %li moveto 1 index (1) eq { Class1String } { ClassString } ifelse Centre 0 setgray show\n", PW / 2, ClassY);
fprintf (stream, " Classf %li %li moveto 1 index (1) eq { Class1String } { ClassString } ifelse Centre 0 setgray show\n", PW / 2, ClassBottomY);
}
if (TitleEnabled) {
if (GaudyFlag) {
fprintf (stream, " G\n"); /* draw boxes */
fprintf (stream, " Gtitlef %li %li moveto Centre 0 setgray show\n", /* title */
((LM + (papermetrics->GaudyBoxWidth * SCALE)) +
(PW - RM - (papermetrics->GaudyBoxWidth * SCALE))) / 2L,
TitleY - (papermetrics->GaudyBoxHeight * SCALE) +
(((papermetrics->GaudyBarHeight * SCALE) * 7L / 10L) / 2L));
if (title != NULL) {
fprintf (stream, "%li %li moveto ",
((LM + (papermetrics->GaudyBoxWidth * SCALE)) + (PW - RM - (papermetrics->GaudyBoxWidth * SCALE))) / 2L,
TitleY - (((papermetrics->GaudyBarHeight * SCALE) * 7L / 10L) / 2L));
PrintPSString (stream, title, strlen(title));
fprintf (stream, " Centre show\n");
}
fprintf (stream, " Gpnf %li %li moveto Centre 1 setgray show\n", /* page number */
PW - RM - ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
TitleY - ((papermetrics->GaudyBoxHeight * SCALE) / 2L) - gaudyPNfontsize * 7L / 20L);
fprintf (stream, " Gdatef %li %li moveto (%s) Centre 0 setgray show\n",
LM + ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
TitleY - ((papermetrics->GaudyBoxHeight * SCALE) * 3L / 5L) - gaudydatefontsize * 7L / 10L, tm_string);
fprintf (stream, " %li %li moveto (%s) Centre show\n",
LM + ((papermetrics->GaudyBoxWidth * SCALE) / 2L),
TitleY - ((papermetrics->GaudyBoxHeight * SCALE) * 3L / 5L) + gaudydatefontsize * 7L / 10L, dt_string);
} else {
fprintf (stream, " 0 setgray Titlef %li %li moveto ", LM, TitleY);
if (title != NULL) {
fprintf (stream, "pop pop ");
PrintPSString (stream, title, strlen(title));
fprintf (stream, " show\n");
} else {
fprintf (stream, "show 8 M ");
PrintPSString (stream, timestring, strlen (timestring));
fprintf (stream, " show 8 M show\n");
}
}
}
fprintf (stream, " BodyF 0 setgray } def\n");
/* define end page procedure */
fprintf (stream, "/EndPage {");
if (GaudyFlag && Columns == 2)
fprintf (stream, " %li %li moveto %li -%li rlineto stroke ", LM + WW + (papermetrics->ColumnSep * SCALE / 2), StartY, 0L, StartY - EndY);
fprintf (stream, "showpage SavedPage restore } def\n");
/* end of the header */
fprintf (stream, "%%%%EndProlog\n");
}
/********************************
EndJob
********************************/
void EndJob (stream)
FILE *stream;
{
/* indicate this is the end of the file */
fprintf (stream, "%%%%Trailer\n");
/* now we know how many pages there are!! */
fprintf (stream, "%%%%Pages: %li\n", PageCount - 1);
}