From 2a8a6d46868b7a78cab1abc0ab4ef95ad9036914 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Tue, 7 Aug 2012 15:15:10 +0100 Subject: When updating an xobject's contents also reset the Length --- pdf/pdf_xobject.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c index 6af7d951..3777602d 100644 --- a/pdf/pdf_xobject.c +++ b/pdf/pdf_xobject.c @@ -226,6 +226,24 @@ pdf_new_xobject(pdf_document *xref, fz_rect *bbox, fz_matrix *mat) void pdf_update_xobject_contents(pdf_document *xref, pdf_xobject *form, fz_buffer *buffer) { - pdf_dict_dels(form->contents, "Filter"); - pdf_update_stream(xref, pdf_to_num(form->contents), buffer); + fz_context *ctx = xref->ctx; + pdf_obj *len = NULL; + + fz_var(len); + + fz_try(ctx) + { + len = pdf_new_int(ctx, buffer->len); + pdf_dict_dels(form->contents, "Filter"); + pdf_dict_puts(form->contents, "Length", len); + pdf_update_stream(xref, pdf_to_num(form->contents), buffer); + } + fz_always(ctx) + { + pdf_drop_obj(len); + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } } -- cgit v1.2.3