summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2016-06-22 13:20:45 -0700
committerRobin Watts <robin.watts@artifex.com>2016-06-22 22:10:45 +0100
commitc92707fece670689c9dd7470e35bdc802946dc45 (patch)
tree5bb8665e93d225e70bc64a57d30811c31f362bf7
parent680bcf8deaf4165914f2ec8655a84b4e2c42c12b (diff)
downloadmupdf-c92707fece670689c9dd7470e35bdc802946dc45.tar.xz
Add support for getting additional annotation information
GSView will make use of the details about the annotations including the author, the date and which annotation the annotation is in reply to. This commit provides the interface to do this easily.
-rw-r--r--include/mupdf/pdf/annot.h17
-rw-r--r--resources/pdf/names.txt2
-rw-r--r--source/pdf/pdf-annot-edit.c17
3 files changed, 34 insertions, 2 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index c648370c..beb100df 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -121,7 +121,22 @@ void pdf_set_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot
/*
pdf_annot_contents: return the contents of an annotation.
*/
-char *pdf_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
+char *pdf_annot_contents(fz_context *ctx, pdf_annot *annot);
+
+/*
+ pdf_annot_author: return the author of an annotation.
+*/
+char *pdf_annot_author(fz_context *ctx, pdf_annot *annot);
+
+/*
+ pdf_annot_author: return the date of an annotation.
+*/
+char *pdf_annot_date(fz_context *ctx, pdf_annot *annot);
+
+/*
+ pdf_annot_irt: return the indirect reference that this annotation is in reply to.
+*/
+pdf_obj *pdf_annot_irt(fz_context *ctx, pdf_annot *annot);
/*
pdf_set_free_text_details: set the position, text, font and color for a free text annotation.
diff --git a/resources/pdf/names.txt b/resources/pdf/names.txt
index ff63d99d..ff91055b 100644
--- a/resources/pdf/names.txt
+++ b/resources/pdf/names.txt
@@ -76,6 +76,7 @@ Contents
Coords
Count
Cover
+CreationDate
Creator
CropBox
Crypt
@@ -169,6 +170,7 @@ I
ICCBased
ID
IM
+IRT
Identity
Identity-H
Identity-V
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index 4d5d924c..d073a699 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -373,11 +373,26 @@ void pdf_set_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Contents, pdf_new_string(ctx, doc, text, strlen(text)));
}
-char *pdf_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot)
+char *pdf_annot_contents(fz_context *ctx, pdf_annot *annot)
{
return pdf_to_str_buf(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Contents));
}
+char *pdf_annot_author(fz_context *ctx, pdf_annot *annot)
+{
+ return pdf_to_str_buf(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_T));
+}
+
+char *pdf_annot_date(fz_context *ctx, pdf_annot *annot)
+{
+ return pdf_to_str_buf(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_CreationDate));
+}
+
+pdf_obj *pdf_annot_irt(fz_context *ctx, pdf_annot *annot)
+{
+ return pdf_dict_get(ctx, annot->obj, PDF_NAME_IRT);
+}
+
void pdf_set_free_text_details(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *pos, char *text, char *font_name, float font_size, float color[3])
{
char nbuf[32];