diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-04-27 17:31:22 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-05-03 12:41:27 +0200 |
commit | 09ef5e2d36eb0f8206d6daa702302dcc6d80f216 (patch) | |
tree | c20f9b42345621a9cdd54850a0291986f1da8330 /source | |
parent | 9ebdb1a76b50bfecd0ecbf06c067f856dd7370c5 (diff) | |
download | mupdf-09ef5e2d36eb0f8206d6daa702302dcc6d80f216.tar.xz |
Tweak 'mutool show ... grep' output.
Diffstat (limited to 'source')
-rw-r--r-- | source/tools/pdfshow.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/source/tools/pdfshow.c b/source/tools/pdfshow.c index d53b701e..e252c4ec 100644 --- a/source/tools/pdfshow.c +++ b/source/tools/pdfshow.c @@ -177,9 +177,9 @@ static void showobject(int num) pdf_drop_obj(ctx, ref); } -static void showgrep(char *filename) +static void showgrep(void) { - pdf_obj *obj; + pdf_obj *ref, *obj; int i, len; len = pdf_count_objects(ctx, doc); @@ -190,7 +190,8 @@ static void showgrep(char *filename) { fz_try(ctx) { - obj = pdf_load_object(ctx, doc, i); + ref = pdf_new_indirect(ctx, doc, i, 0); + obj = pdf_resolve_indirect(ctx, ref); } fz_catch(ctx) { @@ -200,15 +201,17 @@ static void showgrep(char *filename) pdf_sort_dict(ctx, obj); - fz_write_printf(ctx, out, "%s:%d: ", filename, i); + fz_write_printf(ctx, out, "%d 0 obj ", i); pdf_print_obj(ctx, out, obj, 1); + if (pdf_is_stream(ctx, ref)) + fz_write_printf(ctx, out, " stream"); fz_write_printf(ctx, out, "\n"); - pdf_drop_obj(ctx, obj); + pdf_drop_obj(ctx, ref); } } - fz_write_printf(ctx, out, "%s:trailer: ", filename); + fz_write_printf(ctx, out, "trailer "); pdf_print_obj(ctx, out, pdf_trailer(ctx, doc), 1); fz_write_printf(ctx, out, "\n"); } @@ -294,7 +297,7 @@ int pdfshow_main(int argc, char **argv) case 'e': showencrypt(); break; case 'x': showxref(); break; case 'p': showpagetree(); break; - case 'g': showgrep(filename); break; + case 'g': showgrep(); break; case 'o': showoutline(); break; default: showobject(atoi(argv[fz_optind])); break; } |