Once you have a laid out document, you presumably want to be able to do something with it. The first thing to know is how many pages it contains. This is achieved by calling fz_count_pages:
For document types like images, they appear as a single page. If you forget to lay out a reflowable document, this will trigger a layout for a default size and return the required number of pages.
Once you know how many pages there are, you can fetch the fz_page object for each page required:
The pages of a document with n pages are numbered from 0 to n-1.
In common with most other object types, fz_pages are reference counted:
Once the last reference to a page is dropped, the resources it consumes are all released automatically.