diff options
-rw-r--r-- | include/mupdf/pdf/object.h | 2 | ||||
-rw-r--r-- | source/pdf/pdf-object.c | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/include/mupdf/pdf/object.h b/include/mupdf/pdf/object.h index 3875e2c9..cd9994dd 100644 --- a/include/mupdf/pdf/object.h +++ b/include/mupdf/pdf/object.h @@ -163,6 +163,8 @@ int pdf_sprint_encrypted_obj(fz_context *ctx, char *s, int n, pdf_obj *obj, int int pdf_print_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight); int pdf_print_encrypted_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight, pdf_crypt *crypt, int num, int gen); +void pdf_debug_obj(fz_context *ctx, pdf_obj *obj); + char *pdf_to_utf8(fz_context *ctx, pdf_obj *src); char *pdf_load_stream_as_utf8(fz_context *ctx, pdf_obj *src); char *pdf_load_stream_or_string_as_utf8(fz_context *ctx, pdf_obj *src); diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index 3d694d0c..056d6a73 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -2151,6 +2151,33 @@ int pdf_print_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight) return pdf_print_encrypted_obj(ctx, out, obj, tight, NULL, 0, 0); } +static int pdf_debug_encrypted_obj(fz_context *ctx, pdf_obj *obj, int tight, pdf_crypt *crypt, int num, int gen) +{ + char buf[1024]; + char *ptr; + int n; + + n = pdf_sprint_obj(ctx, NULL, 0, obj, tight); + if ((n + 1) < sizeof buf) + { + pdf_sprint_encrypted_obj(ctx, buf, sizeof buf, obj, tight, crypt, num, gen); + fwrite(buf, 1, n, stdout); + } + else + { + ptr = fz_malloc(ctx, n + 1); + pdf_sprint_encrypted_obj(ctx, ptr, n + 1, obj, tight, crypt, num, gen); + fwrite(ptr, 1, n, stdout); + fz_free(ctx, ptr); + } + return n; +} + +void pdf_debug_obj(fz_context *ctx, pdf_obj *obj) +{ + pdf_debug_encrypted_obj(ctx, obj, 0, NULL, 0, 0); +} + int pdf_obj_refs(fz_context *ctx, pdf_obj *ref) { return (ref >= PDF_OBJ__LIMIT ? ref->refs : 0); |