summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-11-07 19:46:54 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-11-07 20:02:57 +0100
commit7f5ccdee1f8a990e1cd675bd1a7ab4673e797f46 (patch)
treef1f888c407119aa26f7b4d2fd9964a755bdc51df
parent68840d4a34e1e56ea9130158e8e163fb60550db4 (diff)
downloadmupdf-7f5ccdee1f8a990e1cd675bd1a7ab4673e797f46.tar.xz
Write placeholder appearance streams for digital signatures.
A proper appearance stream is written when signing with a certificate. This is just to create a placeholder appearance when the original document did not write one.
-rw-r--r--source/pdf/pdf-appearance.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index ceadfd09..c18d5860 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -1067,6 +1067,25 @@ pdf_write_ch_widget_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf
}
static void
+pdf_write_sig_widget_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf,
+ fz_rect *rect, fz_rect *bbox, fz_matrix *matrix, pdf_obj **res)
+{
+ float x0 = rect->x0 + 1;
+ float y0 = rect->y0 + 1;
+ float x1 = rect->x1 - 1;
+ float y1 = rect->y1 - 1;
+ float w = x1 - x0;
+ float h = y1 - y0;
+ fz_append_printf(ctx, buf, "1 w\n0 G\n");
+ fz_append_printf(ctx, buf, "%g %g %g %g re\n", x0, y0, w, h);
+ fz_append_printf(ctx, buf, "%g %g m %g %g l\n", x0, y0, x1, y1);
+ fz_append_printf(ctx, buf, "%g %g m %g %g l\n", x1, y0, x0, y1);
+ fz_append_printf(ctx, buf, "s\n");
+ *bbox = *rect;
+ *matrix = fz_identity;
+}
+
+static void
pdf_write_widget_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf,
fz_rect *rect, fz_rect *bbox, fz_matrix *matrix, pdf_obj **res)
{
@@ -1115,6 +1134,10 @@ pdf_write_widget_appearance(fz_context *ctx, pdf_annot *annot, fz_buffer *buf,
fz_catch(ctx)
fz_rethrow(ctx);
}
+ else if (pdf_name_eq(ctx, ft, PDF_NAME(Sig)))
+ {
+ pdf_write_sig_widget_appearance(ctx, annot, buf, rect, bbox, matrix, res);
+ }
else
{
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot create appearance stream for %s widgets", pdf_to_name(ctx, ft));