W3A/P – WWW Applets/Printer drivers API

May 30, 1995

W3A/P – WWW Applets/Printer drivers API

Printer drivers are used to add support for making print-outs of certain document formats. They are much like viewers, except that their output is supposed to go to a hardcopy device instead of to the screen.

Printer drivers are characterized by:

1. one or more MIME types (the types they know how to print)

2. a list of object files

3. a suffix (referred to as XXX below)

The exported functions of printer drivers are almost the same as for viewers, that is:

• Bool initXXX(char ***mime_types, int *nrtypes)

Initializes private variables and returns the list of formats that the applet accepts. (XXX is replaced with the unique suffix.) When an error occurs, the function sets the errno variable and returns FALSE.

• Bool openXXX(const W3ADocumentInfo info, long id)

Directs the printer driver to start a new print job of the type indicated in info. The ID is theID used in subsequent calls to writeXXX and closeXXX. The function returns FALSE in case of an error and sets errno to the error code.

Question: Is it useful to have a flags argument, so that nonblocking I/O can be specified?

• int writeXXX(long id, const char *buf, const unsigned
int nchars)

Sends characters to the printer driver. It is not necessary (like it is with viewers) to make a call with nchars = 0, to indicate that the end of the data is reached. W3AcloseXXX may be called immediately. The return value is equal to nchars or -1 in case of an error.

• Bool closeXXX(long id)

Signals the end of the data. The printer driver should invalidate (destroy) the self object.