diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-07-06 13:15:49 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-07-06 15:49:55 +0200 |
commit | f0eabc17d6ec113c6e765ac3272f19623a6cbd4e (patch) | |
tree | 873d91bfbc610d70e571358550c59d24c8b64ed2 /source/tools/pdfposter.c | |
parent | c3944e2e1cfb4ac86a8580829376357e1d5bccda (diff) | |
download | mupdf-f0eabc17d6ec113c6e765ac3272f19623a6cbd4e.tar.xz |
Start slimming pdf_page.
We want to turn pdf_page into a thin wrapper around a pdf_obj, so that
any updates to the underlying PDF objects will be reflected without
having to reload the pdf_page.
Diffstat (limited to 'source/tools/pdfposter.c')
-rw-r--r-- | source/tools/pdfposter.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/source/tools/pdfposter.c b/source/tools/pdfposter.c index 81ca0d75..66eaa3a5 100644 --- a/source/tools/pdfposter.c +++ b/source/tools/pdfposter.c @@ -58,6 +58,8 @@ static void decimatepages(fz_context *ctx, pdf_document *doc) pdf_obj *oldroot, *root, *pages, *kids; int num_pages = pdf_count_pages(ctx, doc); int page, kidcount; + fz_rect mediabox; + fz_matrix page_ctm; oldroot = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root); pages = pdf_dict_get(ctx, oldroot, PDF_NAME_Pages); @@ -78,9 +80,13 @@ static void decimatepages(fz_context *ctx, pdf_document *doc) { pdf_page *page_details = pdf_load_page(ctx, doc, page); int xf = x_factor, yf = y_factor; + float w, h; int x, y; - float w = page_details->mediabox.x1 - page_details->mediabox.x0; - float h = page_details->mediabox.y1 - page_details->mediabox.y0; + + pdf_page_transform(ctx, page_details, &mediabox, &page_ctm); + + w = mediabox.x1 - mediabox.x0; + h = mediabox.y1 - mediabox.y0; if (xf == 0 && yf == 0) { @@ -103,21 +109,21 @@ static void decimatepages(fz_context *ctx, pdf_document *doc) fz_rect mb; newpageobj = pdf_copy_dict(ctx, pdf_lookup_page_obj(ctx, doc, page)); - pdf_flatten_inheritable_page_items(ctx, doc, newpageobj); + pdf_flatten_inheritable_page_items(ctx, newpageobj); newpageref = pdf_add_object(ctx, doc, newpageobj); newmediabox = pdf_new_array(ctx, doc, 4); - mb.x0 = page_details->mediabox.x0 + (w/xf)*x; + mb.x0 = mediabox.x0 + (w/xf)*x; if (x == xf-1) - mb.x1 = page_details->mediabox.x1; + mb.x1 = mediabox.x1; else - mb.x1 = page_details->mediabox.x0 + (w/xf)*(x+1); - mb.y0 = page_details->mediabox.y0 + (h/yf)*y; + mb.x1 = mediabox.x0 + (w/xf)*(x+1); + mb.y0 = mediabox.y0 + (h/yf)*y; if (y == yf-1) - mb.y1 = page_details->mediabox.y1; + mb.y1 = mediabox.y1; else - mb.y1 = page_details->mediabox.y0 + (h/yf)*(y+1); + mb.y1 = mediabox.y0 + (h/yf)*(y+1); pdf_array_push(ctx, newmediabox, pdf_new_real(ctx, doc, mb.x0)); pdf_array_push(ctx, newmediabox, pdf_new_real(ctx, doc, mb.y0)); |