diff options
-rw-r--r-- | source/pdf/pdf-page.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 64b30cf6..1b20b091 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -683,8 +683,16 @@ pdf_add_page(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, int ro pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Type, PDF_NAME_Page); pdf_dict_put_drop(ctx, page_obj, PDF_NAME_MediaBox, pdf_new_rect(ctx, doc, mediabox)); pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Rotate, pdf_new_int(ctx, doc, rotate)); - pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_add_object(ctx, doc, resources)); - pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Contents, pdf_add_stream(ctx, doc, contents, NULL, 0)); + + if (pdf_is_indirect(ctx, resources)) + pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, resources); + else if (pdf_is_dict(ctx, resources)) + pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_add_object(ctx, doc, resources)); + else + pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Resources, pdf_new_dict(ctx, doc, 1)); + + if (contents) + pdf_dict_put_drop(ctx, page_obj, PDF_NAME_Contents, pdf_add_stream(ctx, doc, contents, NULL, 0)); } fz_catch(ctx) { |