diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pdfshow.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/apps/pdfshow.c b/apps/pdfshow.c index b05f6013..22891e05 100644 --- a/apps/pdfshow.c +++ b/apps/pdfshow.c @@ -20,7 +20,7 @@ void die(fz_error error) static void usage(void) { - fprintf(stderr, "usage: pdfshow [options] file.pdf [xref] [trailer] [pagetree] [object numbers]\n"); + fprintf(stderr, "usage: pdfshow [options] file.pdf [grepable] [xref] [trailer] [pagetree] [object numbers]\n"); fprintf(stderr, "\t-b\tprint streams as binary data\n"); fprintf(stderr, "\t-e\tprint encoded streams (don't decode)\n"); fprintf(stderr, "\t-p\tpassword\n"); @@ -163,11 +163,33 @@ static void showobject(int num, int gen) fz_dropobj(obj); } +static void showgrep(char *filename) +{ + fz_error error; + fz_obj *obj; + int i; + + for (i = 0; i < xref->len; i++) + { + if (xref->table[i].type == 'n' || xref->table[i].type == 'o') + { + error = pdf_loadobject(&obj, xref, i, 0); + if (error) + die(error); + + printf("%s:%d: ", filename, i); + fz_fprintobj(stdout, obj, 1); + + fz_dropobj(obj); + } + } +} + int main(int argc, char **argv) { char *password = NULL; /* don't throw errors if encrypted */ - fz_error error; char *filename; + fz_error error; int c; while ((c = fz_getopt(argc, argv, "p:be")) != -1) @@ -199,6 +221,7 @@ int main(int argc, char **argv) case 't': showtrailer(); break; case 'x': showxref(); break; case 'p': showpagetree(); break; + case 'g': showgrep(filename); break; default: showobject(atoi(argv[fz_optind]), 0); break; } fz_optind++; |