summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2013-05-13 14:13:16 +0100
committerTor Andersson <tor.andersson@artifex.com>2013-05-30 16:01:58 +0200
commit5a44698a2f51785e2cc08b55b4cf2aa22990b2ba (patch)
tree928092b5bab28dfbb330b3b4e9715b05fb16ecb7
parent880149f48e58ac93697fd19a90df6b31a2242659 (diff)
downloadmupdf-5a44698a2f51785e2cc08b55b4cf2aa22990b2ba.tar.xz
Add functions to return digital signature info
-rw-r--r--fitz/doc_interactive.c10
-rw-r--r--fitz/fitz.h13
-rw-r--r--pdf/mupdf-internal.h2
-rw-r--r--pdf/pdf_field.c2
-rw-r--r--pdf/pdf_form.c27
5 files changed, 53 insertions, 1 deletions
diff --git a/fitz/doc_interactive.c b/fitz/doc_interactive.c
index 10d48129..c9cdf6aa 100644
--- a/fitz/doc_interactive.c
+++ b/fitz/doc_interactive.c
@@ -81,6 +81,16 @@ void fz_choice_widget_set_value(fz_interactive *idoc, fz_widget *tw, int n, char
pdf_choice_widget_set_value((pdf_document *)idoc, tw, n, opts);
}
+int fz_signature_widget_byte_range(fz_interactive *idoc, fz_widget *widget, int (*byte_range)[2])
+{
+ return pdf_signature_widget_byte_range((pdf_document *)idoc, widget, byte_range);
+}
+
+int fz_signature_widget_contents(fz_interactive *idoc, fz_widget *widget, char **contents)
+{
+ return pdf_signature_widget_contents((pdf_document *)idoc, widget, contents);
+}
+
fz_annot_type fz_get_annot_type(fz_annot *annot)
{
return pdf_annot_type((pdf_annot *)annot);
diff --git a/fitz/fitz.h b/fitz/fitz.h
index fd999421..70da29d7 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -3032,7 +3032,8 @@ enum
FZ_WIDGET_TYPE_RADIOBUTTON,
FZ_WIDGET_TYPE_TEXT,
FZ_WIDGET_TYPE_LISTBOX,
- FZ_WIDGET_TYPE_COMBOBOX
+ FZ_WIDGET_TYPE_COMBOBOX,
+ FZ_WIDGET_TYPE_SIGNATURE
};
/* Types of text widget content */
@@ -3227,6 +3228,16 @@ int fz_choice_widget_value(fz_interactive *idoc, fz_widget *tw, char *opts[]);
void fz_choice_widget_set_value(fz_interactive *idoc, fz_widget *tw, int n, char *opts[]);
/*
+ fz_signature_widget_byte_range: retrieve the byte range for a signature widget
+*/
+int fz_signature_widget_byte_range(fz_interactive *idoc, fz_widget *widget, int (*byte_range)[2]);
+
+/*
+ fz_signature_widget_contents: retrieve the contents for a signature widget
+*/
+int fz_signature_widget_contents(fz_interactive *idoc, fz_widget *widget, char **contents);
+
+/*
Document events: the objects via which MuPDF informs the calling app
of occurrences emanating from the document, possibly from user interaction
or javascript execution. MuPDF informs the app of document events via a
diff --git a/pdf/mupdf-internal.h b/pdf/mupdf-internal.h
index d1b923c3..b7931e4f 100644
--- a/pdf/mupdf-internal.h
+++ b/pdf/mupdf-internal.h
@@ -587,6 +587,8 @@ int pdf_choice_widget_options(pdf_document *doc, fz_widget *tw, char *opts[]);
int pdf_choice_widget_is_multiselect(pdf_document *doc, fz_widget *tw);
int pdf_choice_widget_value(pdf_document *doc, fz_widget *tw, char *opts[]);
void pdf_choice_widget_set_value(pdf_document *doc, fz_widget *tw, int n, char *opts[]);
+int pdf_signature_widget_byte_range(pdf_document *doc, fz_widget *widget, int (*byte_range)[2]);
+int pdf_signature_widget_contents(pdf_document *doc, fz_widget *widget, char **contents);
pdf_annot *pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type);
void pdf_delete_annot(pdf_document *doc, pdf_page *page, pdf_annot *annot);
void pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_rect *rect, fz_display_list *disp_list);
diff --git a/pdf/pdf_field.c b/pdf/pdf_field.c
index 964c04c1..d68fd9bf 100644
--- a/pdf/pdf_field.c
+++ b/pdf/pdf_field.c
@@ -50,6 +50,8 @@ int pdf_field_type(pdf_document *doc, pdf_obj *obj)
else
return FZ_WIDGET_TYPE_LISTBOX;
}
+ else if (!strcmp(type, "Sig"))
+ return FZ_WIDGET_TYPE_SIGNATURE;
else
return FZ_WIDGET_TYPE_NOT_WIDGET;
}
diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c
index d7dd6503..d91aed19 100644
--- a/pdf/pdf_form.c
+++ b/pdf/pdf_form.c
@@ -2848,3 +2848,30 @@ void pdf_choice_widget_set_value(pdf_document *doc, fz_widget *tw, int n, char *
fz_rethrow(ctx);
}
}
+
+int pdf_signature_widget_byte_range(pdf_document *doc, fz_widget *widget, int (*byte_range)[2])
+{
+ pdf_annot *annot = (pdf_annot *)widget;
+ pdf_obj *br = pdf_dict_getp(annot->obj, "V/ByteRange");
+ int i, n = pdf_array_len(br)/2;
+
+ if (byte_range)
+ {
+ for (i = 0; i < n; i++)
+ {
+ byte_range[i][0] = pdf_to_int(pdf_array_get(br, 2*i));
+ byte_range[i][1] = pdf_to_int(pdf_array_get(br, 2*i+1));
+ }
+ }
+
+ return n;
+}
+
+int pdf_signature_widget_contents(pdf_document *doc, fz_widget *widget, char **contents)
+{
+ pdf_annot *annot = (pdf_annot *)widget;
+ pdf_obj *c = pdf_dict_getp(annot->obj, "V/Contents");
+ if (contents)
+ *contents = pdf_to_str_buf(c);
+ return pdf_to_str_len(c);
+}