Support for a new type of document writer requires a new structure, derived from fz_document_writer:
For instance:
A generator function should be defined to return such an instance, perhaps:
This uses a friendly macro that allocates a structure of the required size, initialises the function pointers as required, and zeroes the extra values in the structure.
The actual work for the document writer is done in the functions that are passed to fz_new_derived_document_writer. In the example above these were foo_begin_page, foo_end_page, foo_close, and foo_drop. These have the following 4 types respectively.
Once defined, if this is intended to be a generally useful document writer, it should probably be hooked into fz_new_document_writer, where it can be selected by appropriate format and options strings.