diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-04-03 19:49:53 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-04-03 20:01:24 +0100 |
commit | 5f76f7a85e9590e9b3db2392806010b76ad633b6 (patch) | |
tree | b3e0fab685491413100870788879acedd31415ba /source | |
parent | d4ae4095cc1121b9a7a5ca9a444adaa08906e846 (diff) | |
download | mupdf-5f76f7a85e9590e9b3db2392806010b76ad633b6.tar.xz |
Pages created with pdf_create_page were duff.
They hadn't been updated with recent changes. Extract the pdf page
creation code from pdf_load_page into a new static function,
pdf_new_page, and use that from both places.
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-page.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 9d5eb863..c7ef3422 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -425,27 +425,11 @@ void pdf_drop_page(fz_context *ctx, pdf_page *page) fz_drop_page(ctx, &page->super); } -pdf_page * -pdf_load_page(fz_context *ctx, pdf_document *doc, int number) +static pdf_page * +pdf_new_page(fz_context *ctx, pdf_document *doc) { - pdf_page *page; - pdf_annot *annot; - pdf_obj *pageobj, *pageref, *obj; - fz_rect mediabox, cropbox, realbox; - float userunit; - fz_matrix mat; + pdf_page *page = fz_new_page(ctx, sizeof(*page)); - if (doc->file_reading_linearly) - { - pageref = pdf_progressive_advance(ctx, doc, number); - if (pageref == NULL) - fz_throw(ctx, FZ_ERROR_TRYLATER, "page %d not available yet", number); - } - else - pageref = pdf_lookup_page_obj(ctx, doc, number); - pageobj = pdf_resolve_indirect(ctx, pageref); - - page = fz_new_page(ctx, sizeof *page); page->doc = (pdf_document*) fz_keep_document(ctx, &doc->super); page->super.drop_page_imp = (fz_page_drop_page_imp_fn *)pdf_drop_page_imp; @@ -466,8 +450,34 @@ pdf_load_page(fz_context *ctx, pdf_document *doc, int number) page->annot_tailp = &page->annots; page->deleted_annots = NULL; page->tmp_annots = NULL; - page->me = pdf_keep_obj(ctx, pageobj); page->incomplete = 0; + page->me = NULL; + + return page; +} + +pdf_page * +pdf_load_page(fz_context *ctx, pdf_document *doc, int number) +{ + pdf_page *page; + pdf_annot *annot; + pdf_obj *pageobj, *pageref, *obj; + fz_rect mediabox, cropbox, realbox; + float userunit; + fz_matrix mat; + + if (doc->file_reading_linearly) + { + pageref = pdf_progressive_advance(ctx, doc, number); + if (pageref == NULL) + fz_throw(ctx, FZ_ERROR_TRYLATER, "page %d not available yet", number); + } + else + pageref = pdf_lookup_page_obj(ctx, doc, number); + pageobj = pdf_resolve_indirect(ctx, pageref); + + page = pdf_new_page(ctx, doc); + page->me = pdf_keep_obj(ctx, pageobj); obj = pdf_dict_get(ctx, pageobj, PDF_NAME_UserUnit); if (pdf_is_real(ctx, obj)) @@ -680,15 +690,10 @@ pdf_create_page(fz_context *ctx, pdf_document *doc, fz_rect mediabox, int res, i fz_matrix ctm, tmp; fz_rect realbox; - page = fz_malloc_struct(ctx, pdf_page); + page = pdf_new_page(ctx, doc); fz_try(ctx) { - page->resources = NULL; - page->contents = NULL; - page->transparency = 0; - page->links = NULL; - page->annots = NULL; page->me = pageobj = pdf_new_dict(ctx, doc, 4); pdf_dict_put_drop(ctx, pageobj, PDF_NAME_Type, PDF_NAME_Page); |