14.1 Overview

MuPDFs built in renderer (see subsection 9.5.2 Draw Device) produces in-memory arrays of contone values for areas of document pages. The MuPDF library includes routines to be able to output these areas to a number of different output formats.

Typically these devices all follow a similar pattern, enabling either full page or banded rendering to be performed according to the requirements of the particular application.

For a given format XXX, there tend to be 3 functions defined:

void fz_save_pixmap_as_XXX(fz_context *ctx, fz_pixmap *pixmap, char *filename); 
 
void fz_write_pixmap_as_XXX(fz_context *ctx, fz_output *out, fz_pixmap *pixmap); 
 
fz_band_writer *fz_new_XXX_band_writer(fz_context *ctx, fz_output *out);

The first function outputs a pixmap to a utf-8 encoded filename as a XXX formatted file. If the pixmap is not in a suitable colorspace/alpha configuration, then an exception will be thrown.

The second function does the same thing, but to a given fz_output rather than to a named file. The use of a fz_output allows for writing to memory buffers, or even potentially to encrypt or compress further as the write progresses.

The third function returns a fz_band_writer to do the same thing.