Handling reflowable documents

Some document types (such as EPUB) require the contents to be laid out before they can be rendered. This is done by calling fz_layout_document:


\begin{lstlisting}
/*
fz_layout_document: Layout reflowable document types.
\pa...
...fz_context *ctx, fz_document *doc, float w, float h, float em);
\end{lstlisting}

Any non-reflowable document types (such as PDF) will ignore this layout request.

The results of the layout will depend both upon a target width and height, a given font size, and the CSS styles in effect. MuPDF has an inbuilt set of default CSS styles that will be used if a document does not provide its own. In addition, the user can provide a final set that will override any rules found in the default sets. In this way, the appearance of the rendered document can be changed (perhaps by changing document colours or font styles/sizes).

Documents can be laid out multiple times to allow changes in these properties to take effect.

MuPDF provides its own default CSS style sheet, but this can be overridden by the user CSS style sheet in the context:


\begin{lstlisting}
/*
fz_user_css: Get the user stylesheet source text.
*/
cons...
...UB.
*/
void fz_set_user_css(fz_context *ctx, const char *text);
\end{lstlisting}

The user CSS style sheet is supplied as a null terminated C string.

When the CSS or the screen size is changed, and the document relaid out, content moves. In order for applications to be able to not lose the readers place, MuPDF offers a mechanism for making a bookmark and then looking it up again after the content has been laid out to a new position.


\begin{lstlisting}
/*
Create a bookmark for the given page, which can be used t...
..._bookmark(fz_context *ctx, fz_document *doc, fz_bookmark mark);
\end{lstlisting}