summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/pdf/annot.h3
-rw-r--r--source/pdf/pdf-annot-edit.c50
2 files changed, 53 insertions, 0 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index 576ab310..2ae4d1c3 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -165,7 +165,10 @@ void pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float width);
void pdf_set_annot_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4]);
void pdf_set_annot_interior_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4]);
void pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const float *v);
+
void pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *count, const float *v);
+void pdf_clear_annot_ink_list(fz_context *ctx, pdf_annot *annot);
+void pdf_add_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, fz_point stroke[]);
void pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int start_style, int end_style);
void pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const float *v);
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index 53be06d2..97671eea 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -826,6 +826,56 @@ pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *coun
pdf_dirty_annot(ctx, annot);
}
+void
+pdf_clear_annot_ink_list(fz_context *ctx, pdf_annot *annot)
+{
+ check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
+ pdf_dict_del(ctx, annot->obj, PDF_NAME_InkList);
+ pdf_dirty_annot(ctx, annot);
+}
+
+void
+pdf_add_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, fz_point p[])
+{
+ pdf_document *doc = annot->page->doc;
+ fz_matrix page_ctm, inv_page_ctm;
+ pdf_obj *ink_list, *stroke;
+ int i;
+
+ check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes);
+
+ pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
+ fz_invert_matrix(&inv_page_ctm, &page_ctm);
+
+ ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME_InkList);
+ if (!pdf_is_array(ctx, ink_list))
+ {
+ ink_list = pdf_new_array(ctx, doc, 10);
+ pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_InkList, ink_list);
+ }
+
+ stroke = pdf_new_array(ctx, doc, n * 2);
+ fz_try(ctx)
+ {
+ for (i = 0; i < n; ++i)
+ {
+ fz_point tp = p[i];
+ fz_transform_point(&tp, &inv_page_ctm);
+ pdf_array_push_real(ctx, stroke, tp.x);
+ pdf_array_push_real(ctx, stroke, tp.y);
+ }
+ }
+ fz_catch(ctx)
+ {
+ pdf_drop_obj(ctx, stroke);
+ fz_rethrow(ctx);
+ }
+
+ pdf_array_push_drop(ctx, ink_list, stroke);
+
+ pdf_dirty_annot(ctx, annot);
+}
+
static void find_free_font_name(fz_context *ctx, pdf_obj *fdict, char *buf, int buf_size)
{
int i;