added some options and enhancements to the print output:
[obnox/wireshark/wip.git] / print.ps
1 %!
2 %
3 % Code between start/end remarks is put into ps.c
4 % Anything else is thrown away, and is for testing only.
5 %
6 % ---- ethereal preamble start ---- %
7 %!
8 %!PS-Adobe-2.0
9 %
10 % Ethereal - Network traffic analyzer
11 % By Gerald Combs <gerald@ethereal.com>
12 % Copyright 1998 Gerald Combs
13 %
14 %%Creator: Ethereal
15 %%Title: ethereal.ps
16 %%DocumentFonts: Helvetica Courier
17 %%EndComments
18 %!
19
20 %
21 % Ghostscript http://ghostscript.com/ can convert postscript to pdf files.
22 %
23 % To convert this postscript file to pdf, type (for US letter format):
24 % ps2pdf filename.ps
25 %
26 % or (for A4 format):
27 % ps2pdf -sPAPERSIZE=a4 filename.ps
28 %
29 % ... and of course replace filename.ps by your current filename.
30 %
31 % The pdfmark's below will help converting to a pdf file, and have no
32 % effect when printing the postscript directly.
33
34
35 %   This line is necessary if the file should be printable, and not just used
36 %   for distilling into PDF:
37 %
38 /pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse
39 %
40 %   This tells PDF viewers to display bookmarks when the document is opened:
41 %
42 [/PageMode /UseOutlines /DOCVIEW pdfmark
43
44 % Get the Imagable Area of the page
45 clippath pathbbox
46
47 % Set vmax to the vertical size of the page,
48 % hmax to the horizontal size of the page.
49 /vmax exch def
50 /hmax exch def
51 pop pop         % junk
52
53 % 1-inch margins
54 %/lmargin 72 def
55 %/tmargin vmax 72 sub def
56 %/bmargin 72 def
57 %/pagenumtab hmax 72 sub def
58
59 % 1/2-inch margins
60 /lmargin 36 def                                 % left margin
61 /tmargin vmax 56 sub def                % top margin
62 /bmargin 36 def                                 % bottom margin
63 /pagenumtab hmax 36 sub def     % right margin
64
65 % Counters
66 /vpos vmax 40 sub def
67 /thispagenum 1 def
68
69 % Strings
70 /pagenostr 7 string def
71
72
73 /formfeed {
74         printpagedecorations
75         showpage
76         
77         % we need a new current point after showpage is done
78         lmargin         % X
79         vpos            % Y
80         moveto
81         /vpos tmargin def
82 } def
83
84 % Prints text with possible indenting
85 /putline_single {
86         exch 10 mul lmargin add         % X
87         vpos                                            % Y
88         moveto
89         show
90
91         /vpos vpos 10 sub def
92
93         vpos bmargin le                         % is vpos <= bottom margin?
94         {
95                 formfeed
96         }
97         if                                                      % then formfeed and start at top
98 } def
99
100
101 % Prints text with possible indenting and line wrap
102 /putline {
103         /text exch def
104         /indent exch def
105         
106         % wrapat = width / sizeof font (remember: monospaced font)
107         /pagewidth pagenumtab bmargin sub def
108         /cwidth (A) stringwidth pop def
109         /wrapat pagewidth cwidth div cvi def
110                 
111         text length wrapat le {
112                 % print line
113                 indent text 0 text length getinterval putline_single
114         }{
115                 % print the lines first part
116                 indent text 0 wrapat getinterval putline_single
117                 % print wrapped rest
118                 indent text wrapat text length wrapat sub getinterval putline
119         }
120         ifelse
121 } def
122
123
124 % Prints the page number at the top right
125 /printpagedecorations {
126         gsave
127                 % Set the font to 8 point
128                 /Helvetica findfont 8 scalefont setfont
129
130                 % title
131                 lmargin                                         % X
132                 vmax 36 sub                                     % Y
133                 moveto
134                 eth_pagetitle show
135
136                 % this page number
137                 pagenumtab (Page ) stringwidth pop sub thispagenum pagenostr cvs stringwidth pop sub                                    % X
138                 vmax 36 sub                                     % Y
139                 moveto
140                 (Page ) show
141                 thispagenum pagenostr cvs show
142
143                 % thispagenum++
144                 /thispagenum thispagenum 1 add def
145                 
146                 % line at top of page
147                 lmargin                                         % X
148                 vmax 38 sub                                     % Y
149                 moveto
150                 
151                 pagenumtab                                      % X
152                 vmax 38 sub                                     % Y
153                 lineto
154                 stroke
155                 
156                 % line at bottom of page
157                 lmargin                                         % X
158                 bmargin                                         % Y
159                 moveto
160                 
161                 % title
162                 pagenumtab                                      % X
163                 bmargin                                         % Y
164                 lineto
165                 stroke
166                 
167         grestore
168 } def
169         
170 % Reset the vertical position
171 /vpos tmargin def
172
173 % ---- ethereal preamble end ---- %
174
175 % Set the font to 8 point
176 /Courier findfont 8 scalefont setfont
177
178 % the page title
179 /eth_pagetitle (Ethereal) def
180
181 % Display our output lines.
182
183 % PDF bookmark link
184 [/Dest /__frame1__ /Title (Frame 1)   /OUT pdfmark
185 [/View [/XYZ -4 currentpoint matrix currentmatrix matrix defaultmatrix
186  matrix invertmatrix matrix concatmatrix transform exch pop 20 add null]
187  /Dest /__frame1__ /DEST pdfmark
188  
189 % packet data
190 0 (Frame 1) putline
191 0 (Ethernet II \(98 on wire, 68 captured\)) putline
192 1 (Destination: 00:00:0c:36:00:2a) putline
193 1 (Source: 00:c0:4f:c7:eb:c0) putline
194 1 (Type: IP \(0x0800\)) putline
195 0 (Ethernet II \(98 on wire, 68 captured\)) putline
196 1 (Source: 00:c0:4f:c7:eb:c0) putline
197 1 (Type: IP \(0x0800\)) putline
198 0 (Source: 00:c0:4f:c7:eb:c0) putline
199
200 0 () putline
201 0 (0000  cc 00 00 00 00 00 07 02 00 00 00 00 00 00 00 00   ................ ) putline
202 0 (0010  00 00 bd 0e fe 16 01 00 3e 00 03 08 58 4c 20 38   ........>...XL 8 ) putline
203 0 (0020  30 20 49 4d 33 00 16 01 00 34 00 16 01 01 35 00   0 IM3....4....5. ) putline
204 0 (0030  16 01 02 36 00 16 01 03 6e 00 16 01 ff 6f 00 16   ...6....n....o.. ) putline
205 0 (0040  01 ff 70 00 16 01 ff 71 00 16 01 ff 48 00 01 04   ..p....q....H... ) putline
206 0 (0050  ff 03 07 00 24 00 01 01 05 25 00 01 01 05 26 00   ....$....%....&. ) putline
207 0 (0060  01 01 05 27 00 01 01 05 6a 00 01 01 00 6b 00 01   ...'....j....k.. ) putline
208 0 (0070  01 00 6c 00 01 01 00 6d 00 01 01 00 3d 00 01 02   ..l....m....=... ) putline
209 0 (0080  02 00 c0 00 03 08 80 00 00 00 00 00 00 00 b4 00   ................ ) putline
210 0 (0090  01 04 c0 a8 42 ef 39 00 16 08 05 05 05 05 00 00   ....B.9......... ) putline
211 0 (00a0  00 00 00 03 20 36 41 20 52 69 6e 67 00 00 00 00   .... 6A Ring.... ) putline
212 0 (00b0  00 00 00 00 00 00                                 ......           ) putline
213 formfeed
214
215
216 % PDF bookmark link
217 [/Dest /__frame2__ /Title (Frame 2)   /OUT pdfmark
218 [/View [/XYZ -4 currentpoint matrix currentmatrix matrix defaultmatrix
219  matrix invertmatrix matrix concatmatrix transform exch pop 20 add null]
220  /Dest /__frame2__ /DEST pdfmark
221  
222 % packet data
223 0 (Frame 2) putline
224 0 (Ethernet II \(98 on wire, 68 captured\)) putline
225 1 (Destination: 00:00:0c:36:00:2a) putline
226 1 (Source: 00:c0:4f:c7:eb:c0) putline
227 1 (Type: IP \(0x0800\)) putline
228 0 (Ethernet II \(98 on wire, 68 captured\)) putline
229 1 (Source: 00:c0:4f:c7:eb:c0) putline
230 1 (Type: IP \(0x0800\)) putline
231 0 (Source: 00:c0:4f:c7:eb:c0) putline
232
233 0 () putline
234 0 (0000  cc 00 00 00 00 00 07 02 00 00 00 00 00 00 00 00   ................ ) putline
235 0 (0010  00 00 bd 0e fe 16 01 00 3e 00 03 08 58 4c 20 38   ........>...XL 8 ) putline
236 0 (0020  30 20 49 4d 33 00 16 01 00 34 00 16 01 01 35 00   0 IM3....4....5. ) putline
237 0 (0030  16 01 02 36 00 16 01 03 6e 00 16 01 ff 6f 00 16   ...6....n....o.. ) putline
238 0 (0040  01 ff 70 00 16 01 ff 71 00 16 01 ff 48 00 01 04   ..p....q....H... ) putline
239 0 (0050  ff 03 07 00 24 00 01 01 05 25 00 01 01 05 26 00   ....$....%....&. ) putline
240 0 (0060  01 01 05 27 00 01 01 05 6a 00 01 01 00 6b 00 01   ...'....j....k.. ) putline
241 0 (0070  01 00 6c 00 01 01 00 6d 00 01 01 00 3d 00 01 02   ..l....m....=... ) putline
242 0 (0080  02 00 c0 00 03 08 80 00 00 00 00 00 00 00 b4 00   ................ ) putline
243 0 (0090  01 04 c0 a8 42 ef 39 00 16 08 05 05 05 05 00 00   ....B.9......... ) putline
244 0 (00a0  00 00 00 03 20 36 41 20 52 69 6e 67 00 00 00 00   .... 6A Ring.... ) putline
245 0 (00b0  00 00 00 00 00 00                                 ......           ) putline
246
247 % ---- ethereal finale start ---- %
248
249 % If this is not the first page, then print the page number
250 thispagenum 1 gt                                % is thispagenum > 1 ?
251 {
252         printpagedecorations
253 }
254 if
255
256 showpage
257 % ---- ethereal finale end ---- %