summaryrefslogtreecommitdiff
path: root/man/2/print
blob: 575ede771f9f34e6ef22f511a3a1307cb6e38283 (plain)
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
.TH PRINT 2
.SH NAME
Print \- printing system
.SH SYNOPSIS
.EX
include "print.m";
print := load Print Print->PATH;

Print: module
{
	PATH: con "/dis/lib/print/print.dis";
	CONFIG_PATH: con "/lib/print/";

	init: fn(): int;
	set_printfd: fn(fd: ref Sys->FD);
	print_image: fn(p: ref Printer, display: ref Draw->Display, im: ref Draw->Image, pcwidth: int): int;
	print_textfd: fn(p: ref Printer, fd: ref Sys->FD, ps: real, pr: int, wrap: int): int;
	get_defprinter: fn(): ref Printer;
	set_defprinter: fn(p: ref Printer);
	get_size: fn(p: ref Printer): (int, real, real);	# dpi, xinches, yinches
	get_printers: fn(): list of ref Printer;
	get_papers: fn(): list of ref Paper;
	save_settings: fn(): int;

# Printer types

Ptype: adt {
	name: string;
	modes: list of ref Pmode;
	driver: string;
	hpmapfile: string;
};

# Paper sizes

Paper: adt {
	name: string;
	hpcode: string;
	width_inches: real;
	height_inches: real;
};



# Print modes

Pmode: adt {
	name: string;
	desc: string;
	resx: int;
	resy: int;
	blackdepth: int;
	coldepth: int;
	blackresmult: int;
};

# Print options

Popt: adt {
	name: string;
	mode: ref Pmode;
	paper: ref Paper;
	orientation: int;
	duplex: int;
};

# Printer instance

PORTRAIT: con 0;
LANDSCAPE: con 1;

DUPLEX_OFF: con 0;
DUPLEX_LONG: con 1;
DUPLEX_SHORT: con 2;

Printer: adt {
	name: string;
	ptype: ref Ptype;
	device: string;
	popt: ref Popt;
	pdriver: Pdriver;
};

};


Pdriver: module
{
	PATHPREFIX: con "/dis/lib/print/";
	DATAPREFIX: con "/lib/print/";

	init: fn(debug: int);
	sendimage: fn(p: ref Print->Printer, tfd: ref Sys->FD, display: ref Draw->Display, im: ref Draw->Image, width: int, lmargin: int): int;
	sendtextfd: fn(p: ref Print->Printer, pfd, tfd: ref Sys->FD, ps: real, pr: int, wrap: int): int;
	printable_pixels: fn(p: ref Print->Printer): (int, int);

};


.EE
.SH DESCRIPTION
The
.I Print
module provides an interface to one or more printers.
.SS "The Print module"
.TP
.BI init()
.B Init
must be called once to initialise the internal state of
.BR Print .
.TP
.BI set_printfd( fd )
.B set_printfd
provides a file descriptor to be used for output. By default, output is sent to the file or device
specified in the
.B Printer
adt.
.TP
.BI print_image( p, display, im, pcwidth )
.B print_image
prints a page containing a single image. The image is centred horizontally, and is scaled up to fill the percentage of the available
width specified by 
.I pcwidth.
.TP
.BI print_textfd( p, fd, ps, pr, wrap )
.B print_textfd
prints one or more pages of text on printer 
.I p
from the file open for reading on 
.I fd.
The point size is controlled by 
.I p.
If the printer does not support the specified point size an alternative size will be used.
A point size of 0.0 can be used to select the printer's default size (usually 12 point).
If 
.I pr is non-zero, a proportionally-spaced font will be used (if available).
If
.I wrap
is non-zero, lines will be wrapped if they overflow the page width (if this feature is supported by the printer).
.TP
.BI get_defprinter(  )
.B get_defprinter
returns the default printer (in
.I /lib/print/defprinter).
.TP
.BI set_defprinter( p  )
.B set_defprinter
sets the default printer (in
.IR /lib/print/defprinter ).
.TP
.BI get_size(  p  )
.B get_size
returns the resolution in dots per inch and the total number of pixels available for printing in the x and y direction.
Before calling this function the 
.I orientation
should be set if required.
.TP
.BI get_printers(  )
.B get_printers
returns a list of all available printers (in 
.I /lib/print/printer.cfg).
.TP
.BI get_papers(  )
.B get_papers
returns a list of all available paper sizes (in 
.I /lib/print/paper.cfg).
.SS "Data Structures"
.TP
.BI Ptype
 - specifies a Printer Type, with fields:
.RS
.PD
.TP
.B name:
Name used to refer to this printer type
.TP
.B desc
Description
.TP
.B modes
List of supported print modes
.TP
.B driver:
The .dis file specification of the printer driver
.TP
.B hpmapfile:
For HP printers, the name of the color map file
.RE
.TP
.BI Paper
 - specifies the dimensions of a type of paper
.RS
.PD
.TP
.B name:
Name used to refer to this paper size
.TP
.B hpcode:
For HP printers, PCL code used for this paper size
.TP
.B width_inches:
Width of paper in inches
.TP
.B height_inches:
Height of paper in inches
.RE
.TP
.BI Pmode
 - specifies a print mode
.RS
.PD
.TP
.B name:
Name used to refer to this print mode
.TP
.B desc:
Description
.TP
.B resx:
X resolution in dots per inch
.TP
.B resx:
Y resolution in dots per inch
.TP
.B blackdepth:
Depth of black component in bytes
.TP
.B coldepth:
Depth of color components in bytes
.TP
.B blackresmult:
Resolution multiplier of black component (1 means same as base x resolution)
.RE
.TP
.BI Popt
 - specifies a set of Print Options
.RS
.PD
.TP
.B name:
Name of a Printer to which these print options apply
.TP
.B mode:
The name of a print mode
.TP
.B paper:
The name of a paper size
.TP
.B orientation:
Paper orientation - either PORTRAIT or LANDSCAPE
.TP
.B duplex (NB DUPLEX IS NOT CURRENTLY SUPPORTED):
Duplex setting - DUPLEX_OFF or DUPLEX_SHORT or DUPLEX_LONG 
.RE
.TP
.BI Printer
 - specifies a printer instance
.RS
.PD
.TP
.B name:
Name used to refer to this printer
.TP
.B ptype:
The printer type
.TP
.B device:
The name of the file to be used for output (eg /dev/lpt1data)
.TP
.B popt:
The print options
.TP
.B driver:
The printer driver module handle
.RE
.SS "Configuration Files"
.PP
There are configuration files to initialize the Printer Types, Print Modes, Paper Sizes Printers and Print Modes.
They all have a similar format, with fields corresponding to the relevant adt.
Here is an extract from the 
.I paper.cfg
file:
.PP
.EX
A4=
	hpcode=26
	width_inches=8.3
	height_inches=11.7
A5=
	hpcode=25
	width_inches=4.15
	height_inches=5.85
.EE
.PP
Aliases can also be defined, such as
.PP
.EX
myA4=A4
.EE
.PP
The final configuration file, 
.B defprinter,
just contains the name of the default printer.
.SH FILES
.TP
.B /lib/print/*.map
HP color maps.
.TP
.BI /lib/print/ptype.cfg
Print Type configuration file.
.TP
.BI /lib/print/pmode.cfg
Print Mode configuration file.
.TP
.BI /lib/print/paper.cfg
Paper Size configuration file.
.TP
.BI /lib/print/printer.cfg
Printer Instance configuration file.
.TP
.BI /lib/print/popts.cfg
Print options configuration file.
.TP
.BI /lib/print/defprinter
Holds the name of the default printer. Not needed if there is only one printer available.
.SH SOURCE
.TF /appl/lib/print/print.b
.TP
.B /appl/lib/print/print.b
Implementation of the
.B Print
module.
.TP
.B /appl/lib/print/*_driver.b
Printer-specific driver modules
.TP
.B /appl/lib/print/scaler.b
Scaler module
.SH SEE ALSO
.IR draw-image (2),
.IR image (6)