diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-03-21 12:44:49 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-03-21 12:57:04 +0100 |
commit | 04b04805e7e3e82c49817b409564fa22332dcca5 (patch) | |
tree | 4a944ad8fceb0fc895eef795c0cbf7970f05d16a | |
parent | ace0c8fc182763ec54c078f495b025fec42143a3 (diff) | |
download | mupdf-04b04805e7e3e82c49817b409564fa22332dcca5.tar.xz |
Fix 696661: Missing annotations.
Add an explicit 'page setup' matrix to pdf-write device, which is only used
when creating top level page content stream and not the child annotation
content streams.
-rw-r--r-- | include/mupdf/pdf/output-pdf.h | 2 | ||||
-rw-r--r-- | source/pdf/pdf-appearance.c | 2 | ||||
-rw-r--r-- | source/pdf/pdf-device.c | 12 |
3 files changed, 9 insertions, 7 deletions
diff --git a/include/mupdf/pdf/output-pdf.h b/include/mupdf/pdf/output-pdf.h index 48789a1a..69aae2ea 100644 --- a/include/mupdf/pdf/output-pdf.h +++ b/include/mupdf/pdf/output-pdf.h @@ -11,7 +11,7 @@ is not an array, and that is it not shared with other objects/pages. */ fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, - const fz_rect *mediabox, fz_buffer *buf, pdf_obj *resources); + const fz_matrix *topctm, const fz_rect *mediabox, fz_buffer *buf, pdf_obj *resources); void pdf_localise_page_resources(fz_context *ctx, pdf_document *doc); diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index 6ddf3240..c64e73af 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1617,7 +1617,7 @@ void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *ann contents = fz_new_buffer(ctx, 0); - dev = pdf_new_pdf_device(ctx, doc, &trect, contents, resources); + dev = pdf_new_pdf_device(ctx, doc, &fz_identity, &trect, contents, resources); fz_run_display_list(ctx, disp_list, dev, &ctm, &fz_infinite_rect, NULL); fz_drop_device(ctx, dev); diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c index 4bad79c3..b33010e6 100644 --- a/source/pdf/pdf-device.c +++ b/source/pdf/pdf-device.c @@ -215,8 +215,8 @@ pdf_dev_ctm(fz_context *ctx, pdf_device *pdev, const fz_matrix *ctm) return; fz_invert_matrix(&inverse, &gs->ctm); fz_concat(&inverse, ctm, &inverse); - memcpy(&gs->ctm, ctm, sizeof(*ctm)); - fz_buffer_printf(ctx, gs->buf, "%f %f %f %f %f %f cm\n", inverse.a, inverse.b, inverse.c, inverse.d, inverse.e, inverse.f); + gs->ctm = *ctm; + fz_buffer_printf(ctx, gs->buf, "%M cm\n", &inverse); } static void @@ -1062,7 +1062,7 @@ pdf_dev_drop_imp(fz_context *ctx, fz_device *dev) fz_free(ctx, pdev->gstates); } -fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, fz_buffer *buf, pdf_obj *resources) +fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, const fz_matrix *topctm, const fz_rect *mediabox, fz_buffer *buf, pdf_obj *resources) { pdf_device *dev = fz_new_device(ctx, sizeof *dev); @@ -1115,7 +1115,8 @@ fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, const fz_rect dev->num_gstates = 1; dev->max_gstates = 1; - fz_buffer_printf(ctx, buf, "1 0 0 -1 %f %f cm\n", 0 - mediabox->x0, mediabox->y1); + if (topctm != &fz_identity) + fz_buffer_printf(ctx, buf, "%M cm\n", topctm); } fz_catch(ctx) { @@ -1131,7 +1132,8 @@ fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, const fz_rect fz_device *pdf_page_write(fz_context *ctx, pdf_document *doc, const fz_rect *mediabox, fz_buffer **pcontents, pdf_obj **presources) { + fz_matrix pagectm = { 1, 0, 0, 1, -mediabox->x0, mediabox->y1 }; *presources = pdf_new_dict(ctx, doc, 0); *pcontents = fz_new_buffer(ctx, 0); - return pdf_new_pdf_device(ctx, doc, mediabox, *pcontents, *presources); + return pdf_new_pdf_device(ctx, doc, &pagectm, mediabox, *pcontents, *presources); } |