diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-annot-edit.c | 25 | ||||
-rw-r--r-- | source/pdf/pdf-annot.c | 8 | ||||
-rw-r--r-- | source/pdf/pdf-appearance.c | 7 |
3 files changed, 25 insertions, 15 deletions
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index 95b41958..fe75823c 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -92,7 +92,7 @@ pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_ty pdf_obj *annot_obj = pdf_new_dict(ctx, doc, 0); pdf_obj *ind_obj = NULL; fz_rect mediabox; - fz_matrix page_ctm, inv_page_ctm; + fz_matrix page_ctm; fz_var(annot); fz_var(ind_obj); @@ -117,9 +117,8 @@ pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_ty pdf_dict_put_drop(ctx, annot_obj, PDF_NAME_F, pdf_new_int(ctx, doc, F_Print)); pdf_page_transform(ctx, page, &mediabox, &page_ctm); - fz_invert_matrix(&inv_page_ctm, &page_ctm); - annot = pdf_new_annot(ctx, page, &page_ctm, &inv_page_ctm); + annot = pdf_new_annot(ctx, page, &page_ctm); annot->ap = NULL; /* @@ -235,8 +234,11 @@ void pdf_set_markup_annot_quadpoints(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *qp, int n) { pdf_obj *arr = pdf_new_array(ctx, doc, n*2); + fz_matrix inv_page_ctm; int i; + fz_invert_matrix(&inv_page_ctm, &annot->page_ctm); + pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_QuadPoints, arr); for (i = 0; i < n; i++) @@ -244,7 +246,7 @@ pdf_set_markup_annot_quadpoints(fz_context *ctx, pdf_document *doc, pdf_annot *a fz_point pt = qp[i]; pdf_obj *r; - fz_transform_point(&pt, &annot->inv_page_ctm); + fz_transform_point(&pt, &inv_page_ctm); r = pdf_new_real(ctx, doc, pt.x); pdf_array_push_drop(ctx, arr, r); r = pdf_new_real(ctx, doc, pt.y); @@ -256,10 +258,13 @@ void pdf_set_ink_annot_list(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *pts, int *counts, int ncount, float color[3], float thickness) { pdf_obj *list = pdf_new_array(ctx, doc, ncount); + fz_matrix inv_page_ctm; pdf_obj *bs, *col; fz_rect rect; int i, k = 0; + fz_invert_matrix(&inv_page_ctm, &annot->page_ctm); + pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_InkList, list); for (i = 0; i < ncount; i++) @@ -273,7 +278,7 @@ pdf_set_ink_annot_list(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_ { fz_point pt = pts[k]; - fz_transform_point(&pt, &annot->inv_page_ctm); + fz_transform_point(&pt, &inv_page_ctm); if (i == 0 && j == 0) { @@ -332,14 +337,17 @@ static void find_free_font_name(fz_context *ctx, pdf_obj *fdict, char *buf, int void pdf_set_text_annot_position(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point pt) { + fz_matrix inv_page_ctm; fz_rect rect; int flags; + fz_invert_matrix(&inv_page_ctm, &annot->page_ctm); + rect.x0 = pt.x; rect.x1 = pt.x + TEXT_ANNOT_SIZE; rect.y0 = pt.y; rect.y1 = pt.y + TEXT_ANNOT_SIZE; - fz_transform_rect(&rect, &annot->inv_page_ctm); + fz_transform_rect(&rect, &inv_page_ctm); pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &rect)); @@ -381,10 +389,13 @@ void pdf_set_free_text_details(fz_context *ctx, pdf_document *doc, pdf_annot *an pdf_obj *font = NULL; pdf_obj *ref; pdf_font_desc *font_desc = NULL; + fz_matrix inv_page_ctm; pdf_da_info da_info; fz_buffer *fzbuf = NULL; fz_point page_pos; + fz_invert_matrix(&inv_page_ctm, &annot->page_ctm); + dr = pdf_dict_get(ctx, annot->page->obj, PDF_NAME_Resources); if (!dr) { @@ -438,7 +449,7 @@ void pdf_set_free_text_details(fz_context *ctx, pdf_document *doc, pdf_annot *an pdf_measure_text(ctx, font_desc, (unsigned char *)text, strlen(text), &bounds); page_pos = *pos; - fz_transform_point(&page_pos, &annot->inv_page_ctm); + fz_transform_point(&page_pos, &inv_page_ctm); bounds.x0 *= font_size; bounds.x1 *= font_size; diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index b502730a..68da8494 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -485,7 +485,7 @@ fz_annot_type pdf_annot_type(fz_context *ctx, pdf_annot *annot) return -1; } -pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page, const fz_matrix *page_ctm, const fz_matrix *inv_page_ctm) +pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page, const fz_matrix *page_ctm) { pdf_annot *annot = fz_new_annot(ctx, sizeof(pdf_annot)); @@ -496,7 +496,6 @@ pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page, const fz_matrix *page_ annot->page = page; annot->page_ctm = *page_ctm; - annot->inv_page_ctm = *inv_page_ctm; return annot; } @@ -507,14 +506,11 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann pdf_annot *annot, **itr; pdf_obj *obj, *ap, *as, *n; int i, len, keep_annot; - fz_matrix inv_page_ctm; fz_var(annot); fz_var(itr); fz_var(keep_annot); - fz_invert_matrix(&inv_page_ctm, page_ctm); - itr = &page->annots; len = pdf_array_len(ctx, annots); @@ -530,7 +526,7 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann { obj = pdf_array_get(ctx, annots, i); - annot = pdf_new_annot(ctx, page, page_ctm, &inv_page_ctm); + annot = pdf_new_annot(ctx, page, page_ctm); *itr = annot; annot->obj = pdf_keep_obj(ctx, obj); itr = &annot->next; diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index d9e9e5a0..ff1aa4fa 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1569,17 +1569,20 @@ void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *ann pdf_obj *obj = annot->obj; fz_device *dev = NULL; pdf_xobject *xobj = NULL; + fz_matrix inv_page_ctm; pdf_obj *resources; fz_buffer *contents; + fz_invert_matrix(&inv_page_ctm, &annot->page_ctm); + fz_var(dev); fz_try(ctx) { pdf_obj *ap_obj; fz_rect trect = *rect; - fz_transform_rect(&trect, &annot->inv_page_ctm); + fz_transform_rect(&trect, &inv_page_ctm); pdf_dict_put_drop(ctx, obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &trect)); @@ -1606,7 +1609,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, &fz_identity, &trect, resources, contents); - fz_run_display_list(ctx, disp_list, dev, &annot->inv_page_ctm, &fz_infinite_rect, NULL); + fz_run_display_list(ctx, disp_list, dev, &inv_page_ctm, &fz_infinite_rect, NULL); fz_drop_device(ctx, dev); pdf_update_stream(ctx, doc, ap_obj, contents, 0); |