Handling password protected documents

Some document types (such as PDF) can require passwords to allow the file to be opened. After you have obtained a fz_document, you should therefore check whether it needs a password using fz_needs_password:


\begin{lstlisting}
/*
fz_needs_password: Check if a document is encrypted with ...
...s.
*/
int fz_needs_password(fz_context *ctx, fz_document *doc);
\end{lstlisting}

If a password is required, you can supply one using fz_authenticate_password:


\begin{lstlisting}
/*
fz_authenticate_password: Test if the given password can
...
...sword(fz_context *ctx, fz_document *doc, const char *password);
\end{lstlisting}