diff options
Diffstat (limited to 'source/pdf/pdf-form.c')
-rw-r--r-- | source/pdf/pdf-form.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index 36d07ee1..88737ce4 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -1295,6 +1295,36 @@ int pdf_signature_widget_byte_range(fz_context *ctx, pdf_document *doc, pdf_widg return n; } +fz_stream *pdf_signature_widget_hash_bytes(fz_context *ctx, pdf_document *doc, pdf_widget *widget) +{ + fz_range *byte_range = NULL; + int byte_range_len; + fz_stream *bytes = NULL; + + fz_var(byte_range); + fz_try(ctx) + { + byte_range_len = pdf_signature_widget_byte_range(ctx, doc, widget, NULL); + if (byte_range_len) + { + byte_range = fz_calloc(ctx, byte_range_len, sizeof(*byte_range)); + pdf_signature_widget_byte_range(ctx, doc, widget, byte_range); + } + + bytes = fz_open_null_n(ctx, fz_keep_stream(ctx, doc->file), byte_range, byte_range_len); + } + fz_always(ctx) + { + fz_free(ctx, byte_range); + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } + + return bytes; +} + int pdf_signature_widget_contents(fz_context *ctx, pdf_document *doc, pdf_widget *widget, char **contents) { pdf_annot *annot = (pdf_annot *)widget; |