-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathftops
More file actions
executable file
·104 lines (84 loc) · 1.82 KB
/
Copy pathftops
File metadata and controls
executable file
·104 lines (84 loc) · 1.82 KB
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
#!/bin/sh
if [ X$1 != X ]; then
2>&1 cat <<\EOF
ftops is a simple filter, it reads from stdin and writes to stdout
it is used for converting files with \f<fontstyle> type font change
escapes to postscript. it is a quick hack to convert elvis .doc
files to postscript
e.g. usage;
refont -f *.doc | ftops > elvisDoc.ps
EOF
exit 1
fi
translate () {
sed \
-e 's,(,\\\(,g' \
-e 's,),\\\),g' \
-e 's,\\fB,) p B setfont (,g' \
-e 's,\\fI,) p I setfont (,g' \
-e 's,\\fR,) p R setfont (,g' \
-e 's,\\fU,) p U setfont (,g' \
-e 's,^,(,' \
-e 's,$,) ShoW_LinE,'
}
cat <<\PS_PROLOG
%!
%%Pages: (atend)
%%DocumentFonts Courier Courier-Oblique Courier-BoldOblique
%%Title: ftops shell script output
%%Creator: ftops
%%EndComments
/inch { 72 mul } bind def
/getfont { exch findfont exch scalefont } bind def
/SheetWidth 8.5 inch def
/SheetHeight 11 inch def
/LeftMargin 20 def
/TopMargin 20 def
/bodyfontsize 12 def
/bodyfont /Courier bodyfontsize getfont def
/R bodyfont def
/B /Courier-Bold bodyfontsize getfont def
/I /Courier-Oblique bodyfontsize getfont def
/U /Courier-BoldOblique bodyfontsize getfont def
/startpage
{
LeftMargin SheetHeight TopMargin sub moveto
R setfont
} def
/endpage { showpage } def
% Function s: print a source line
/s {
gsave show grestore
currentpoint
exch pop LeftMargin exch bodyfontsize sub
moveto
} def
/p { show } def
/ShoW_LinE { s } def
%%EndProlog
PS_PROLOG
translate | awk 'BEGIN {
lines=0
maxlines=66
pages=1
}
{ #MAIN
if ($NF~/ShoW_LinE/) {
++lines
}
if (lines==1) {
printf("%%%%Page: %d %d\n", pages, pages)
printf("startpage\n")
}
print
if (lines == maxlines) {
++pages
printf("endpage\n")
lines=0
}
}
END {
printf("%%%%Trailer\n")
printf("%%%%Pages: %d\n", pages)
} ' -
exit 0