summaryrefslogtreecommitdiff
path: root/apps/pdfshow.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/pdfshow.c')
-rw-r--r--apps/pdfshow.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/apps/pdfshow.c b/apps/pdfshow.c
index a84e962b..2fbfdc2f 100644
--- a/apps/pdfshow.c
+++ b/apps/pdfshow.c
@@ -205,26 +205,35 @@ int main(int argc, char **argv)
exit(1);
}
- xref = pdf_open_xref(ctx, filename, password);
+ fz_var(xref);
+ fz_try(ctx)
+ {
+ xref = pdf_open_xref(ctx, filename);
+ if (pdf_needs_password(xref))
+ if (!pdf_authenticate_password(xref, password))
+ fz_throw(ctx, "cannot authenticate password: %s", filename);
- if (fz_optind == argc)
- showtrailer();
+ if (fz_optind == argc)
+ showtrailer();
- while (fz_optind < argc)
- {
- switch (argv[fz_optind][0])
+ while (fz_optind < argc)
{
- 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;
+ switch (argv[fz_optind][0])
+ {
+ 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++;
}
- fz_optind++;
+ }
+ fz_catch(ctx)
+ {
}
pdf_free_xref(xref);
- fz_flush_warnings(ctx);
fz_free_context(ctx);
return 0;
}