Grafting objects

To move a single object to a new tree, use pdf_graft_object:


\begin{lstlisting}
/*
pdf_graft_object: Return a deep copied object equivalent ...
...graft_object(fz_context *ctx, pdf_document *dst, pdf_obj *obj);
\end{lstlisting}

This takes an object in one document, and returns an equivalent object that can safely be written into document dst. Any indirect references within the original object will have been copied across as new objects within dst as a side effect of this call.

The `safe' version of the code given above would therefore be:


\begin{lstlisting}
pdf_dict_putp_drop(ctx,
pdf_trailer(ctx, docB),
''Root/Exam...
...df_dict_getp(ctx,
pdf_trailer(ctx, docA,
''Root/Example''));
\end{lstlisting}