PDF Objects

PDF files are made up of a series of objects. These objects can be in many different types, including dictionaries, streams, numbers, booleans, names, strings etc. For full details, see `The PDF Reference Manual'.

MuPDF represents all of these as a pdf_obj pointer. Such pointers are reference counted in the usual way:


\begin{lstlisting}
pdf_obj *pdf_keep_obj(fz_context *ctx, pdf_obj *obj);
void pdf_drop_obj(fz_context *ctx, pdf_obj *obj);
\end{lstlisting}

Given such a pointer, the actual type of the object can be obtained using:


\begin{lstlisting}
int pdf_is_null(fz_context *ctx, pdf_obj *obj);
int pdf_is_bo...
...df_obj *obj);
int pdf_is_stream(fz_context *ctx, pdf_obj *obj);
\end{lstlisting}

These all return non-zero if the object is of the tested type, and zero otherwise.

To extract the data from a PDF object, you can use one of the following functions:


\begin{lstlisting}
/* safe, silent failure, no error reporting on type mismatche...
...f_obj *obj);
int pdf_to_str_len(fz_context *ctx, pdf_obj *obj);
\end{lstlisting}

It is, in fact, safe to call any of these functions on any pdf_obj pointer. If the object is not of the expected type, a `safe' default will be returned.



Subsections