Code sync
[external/libijs.git] / ijs_spec.sgml
1 <!doctype article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
2 <article>
3 <artheader>
4  <title>IJS Protocol Specification</title>
5  <subtitle>Version 0.34 &mdash; 22 Feb 2002</subtitle>
6  <!-- the date should be a <date> element, but I can't for the
7       life of me figure out how to coax db2ps into actually
8       rendering it -->
9  <author><firstname>Raph</> <surname>Levien</></author>
10
11 </artheader>
12
13 <abstract>
14 <para>
15 This document contains a specification for the IJS protocol, which is
16 intended to make it easier to deploy raster-based printer drivers in
17 a wide variety of environments, including Unix desktops.
18 </para>
19 </abstract>
20
21 <sect1><title>Introduction</title>
22
23 <para>
24 IJS is, first and foremost, a protocol for transmission of raster page
25 images. The protocol is a fairly traditional client-server design. In
26 general, the client sends one or more page images to the server, along
27 with various metadata. Communication is through simple
28 &ldquo;commands&rdquo;, which are essentially size-prefixed
29 packets. The client sends a command to the server, then waits for a
30 response command, either ACK or NAK.
31 </para>
32
33 <para>
34 Since, in the typical IJS scenario, there is only one client for
35 any given server, it may be helpful to denote the client role as
36 "master" and the server role as "slave". However, this document
37 uses the terms "client" and "server".
38 </para>
39
40 <para>
41 On Unix systems, the server &ldquo;speaks&rdquo; IJS through stdin and stdout. One
42 consequence of this design decision is that the server can be invoked
43 remotely, for example through <command>ssh</command>.
44 <comment>It's not clear yet how
45 useful this will be, but at least people can experiment with
46 it.</comment>
47 </para>
48
49 <para>
50 Other forms of communication (such as domain sockets) may be useful,
51 as well, but are not specified in this version.
52 </para>
53
54 <para>
55 There are also a large number of things that the IJS specification
56 does <emphasis>not</emphasis> address. It does not provide strings for
57 a UI (although the parameter names and values may be used as a
58 fallback when higher-level mechanisms designed to provide these
59 fail). It does not address the task of discovering printers or
60 drivers. It is not designed to dispatch jobs to multiple printers.  It
61 does not provide queue management features. It does not address higher
62 level imaging models, or fonts. These are important components of a
63 printing system, and should be addressed by other modules and
64 interfaces.
65 </para>
66
67 </sect1>
68
69 <sect1><title>Wire protocol</title>
70
71 <para>
72 After a brief initialization handshake, all IJS communication occurs
73 through <emphasis>commands</emphasis>. Most of these are sent from the
74 client to the server, but three (IJS_CMD_PONG, IJS_CMD_ACK, and
75 IJS_CMD_NAK) are sent from the server to the client.
76 </para>
77
78 <para>With the exception of IJS_CMD_PING, the appropriate response to
79 a command sent from the server is either IJS_CMD_ACK or IJS_CMD_NAK.
80 </para>
81
82 <para>
83 The initialization handshake is as follows. First, the client sends
84 the string "IJS\n\252v1\n" (with C backslash escaping). Upon receipt
85 of this string, the server sends the string "IJS\n\253v1\n".  At this
86 point, the client may send IJS commands to the server.
87 </para>
88
89 <para>
90 IJS is designed to have a simple wire encoding. Integers are encoded
91 as 32-bit big-endian (ie &ldquo;network order&rdquo;) values. The
92 encoding for a command is as follows:
93 </para>
94
95 <table><title>Wire Encoding of IJS Commands</title>
96 <tgroup cols=2>
97 <colspec colname=c1 colwidth=1in>
98 <colspec colname=c2 colwidth=1in>
99 <spanspec spanname=hspan namest=c1 nameend=c2 align=center>
100 <tbody>
101 <row><entry>Command</entry><entry>4-byte integer</entry></row>
102 <row><entry>Size in bytes</entry><entry>4-byte integer</entry></row>
103 <row rowsep=0><entry spanname=hspan>Arguments</entry></row>
104 <row><entry spanname=hspan>...</entry></row>
105 </tbody>
106 </tgroup>
107 </table>
108
109 <para>
110 The arguments are simply concatenated. For variable size arguments,
111 the size is either explicitly given as another argument, or, in the
112 case of the last argument, is inferred from the size of the command.
113 </para>
114
115 <para>
116 A wire encoding for a typical command is given below. This command
117 sets the Dpi parameter to 600.
118 </para>
119
120 <table><title>Example Wire Encoding</title>
121 <tgroup cols=3>
122 <colspec colname=c1 colwidth=1.5in>
123 <colspec colname=c2>
124 <colspec colname=c3 colwidth=3in>
125
126 <thead>
127 <row>
128  <entry>Encoded bytes</entry>
129  <entry>Field</entry>
130  <entry>Value</entry>
131 </row>
132 </thead>
133
134 <tbody>
135
136 <row><entry>00 00 00 0c</entry> <entry>Command</entry>
137 <entry>IJS_COMMAND_SET_PARAM</entry></row>
138
139 <row><entry>00 00 00 16</entry> <entry>Size in bytes</entry>
140 <entry>22</entry></row>
141
142 <row><entry>00 00 00 00</entry> <entry>Job id</entry>
143 <entry>0</entry></row>
144
145 <row><entry>00 00 00 03</entry> <entry>Size of parameter name</entry>
146 <entry>3</entry>
147
148 <row><entry>44 70 69 </entry> <entry>Parameter name</entry>
149 <entry>Dpi</entry></row>
150
151 <row><entry>36 30 30 </entry> <entry>Value</entry> <entry>600</entry></row>
152
153 </tbody>
154 </tgroup>
155 </table>
156
157 <para>The numerical values of the commands are:</para>
158
159 <table><title>Numerical Values of IJS Commands</title>
160
161 <tgroup cols=2>
162 <colspec colwidth=3in>
163 <colspec colwidth=1in>
164 <thead>
165 <row>
166  <entry>Command</entry>
167  <entry>Value</entry>
168 </row>
169 </thead>
170
171 <tbody>
172 <row><entry>IJS_CMD_ACK</entry> <entry>0</entry></row>
173 <row><entry>IJS_CMD_NAK</entry> <entry>1</entry></row>
174 <row><entry>IJS_CMD_PING</entry> <entry>2</entry></row>
175 <row><entry>IJS_CMD_PONG</entry> <entry>3</entry></row>
176 <row><entry>IJS_CMD_OPEN</entry> <entry>4</entry></row>
177 <row><entry>IJS_CMD_CLOSE</entry> <entry>5</entry></row>
178 <row><entry>IJS_CMD_BEGIN_JOB</entry> <entry>6</entry></row>
179 <row><entry>IJS_CMD_END_JOB</entry> <entry>7</entry></row>
180 <row><entry>IJS_CMD_CANCEL_JOB</entry> <entry>8</entry></row>
181 <row><entry>IJS_CMD_QUERY_STATUS</entry> <entry>9</entry></row>
182 <row><entry>IJS_CMD_LIST_PARAMS</entry> <entry>10</entry></row>
183 <row><entry>IJS_CMD_ENUM_PARAM</entry> <entry>11</entry></row>
184 <row><entry>IJS_CMD_SET_PARAM</entry> <entry>12</entry></row>
185 <row><entry>IJS_CMD_GET_PARAM</entry> <entry>13</entry></row>
186 <row><entry>IJS_CMD_BEGIN_PAGE</entry> <entry>14</entry></row>
187 <row><entry>IJS_CMD_SEND_DATA_BLOCK</entry> <entry>15</entry></row>
188 <row><entry>IJS_CMD_END_PAGE</entry> <entry>16</entry></row>
189 <row><entry>IJS_CMD_EXIT</entry> <entry>17</entry></row>
190 </tbody>
191 </tgroup>
192 </table>
193
194 <para>
195 A state transition diagram for servers supporting a maximum of one
196 active job at a time is given below:
197 </para>
198
199 <graphic fileref="state.eps" format="eps" scale=50>
200 </graphic>
201
202 <sect2><title>IJS_CMD_ACK</title>
203
204 <para>This command is sent from server to the client in response to a
205 command from the client, to indicate successful completion. There are
206 no arguments specific to this command. However, for commands (such as
207 IJS_CMD_GET_PARAM) which request a value, this value is returned as
208 the argument in an ACK command.
209 </para>
210 </sect2>
211
212 <sect2><title>IJS_CMD_NAK</title>
213
214 <para>This command is sent from server to the client in response to a
215 command from the client, to indicate an error. There is one integer
216 argument, which is the error code. A list of error codes is given
217 in <xref linkend="sect-errorcodes">.
218
219 <sect2><title>IJS_CMD_PING</title>
220
221 <para>The PING command is sent from the client to the server as part
222 of the connection setup. It contains one integer argument, which is
223 the 100 times the real-valued version number of the largest IJS
224 protocol understood by the client. Thus, for the version of the
225 protocol described in this document, the argument is 30. The
226 appropriate response to a PING is a PONG.
227 </para>
228 </sect2>
229
230 <sect2><title>IJS_CMD_PONG</title>
231
232 <para>The PONG command is sent from the server to the client in
233 response to the PING command. It contains one integer argument, which
234 is 100 times the largest IJS version number understood by the
235 server. After a PING/PONG handshake, both client and server should use
236 the minimum of the two version numbers. This negotiation mechanism
237 preserves the ability to make deep changes in future version of the
238 protocol, while preserving backwards compatibility for both clients
239 and servers.
240 </para>
241 </sect2>
242
243 <sect2><title>IJS_CMD_OPEN</title>
244
245 <para>
246 The client should send an OPEN command to the server to indicate
247 that printing is imminent. The server can allocate resources, such
248 as tables, at this time.
249 </para>
250 </sect2>
251
252 <sect2><title>IJS_CMD_CLOSE</title>
253
254 <para>
255 The client should send a CLOSE command to the server to indicate
256 that printing is complete for now. The server can free any allocated
257 resources at this time.
258 </para>
259
260 <para>
261 There should not be any jobs open at the time of the CLOSE command.
262 Handling of any such jobs is undefined.
263 </sect2>
264
265 <sect2><title>IJS_CMD_BEGIN_JOB</title>
266
267 <para>
268 The client should send a BEGIN_JOB to the server to begin a job.
269 There is one integer argument, a job id. This id is allocated by
270 the client, and jobs are uniquely identified by the (client, job
271 id) tuple. This job id is present as an argument for all the
272 commands which operate within the context of a job. This job
273 id is valid until the corresponding END_JOB command is invoked,
274 at which point it can be reused if desired.
275
276 <para>
277 The connection must be in an open state to begin a job, ie an
278 OPEN command must have been sent, without a corresponding CLOSE.
279 </para>
280
281 <para>
282 Servers can choose whether or not to implement multiple jobs,
283 depending on their sophistication. When the number of jobs supported
284 is exceeded, the server should return an IJS_ETOOMANYJOBS error code.
285 </para>
286 </sect2>
287
288 <sect2><title>IJS_CMD_END_JOB</title>
289
290 <para>
291 The client should send an END_JOB command to the server on the
292 completion of a job. The one argument is the job id.  This command
293 cannot be used in the middle of a page, i.e. when a BEGIN_PAGE command
294 has been issued without its corresponding END_PAGE.
295 </para>
296 </sect2>
297
298 <sect2><title>IJS_CMD_CANCEL_JOB</title>
299
300 <para>
301 This command cancels a job. The one argument is the job id.  This
302 command can be used whether or not a page is open.
303 </para>
304 </sect2>
305
306 <sect2><title>IJS_CMD_QUERY_STATUS</title>
307
308 <para>
309 This command queries the status of a job, or general printer status
310 within a job context. The one argument is the job id. The return
311 data is the printer status.
312 </para>
313
314 <para>
315 The format of the printer status is yet to be determined. Glen Petrie
316 has made a proposal on the inkjet-list mailing list. Michael Sweet has
317 suggested adopting the IPP status codes. That standard is fairly rich
318 in status queries. There appear to be at least four queries related to
319 this IJS command: printer-state (enum), printer-state-reasons
320 (keyword), printer-state-message (text), printer-is-accepting-jobs
321 (boolean).
322 </para>
323 </sect2>
324
325 <sect2><title>IJS_CMD_LIST_PARAMS</title>
326
327 <para>
328 This command queries the server for a complete list of parameters.
329 Note that this list may change dynamically, in response to setting
330 various parameters, or external events. The argument is the job id.
331 The return value is a comma-separated list of parameters.
332 </para>
333 </sect2>
334
335 <sect2><title>IJS_CMD_ENUM_PARAM</title>
336
337 <para>
338 This command queries the possible values for a given parameter.
339 The arguments are the job id and the name of the parameter. The
340 return value is a comma-separated list of values, with the default
341 given first.
342 </para>
343
344 <para>
345 Some parameters may not have a small finite enumeration. In these
346 cases, the server should report IJS_ERANGE.
347 </para>
348
349 <para>
350 Note also that the comma-separated encoding does not provide a way
351 to report values containing commas. Thus, these should be avoided.
352 </sect2>
353
354 <sect2><title>IJS_CMD_SET_PARAM</title>
355
356 <para>
357 This command sets a parameter. There are four arguments: the job id,
358 the size of the parameter name (in bytes), the parameter name, and the
359 value. The size of the value is inferred from the size of the command.
360 </para>
361
362 <para>If the parameter is unknown, the server returns an IJS_EUNKPARAM
363 error. If the parameter is known but the value is not appropriate, the
364 server returns an IJS_ERANGE error.
365 </para>
366 </sect2>
367
368 <sect2><title>IJS_CMD_GET_PARAM</title>
369
370 <para>
371 This command retrieves the current value of a parameter. There are two
372 arguments: the job id and the parameter name. The value of the parameter
373 is returned.
374 </para>
375
376 <para>
377 If the parameter is unknown, the server returns an IJS_EUNKPARAM error.
378 </para>
379 </sect2>
380
381 <sect2><title>IJS_CMD_BEGIN_PAGE</title>
382
383 <para>
384 This command begins a new page. All of the parameters affecting the
385 data format of the page should have already been set by this time.
386 </para>
387 </sect2>
388
389 <sect2><title>IJS_CMD_SEND_DATA_BLOCK</title>
390
391 <para>
392 This command sends a block of data, in the format defined by
393 PageImageLanguage and its subsidiary parameters. There are no
394 alignment restrictions. There are two arguments: the job id,
395 and the size of the data block in bytes. The data block follows
396 the command, in the same stream.
397 </para>
398
399 <para>
400 Note that shared-memory transport of bulk data is anticipated in
401 a future version of this standard. Pipe transport will still be
402 used as a fallback in case shared-memory transport is unavailable.
403 </para>
404
405 <para>
406 The server must be in the middle of a page (ie BEGIN_PAGE without
407 the corresponding END_PAGE) when this command is issued.
408 </para>
409 </sect2>
410
411 <sect2><title>IJS_CMD_END_PAGE</title>
412
413 <para>
414 This command ends a page. The server must be in the middle of a
415 page when this command is issued. The argument is the job id.
416 </para>
417 </sect2>
418
419 <sect2><title>IJS_CMD_EXIT</title>
420
421 <para>
422 This command signals the end of the IJS connection. In the typical
423 case of a server with a single client, the server process terminates
424 upon receipt of this command.
425 </para>
426
427 <para>
428 The connection must be in a closed state at the time of this command.
429 </para>
430
431 <comment>Need to look into race condition.</comment>
432 </sect2>
433
434 </sect1>
435
436 <sect1><title>Parameters</title>
437
438 <para>
439 IJS defines a small set of standard parameters, which all clients and
440 servers are expected to understand. Individual implementations may
441 extend this standard set with additional parameters specific to the
442 device or driver. Clients should, in general, provide some mechanism
443 for setting (and possibly querying) arbitrary additional
444 parameters. In particular, command line clients should accept command
445 line options to set additional parameters. Interactive clients should
446 ideally query the server for a list of these parameters to display in
447 the interface, then query each parameter for the list of possible
448 values, presented as menu choices.
449 </para>
450
451 <para>
452 In addition, in many scenarios, the client may have additional
453 information specific to the device, obtained through other means, for
454 example a PPD (or PPD-like) file specified by the user. Such file
455 formats are well beyond the scope of this specification. However, many
456 users may find the simple parameter mechanism of IJS to be sufficient
457 for their needs. A particular strength of the IJS parameter mechanism
458 is that no additional effort is required to handle dynamic capability
459 information, for example the presence of a hot-pluggable duplexer.
460 </para>
461
462 <para>
463 Often, one parameter will be subsidiary to another. In this case,
464 the subsidiary parameter should be set, gotten, or enumerated after
465 the other parameter is set.
466 </para>
467
468 </sect1>
469
470 <sect1><title>Standard parameters</title>
471
472 <para>
473 This section describes the standard parameters specified by IJS.
474 </para>
475
476 <sect2><title>OutputFile</title>
477
478 <para>
479 This parameter is the filename intended for IJS output. It will
480 often refer to a device, but can also be a regular file.
481 </para>
482
483 <para>
484 Note that this parameter should be considered security-sensitive.
485 Clients should take care to ensure that it is set only to legitimate
486 values.
487 </para>
488
489 </sect2>
490
491 <sect2><title>OutputFD</title>
492
493 <para>
494 This is an alternative to OutputFile, and is intended to support
495 -sOutputFile=- and -sOutputFile="|cmd" configurations of Ghostscript.
496 The parameter is a numeric file descriptor.
497 </para>
498
499 </sect2>
500
501 <sect2><title>DeviceManufacturer</title>
502
503 <para>
504 This parameter is the manufacturer of the printer. In general, it
505 should match the "MANUFACTURER" (or "MFR") field of the IEEE 1284
506 Device ID string exactly<citation>IEEE1284</citation>.
507 </para>
508
509 <para>
510 There are many different scenarios for setting and querying this
511 parameter, depending on what information is known about the device.
512 </para>
513
514 <para>
515 In the case where the server is able to identify the device, for
516 example by retrieving the IEEE 1284 Device ID string, or through the
517 GET_DEVICE_ID request of the USB Printer
518 Class<citation>USBPrint</citation>, getting the value of the parameter
519 will retrieve this identification string. In general, the server should
520 perform the device ID query at the time of the GET_PARAM command.
521 </para>
522
523 <para>
524 In the case where the device identification is configured by the
525 client, the client may set this parameter, then set the DeviceModel
526 parameter.
527 </para>
528
529 <para>
530 Finally, enumerating this parameter returns a list of manufacturers
531 known by the server. This may be helpful for installing a new
532 printer in cases where automatic device identification is not
533 available.
534 </para>
535
536 <para>
537 There may be cases where the server is able to automatically identify
538 the device, and the client attempts to override this identification.
539 The server should allow this override to occur, particularly when
540 the device ID is not one known to the server. However, the server
541 can reject such attempts by returning an IJS_ERANGE error.
542 </para>
543 </sect2>
544
545 <sect2><title>DeviceModel</title>
546
547 <para>
548 This parameter is the model name of the printer, and together with
549 DeviceManufacturer, identifies the device. In general it should match
550 the "MODEL" (or "MDL") field of the IEEE 1284 Device ID string.
551 </para>
552
553 <para>
554 Usage scenarios are similar to DeviceManufacturer. This parameter is
555 subsidiary to DeviceManufacturer.
556 </para>
557
558 <para>
559 Setting the device manufacturer and model may have profound effects on
560 the list of other parameters available. For example, the server may in
561 fact be a wrapper that invokes the &ldquo;real&rdquo; server once
562 the device id is known, and then proxies all IJS commands
563 subsequently. Thus, all other parameters other than OutputFD,
564 OutputFile, and DeviceManufacturer, should be considered subsidiary to
565 this one.
566 </para>
567 </sect2>
568
569 <sect2><title>PageImageFormat</title>
570
571 <para>
572 This parameter specifies the format of the page image data to be sent
573 to the printer. This standard only defines one standard value:
574 "Raster". Other values, including compressed raster formats, as well
575 as possibly higher level page description languages such as PostScript
576 and PDF, are envisioned as possible future extensions.
577
578 <para>
579 When it makes sense, names consistent with the "COMMAND SET" (or
580 "CMD") field of the IEEE 1284 Device ID string are recommended.
581 However, this namespace has many shortcomings for use with IJS.
582 In particular, it tends to identify the command set too vaguely.
583 For example, many Epson printers report merely "ESCPL2", which is
584 not nearly precise enough to usefully drive the printer.
585 </para>
586
587 <para>
588 When the value is "Raster", the following parameters are required, and
589 are subsidiary to this one: Dpi, Width, Height, BitsPerSample,
590 ColorSpace, and NumChan.
591 </para>
592 </sect2>
593
594 <sect2><title>Dpi</title>
595
596 <para>
597 This parameter is the resolution for transfer of raster data. It is
598 specified as a horizontal resolution, in floating decimal dpi units,
599 an "x", and a vertical resolution, in floating decimal dpi units.
600 Thus, a typical value is "1440x720".
601 </para>
602
603 <para>
604 Note that the server may perform scaling of the raster data as part of
605 its processing, before sending it to the device. In these cases, the
606 Dpi parameter specifies the resolution prior to scaling. For example,
607 a driver might accept 720 dpi raster data, then perform 2:1 horizontal
608 pixel replication to drive the actual device at 1440x720 dpi. In this
609 example, the value of the Dpi parameter is "720x720".
610 </para>
611 </sect2>
612
613 <sect2><title>Width</title>
614 <para>
615 This parameter is the decimal encoded width of the raster image,
616 in pixels. It MUST be set when PageImageFormat is Raster.
617 </para>
618 </sect2>
619
620 <sect2><title>Height</title>
621 <para>
622 This parameter is the decimal encoded height of the raster image,
623 in pixels. It MUST be set for raster images.
624 </para>
625 </sect2>
626
627 <sect2><title>BitsPerSample</title>
628 <para>
629 This parameter is the decimal encoded bit depth of samples for pixel
630 values. It MUST be set for raster images. Valid values include 1-7
631 (implying client-side dithering of image pixels), 8, and 16 (both
632 implying server-side dithering if needed by the device). In general,
633 the total number of bits per pixel is equal to BitsPerSample times
634 NumChan.
635 </para>
636
637 <para>
638 In many cases, querying this parameter will be useful. A
639 &ldquo;dumb&rdquo; server may choose not to implement color
640 transform and dithering, leaving these to the client. In this case,
641 the result of the query operation will be a list of bit depths
642 actually supported by the device. Simple devices may report "1", while
643 devices capable of both bilevel and 4-level variable dots may report
644 "1,2".
645 </para>
646
647 <para>
648 Note that not all combinations of BitsPerSample and ColorSpace are
649 valid. In particular, BitsPerSample less than 8 in combination with a
650 ColorSpace of sRGB or any other colorimetric color space are not
651 valid. Also for scRGB (also known as sRGB64), 16 is the only valid
652 value.
653 </para>
654
655 <para>
656 When the value is 16, the ByteSex parameter is required, and is
657 subsidiary to this one.
658 </para>
659 </sect2>
660
661 <sect2><title>ByteSex</title>
662
663 <para>
664 When BitsPerSample is equal to 16, this parameter specifies the byte
665 sex of the raster data. Possible values are "big-endian" and
666 "little-endian".
667 </para>
668
669 <para>
670 Enumerating this parameter should list the preferred byte sex as the
671 default (ie first in the comma-separated list). In most cases, this
672 will be the byte sex of the server's host architecture.
673 </para>
674
675 <para>
676 Servers limited to 8 bits of depth need not implement this parameter
677 at all.
678 </para>
679 </sect2>
680
681 <sect2><title>ColorSpace</title>
682
683 <para>
684 This parameter is a string identifying the color space of the raster
685 image data. It MUST be set for raster images. Standard values
686 include "DeviceGray", "DeviceRGB", "DeviceCMYK", and "sRGB". Servers
687 should support at least one of these color spaces. Clients should be
688 able to produce raster output if at least one of these color spaces is
689 supported by the server.
690 </para>
691
692 <comment> I think we should have a wide-gamut colorimetric color space
693 in the standard list as well. I like La*b* with a recommended bit
694 depth of 16. Any objections?
695 </comment>
696
697 <para>
698 A device may choose to provide more color spaces. For example, 6 color
699 inkjets may provide a "DeviceCcMmYK" space. In general, for a client
700 to use any of these nonstandard spaces requires detailed knowledge of
701 the color rendering characteristics of the device.
702 </para>
703
704 <para>
705 Servers should not provide additional color spaces which are merely
706 transforms of the standard color spaces. Examples of such discouraged
707 color spaces are HSV, XYZ, Luv, Yuv, YCC, and colorimetric RGB spaces
708 other than sRGB (TODO: unless we decide to accept scRGB/sRGB64).
709 </para>
710 </sect2>
711
712 <sect2><title>NumChan</title>
713
714 <para>
715 This parameter is the number of channels in the chosen color space.
716 In general, it can be determined from the ColorSpace. In particular,
717 DeviceGray implies 1, DeviceRGB and sRGB imply 3, and DeviceCMYK
718 implies 4. Attempting to set a NumChan inconsistent with ColorSpace
719 should result in an error.
720 </para>
721
722 <sect2><title>PaperSize</title>
723
724 <para>This parameter is in W.WWxH.HH format, in inches, i.e. a string
725 that may be produced by sprintf (str, "%fx%f", width, height). If the
726 server knows the paper size (which is unlikely for inkjets), then
727 getting the parameter will give a good value. In the more common case,
728 get simply returns an error code (todo: probably need to allocate a
729 new one for this). Enumerating this parameter may give a list of paper
730 sizes known by the driver that are plausible for the device.
731 </para>
732
733 <para>
734 The result of getting or enumerating PaperSize may change dynamically
735 depending on the DeviceModel, Duplex, and possibly
736 &ldquo;extension&rdquo; parameters such as those for selecting
737 trays.
738 </para>
739
740 <para>
741 Note that this parameter is essentially the same as the PageSize
742 page device parameter. The main difference is units (PostScript uses
743 1/72" inch units), and the minor syntax nit of PostScript array
744 encoding.
745 </para>
746 </sect2>
747
748 <sect2><title>PrintableArea</title>
749
750 <para>
751 This parameter is in W.WWxH.HH format, and describes the printable
752 area of the page. It is expected that the client will usually get it
753 from the server. Any attempt to set it is allowed to fail with an
754 error, even if it's the same value as the get. The value may change
755 dynamically depending on PaperSize and other parameters.
756 </para>
757
758 </sect2>
759
760 <sect2><title>PrintableTopLeft</title>
761
762 <para>
763 This parameter is in W.WWxH.HH format, and contains the left and top
764 margins of the printable area with respect to the media. It is the
765 companion to PrintableArea (I'm considering having a single parameter
766 that ASCII encodes the four floats).
767 </para>
768 </sect2>
769
770 <sect2><title>TopLeft</title>
771
772 <para>
773 This parameter, in W.WWxH.HH is intended to be set, and controls the
774 placement of the raster image on the page. The corresponding size of
775 the raster image area can be inferred from the Width, Height, and Dpi
776 parameters.
777 </para>
778 </sect2>
779
780 <sect2><title>PostScript Page Device Parameters</title>
781
782 <para>
783 PostScript defines a number of page device parameters, many of which
784 are relevant to IJS, whether using PostScript or not. Further, many
785 proposals for characterizing device capabilities are based on PPD
786 files, which use a consistent namespace and semantics to page device
787 parameters.
788 </para>
789
790 <para>
791 IJS imports the namespace of PostScript page device parameters,
792 prefixing it with the string "PS:". The client can assume that any
793 parameters returned by a LIST_PARAMS command matching this prefix are
794 in fact PostScript page device parameters. Values are straightforward
795 ASCII encodings. For example, arrays are encoded as space-separated
796 values, enclosed in square brackets. The set of valid page device
797 parameters is defined in the PostScript Language Reference
798 Manual<citation>PLRM</citation>, particularly Chapter 6.
799 </para>
800
801 <para>
802 Some page device parameters are subsumed by native IJS parameters, and
803 should not be used. These include PageSize (subsumed by PaperSize),
804 ProcessColorModel (subsumed by ColorSpace), Margins and PageOffset
805 (subsumed by TopLeft), and HWResolution (subsumed by Dpi).
806 </para>
807
808 <para>
809 Devices supporting duplexing should implement PS:Duplex and PS:Tumble,
810 both booleans. A value of true for PS:Duplex requests printing on both
811 sides of the page. When PS:Duplex is true, PS:Tumble specifies the
812 relative orientation of the pages. When PS:Tumble is false, the pages
813 are oriented suitably at the left or right. When PS:Tumble is true,
814 the pages are oriented suitably for binding at the top or
815 bottom. Enumerating the PS:Duplex parameter should return a single
816 "false" value when the server knows that the device is not capable of
817 duplexing, and either "false,true" or "true,false" if it may be.
818 </para>
819
820 <comment>
821 Note that the HPIJS 1.0 implementation of IJS, identifying itself as
822 IJS version 0.29, specifies an integer-valued Duplex parameter, with
823 values of 0 (PS:Duplex = false, PS:Tumble don't care), 1 (PS:Duplex =
824 true, PS:Tumble = false), and 2 (PS:Duplex = true, PS:Tumble = true).
825 An integer valued Duplex parameter is inconsistent with the PostScript
826 specification. However, clients desiring compatibility should set
827 the integer-valued Duplex parameter rather than the PS: parameters
828 when the server reports a version of 0.29.
829 </comment>
830
831 <para>
832 Devices supporting roll-fed media should implement PS:RollFedMedia,
833 PS:Orientation, PS:AdvanceMedia, PS:AdvanceDistance (note that units
834 are integer 1/72"), and PS:CutMedia.
835 </para>
836
837 <para>
838 Other parameters that may be useful for some devices include
839 PS:MediaColor, PS:MediaWeight, PS:MediaType, PS:MediaClass,
840 PS:InsertSheet, PS:LeadingEdge, PS:ManualFeed, PS:TraySwitch,
841 PS:MediaPosition, PS:ImageShift, PS:MirrorPrint, PS:NegativePrint,
842 PS:NumCopies, PS:Collate, PS:Jog, PS:OutputFaceUp, PS:Separations, and
843 PS:SeparationColorNames. Other parameters are allowed, but are
844 unlikely to be useful in an IJS context.
845 </para>
846 </sect2>
847
848 </sect1>
849
850 <sect1><title>Parameter Namespace Extension</title>
851
852 <para>
853 While this document specifies enough parameters to be able to print
854 usefully, there is a huge diversity of devices and applications, often
855 indicating additional parameters not specified. IJS is designed to
856 accomodate these additional parameters as extensions. It is expected
857 that the namespace of these extensions will be managed informally.
858 Note that collisions in this namespace are not necessarily fatal, as
859 many will be device or manufacturer specific, so that the device id
860 may be used to disentangle them. Even so, it is clearly a good idea
861 to manage this namespace well. This section recommends some practices
862 towards this goal.
863 </para>
864
865 <para>
866 When possible, extension parameters should be prefixed, with a colon
867 separating the prefix from the base parameter name. Well known
868 prefixes give clients useful information about parameters, even when
869 the client lacks information about the specific parameter. An unknown
870 prefix at least allows the client to identify the parameter as a
871 nonstandard extension.
872 </para>
873
874 <para>
875 This document specifies a number of standard prefixes. We also reserve
876 the following prefixes for possible use in future revisions of this
877 protocol: IPP, UPDF. Further, the Omni: prefix is reserved for the Omni
878 group at IBM, and CUPS: is reserved for the CUPS project.
879 </para>
880
881 <comment>
882 Robert, do you want STP:? Anyone else?
883 </comment>
884
885 <sect2><title>Quality:</title>
886
887 <para>
888 Inkjet printers often provide a rich set of options for tuning output
889 quality, or selecting a point along a speed/quality tradeoff. The
890 details of these options vary widely from device to device. When made
891 available through IJS, they should be grouped under the Quality:
892 prefix.
893 </para>
894
895 <para>
896 Parameters in the Quality: namespace are to be interpreted in the
897 context of the device id (as defined by the DeviceManufacturer and
898 DeviceModel parameters). In the context of different device id's,
899 Quality: parameters with the same name may have entirely different
900 meaning. This recommendation reflects the diversity of quality
901 parameters and settings in devices and drivers.
902 </para>
903
904 <para>
905 For example, HPIJS 1.0 has the following parameters, for HP inkjet
906 printers: Quality, MediaType, ColorMode, and PenSet. To be compliant
907 with versions 0.30 and later of IJS, they should be named
908 Quality:Quality, Quality:MediaType, Quality:ColorMode, and
909 Quality:PenSet.
910 </para>
911
912 <para>
913 Note that Quality:MediaType overlaps somewhat with PS:MediaType. In
914 general, the former specifies a color profile or printing mode (for
915 example, to optimize printing on transparencies). The latter is often
916 used for selecting a paper source, for example letterhead or
917 envelopes. The former is more likely to be useful in inkjet
918 applications.
919 </para>
920
921 <para>
922 The Dpi and ColorSpace parameters are subsidiary to any Quality:
923 parameters provided.
924 </para>
925
926 </sect2>
927
928 <sect2><title>Finishing:</title>
929
930 <para>
931 Finishing options, such as stapling and collating, should be
932 grouped under the Finishing prefix.
933 </para>
934
935 <para>
936 The PS page device parameter namespace includes some finishing
937 options, including Duplex, Tumble, Collate, Jog, and the roll-fed
938 parameters: RollFedMedia, Orientation, AdvanceMedia, AdvanceDistance,
939 and CutMedia. For these parameters, the PS: prefix is preferred.
940 </para>
941
942 <para>
943 The PPD specification describes a number of additional finishing
944 parameters (section 5.18 of <citation>PPD</citation>). Where possible,
945 Finishing: parameters should be consistent with the PPD specification.
946 </para>
947
948 </sect2>
949
950 <sect2><title>PPD:</title>
951
952 <para>
953 The PPD specification<citation>PPD</citation> contains a large
954 number of options and parameters that may be provided by printers.
955 The PPD: prefix is reserved for PPD parameters that are made
956 available through the IJS protocol.
957 </para>
958
959 <para>
960 In cases where both a page device parameter and a PPD parameter
961 specify the same setting, the PS: page device parameter takes
962 priority. In many cases, page device parameters are advantageous
963 because they are designed for both getting and setting, while PPD
964 itself is a static file format. In addition, finishing parameters
965 should be under the Finishing: namespace.
966 </para>
967
968 <para>
969 In general, use of the PPD: extension is not recommended, as the
970 PPD file format tends to be specific to PostScript printers.
971 </para>
972
973 <comment>
974 We could use more specific advice on when to use PPD: parameters, and
975 when not to. Anyone with more PPD knowledge willing to help with this?
976 </comment>
977
978 </sect2>
979
980 </sect1>
981
982 <sect1 id="sect-errorcodes"><title>Error codes</title>
983
984 <para>
985 Any IJS command may either succeed or fail. Success is indicated
986 by an IJS_ACK response. Failure is indicated by an IJS_NAK response,
987 which includes an integer error code.
988 </para>
989
990 <para>
991 The current draft contains the following error codes:
992
993 </para>
994
995 <table><title>Draft IJS Error Codes</title>
996 <tgroup cols=3>
997 <colspec colname=def>
998 <colspec colname=val>
999 <colspec colname=exp>
1000 <thead>
1001 <row>
1002  <entry>Symbolic definition</entry>
1003  <entry>Numeric value</entry>
1004  <entry>Meaning</entry>
1005 </row>
1006 </thead>
1007
1008 <tbody>
1009 <row><entry>IJS_EIO</entry>            <entry>-2</entry>  <entry>I/O error</entry></row>
1010 <row><entry>IJS_EPROTO</entry>         <entry>-3</entry>  <entry>protocol error</entry></row>
1011 <row><entry>IJS_ERANGE</entry>         <entry>-4</entry>  <entry>out of range</entry></row>
1012 <row><entry>IJS_EINTERNAL</entry>      <entry>-5</entry>  <entry>internal error</entry></row>
1013 <row><entry>IJS_ENYI</entry>           <entry>-6</entry>  <entry>not yet implemented</entry></row>
1014 <row><entry>IJS_ESYNTAX</entry>        <entry>-7</entry>  <entry>syntax error</entry></row>
1015 <row><entry>IJS_ECOLORSPACE</entry>    <entry>-8</entry>  <entry>unknown color space</entry></row>
1016 <row><entry>IJS_EUNKPARAM</entry>      <entry>-9</entry>  <entry>unknown parameter</entry></row>
1017 <row><entry>IJS_EJOBID</entry>        <entry>-10</entry>  <entry>job id doesn't match</entry></row>
1018 <row><entry>IJS_ETOOMANYJOBS</entry>  <entry>-11</entry>  <entry>reached limit of server's #jobs</entry></row>
1019 <row><entry>IJS_EBUF</entry>          <entry>-12</entry>  <entry>buffer isn't big enough</entry></row>
1020 </tbody>
1021 </tgroup>
1022 </table>
1023
1024 <para>
1025 However, I see that this list overlaps the status codes for IPP
1026 operations (section 13.2 of <citation>RFC 2911</citation>) to a large extent. I am strongly
1027 considering unifying these.
1028 </para>
1029
1030 </sect1>
1031
1032 <sect1><title>Acknowledgements</title>
1033
1034 <para>
1035 IJS is directly inspired by the HPIJS work done by the HP Vancouver
1036 team, particularly David Suffield. This spec also benefited from
1037 comments and suggestions from Robert Krawitz, Grant Taylor, Glen
1038 Petrie, Russell Lang, Michael Sweet, and the Omni team at IBM: Mark
1039 VanderWiele, Mark Hamzy, and Pete Zannucci.
1040 </para>
1041
1042 <comment>Please add your name here. Incidentally, the &lt;ackno&gt; tag
1043 of DocBook seems more reasonable than a section, but I can't get it
1044 to format with a nice title.
1045 </comment>
1046 </sect1>
1047
1048 <bibliography><title>References</title>
1049 <biblioentry>
1050  <abbrev>RFC 2911</abbrev>
1051  <authorgroup>
1052   <author><firstname>T.</firstname> <surname>Hastings</surname></author>
1053   <author><firstname>R.</firstname> <surname>Herriot</surname></author>
1054   <author><firstname>R.</firstname> <surname>deBry</surname></author>
1055   <author><firstname>S.</firstname> <surname>Isaacson</surname></author>
1056   <author><firstname>P.</firstname> <surname>Powell</surname></author>
1057  </authorgroup>
1058
1059  <title>Internet Printing Protocol/1.1: Model and Semantics</title>
1060  <date>September 2000</date>
1061 </biblioentry>
1062
1063 <biblioentry>
1064  <abbrev>IEEE1284</abbrev>
1065  <title>IEEE Std.1284-1994 Standard Signaling Method for a
1066       Bi-directional Parallel Peripheral Interface for Personal
1067       Computers</title>
1068  <date>1994</date>
1069 </biblioentry>
1070
1071 <biblioentry>
1072  <abbrev>USBPrint</abbrev>
1073  <title>Universal Serial Bus Device Class Definition for Printing Devices</title>
1074  <edition>1.1</edition>
1075  <date>January 2000</date>
1076 </biblioentry>
1077
1078 <biblioentry>
1079  <abbrev>PLRM</abbrev>
1080  <title>PostScript Language Reference</title>
1081  <edition>third edition</edition>
1082  <corpname>Adobe Systems Incorporated</corpname>
1083  <publisher><publishername>Addison-Wesley</publishername></publisher>
1084  <date>1999</date>
1085 </biblioentry>
1086
1087 <biblioentry>
1088  <abbrev>PPD</abbrev>
1089  <title>PostScript Printer Description File Format</title>
1090  <edition>version 4.3</edition>
1091  <corpname>Adobe Systems Incorporated</corpname>
1092  <pubsnumber>Technical Note 5003</pubsnumber>
1093  <date>9 February 1996</date>
1094 </biblioentry>
1095
1096 </bibliography>
1097
1098
1099 </article>