summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-04-12 11:22:00 +0100
committerRobin Watts <robin.watts@artifex.com>2016-04-12 11:51:55 +0100
commitc702080ae741f08d04788fd415b2a870c6e269e7 (patch)
treeb151e65d68823601be65ab6c59f61fb64a61726b
parent80e4786f5a0673c37821ba373e78c4fb58274314 (diff)
downloadmupdf-c702080ae741f08d04788fd415b2a870c6e269e7.tar.xz
Fix PDF annotations not appearing after creation.
Caused by a mismatch in the annotation creation/loading code.
-rw-r--r--include/mupdf/pdf/annot.h5
-rw-r--r--source/pdf/pdf-annot-edit.c3
-rw-r--r--source/pdf/pdf-annot.c26
3 files changed, 22 insertions, 12 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index e25ec5db..7daad6a0 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -137,4 +137,9 @@ fz_annot_type pdf_annot_obj_type(fz_context *ctx, pdf_obj *obj);
*/
pdf_annot *pdf_poll_changed_annot(fz_context *ctx, pdf_document *idoc, pdf_page *page);
+/*
+ pdf_new_annot: Internal function for creating a new pdf annotation.
+*/
+pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page);
+
#endif
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index 66704a2f..c8594be1 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -117,8 +117,7 @@ pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_ty
/* Make printable as default */
pdf_dict_put_drop(ctx, annot_obj, PDF_NAME_F, pdf_new_int(ctx, doc, F_Print));
- annot = fz_malloc_struct(ctx, pdf_annot);
- annot->page = page;
+ annot = pdf_new_annot(ctx, page);
annot->rect = rect;
annot->pagerect = rect;
annot->ap = NULL;
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index 5261bdb0..efae4cd3 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -481,6 +481,20 @@ fz_annot_type pdf_annot_obj_type(fz_context *ctx, pdf_obj *obj)
return -1;
}
+pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page)
+{
+ pdf_annot *annot = fz_new_annot(ctx, sizeof(pdf_annot));
+
+ annot->super.drop_annot_imp = (fz_annot_drop_imp_fn*)pdf_drop_annot_imp;
+ annot->super.bound_annot = (fz_annot_bound_fn*)pdf_bound_annot;
+ annot->super.run_annot = (fz_annot_run_fn*)pdf_run_annot;
+ annot->super.next_annot = (fz_annot_next_fn*)pdf_next_annot;
+
+ annot->page = page;
+
+ return annot;
+}
+
void
pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *annots)
{
@@ -507,17 +521,9 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann
{
obj = pdf_array_get(ctx, annots, i);
- annot = fz_new_annot(ctx, sizeof(pdf_annot));
- annot->super.drop_annot_imp = (fz_annot_drop_imp_fn*)pdf_drop_annot_imp;
- annot->super.bound_annot = (fz_annot_bound_fn*)pdf_bound_annot;
- annot->super.run_annot = (fz_annot_run_fn*)pdf_run_annot;
- annot->super.next_annot = (fz_annot_next_fn*)pdf_next_annot;
-
- annot->page = page;
- annot->obj = pdf_keep_obj(ctx, obj);
- annot->next = NULL;
-
+ annot = pdf_new_annot(ctx, page);
*itr = annot;
+ annot->obj = pdf_keep_obj(ctx, obj);
itr = &annot->next;
}
}