To implement a new document handler, a new fz_document_handler structure is required. There are 3 components to such a structure, all function pointers:
The first is a function to recognize a document from a magic string, typically a mimetype or a filename:
The second is a function to open a document from a filename:
This function can permissibly be NULL, as it can be synthesized automatically from the third entry, a function to open a document from a stream:
To create a fz_document use the fz_new_document macro. For a document of type foo, typically a foo_document structure would be defined as below:
This would then be created using a call to fz_new_document, such as:
This returns an empty document structure with super populated with default values, and the foo specific fields initialized to 0. The document handler then needs to fill in the document level functions.