diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-05-13 14:13:16 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-05-30 16:01:58 +0200 |
commit | 5a44698a2f51785e2cc08b55b4cf2aa22990b2ba (patch) | |
tree | 928092b5bab28dfbb330b3b4e9715b05fb16ecb7 /pdf | |
parent | 880149f48e58ac93697fd19a90df6b31a2242659 (diff) | |
download | mupdf-5a44698a2f51785e2cc08b55b4cf2aa22990b2ba.tar.xz |
Add functions to return digital signature info
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/mupdf-internal.h | 2 | ||||
-rw-r--r-- | pdf/pdf_field.c | 2 | ||||
-rw-r--r-- | pdf/pdf_form.c | 27 |
3 files changed, 31 insertions, 0 deletions
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); +} |