summaryrefslogtreecommitdiff
path: root/source/tools/pdfposter.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/tools/pdfposter.c')
-rw-r--r--source/tools/pdfposter.c24
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));