diff options
Diffstat (limited to 'source/tools/pdfshow.c')
-rw-r--r-- | source/tools/pdfshow.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/source/tools/pdfshow.c b/source/tools/pdfshow.c index c5d021ad..d084c080 100644 --- a/source/tools/pdfshow.c +++ b/source/tools/pdfshow.c @@ -27,7 +27,7 @@ static void showtrailer(void) if (!doc) fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified"); fprintf(out, "trailer\n"); - pdf_fprint_obj(out, pdf_trailer(doc), 0); + pdf_fprint_obj(ctx, out, pdf_trailer(ctx, doc), 0); fprintf(out, "\n"); } @@ -37,11 +37,11 @@ static void showencrypt(void) if (!doc) fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified"); - encrypt = pdf_dict_gets(pdf_trailer(doc), "Encrypt"); + encrypt = pdf_dict_gets(ctx, pdf_trailer(ctx, doc), "Encrypt"); if (!encrypt) fz_throw(ctx, FZ_ERROR_GENERIC, "document not encrypted"); fprintf(out, "encryption dictionary\n"); - pdf_fprint_obj(out, pdf_resolve_indirect(encrypt), 0); + pdf_fprint_obj(ctx, out, pdf_resolve_indirect(ctx, encrypt), 0); fprintf(out, "\n"); } @@ -49,7 +49,7 @@ static void showxref(void) { if (!doc) fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified"); - pdf_print_xref(doc); + pdf_print_xref(ctx, doc); fprintf(out, "\n"); } @@ -62,11 +62,11 @@ static void showpagetree(void) if (!doc) fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified"); - count = pdf_count_pages(doc); + count = pdf_count_pages(ctx, doc); for (i = 0; i < count; i++) { - ref = pdf_lookup_page_obj(doc, i); - fprintf(out, "page %d = %d %d R\n", i + 1, pdf_to_num(ref), pdf_to_gen(ref)); + ref = pdf_lookup_page_obj(ctx, doc, i); + fprintf(out, "page %d = %d %d R\n", i + 1, pdf_to_num(ctx, ref), pdf_to_gen(ctx, ref)); } fprintf(out, "\n"); } @@ -103,13 +103,13 @@ static void showstream(int num, int gen) showcolumn = 0; if (showdecode) - stm = pdf_open_stream(doc, num, gen); + stm = pdf_open_stream(ctx, doc, num, gen); else - stm = pdf_open_raw_stream(doc, num, gen); + stm = pdf_open_raw_stream(ctx, doc, num, gen); while (1) { - n = fz_read(stm, buf, sizeof buf); + n = fz_read(ctx, stm, buf, sizeof buf); if (n == 0) break; if (showbinary) @@ -118,7 +118,7 @@ static void showstream(int num, int gen) showsafe(buf, n); } - fz_close(stm); + fz_drop_stream(ctx, stm); } static void showobject(int num, int gen) @@ -128,9 +128,9 @@ static void showobject(int num, int gen) if (!doc) fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified"); - obj = pdf_load_object(doc, num, gen); + obj = pdf_load_object(ctx, doc, num, gen); - if (pdf_is_stream(doc, num, gen)) + if (pdf_is_stream(ctx, doc, num, gen)) { if (showbinary) { @@ -139,7 +139,7 @@ static void showobject(int num, int gen) else { fprintf(out, "%d %d obj\n", num, gen); - pdf_fprint_obj(out, obj, 0); + pdf_fprint_obj(ctx, out, obj, 0); fprintf(out, "stream\n"); showstream(num, gen); fprintf(out, "endstream\n"); @@ -149,11 +149,11 @@ static void showobject(int num, int gen) else { fprintf(out, "%d %d obj\n", num, gen); - pdf_fprint_obj(out, obj, 0); + pdf_fprint_obj(ctx, out, obj, 0); fprintf(out, "endobj\n\n"); } - pdf_drop_obj(obj); + pdf_drop_obj(ctx, obj); } static void showgrep(char *filename) @@ -161,15 +161,15 @@ static void showgrep(char *filename) pdf_obj *obj; int i, len; - len = pdf_count_objects(doc); + len = pdf_count_objects(ctx, doc); for (i = 0; i < len; i++) { - pdf_xref_entry *entry = pdf_get_xref_entry(doc, i); + pdf_xref_entry *entry = pdf_get_xref_entry(ctx, doc, i); if (entry->type == 'n' || entry->type == 'o') { fz_try(ctx) { - obj = pdf_load_object(doc, i, 0); + obj = pdf_load_object(ctx, doc, i, 0); } fz_catch(ctx) { @@ -177,17 +177,17 @@ static void showgrep(char *filename) continue; } - pdf_sort_dict(obj); + pdf_sort_dict(ctx, obj); fprintf(out, "%s:%d: ", filename, i); - pdf_fprint_obj(out, obj, 1); + pdf_fprint_obj(ctx, out, obj, 1); - pdf_drop_obj(obj); + pdf_drop_obj(ctx, obj); } } fprintf(out, "%s:trailer: ", filename); - pdf_fprint_obj(out, pdf_trailer(doc), 1); + pdf_fprint_obj(ctx, out, pdf_trailer(ctx, doc), 1); } int pdfshow_main(int argc, char **argv) @@ -236,8 +236,8 @@ int pdfshow_main(int argc, char **argv) fz_try(ctx) { doc = pdf_open_document_no_run(ctx, filename); - if (pdf_needs_password(doc)) - if (!pdf_authenticate_password(doc, password)) + if (pdf_needs_password(ctx, doc)) + if (!pdf_authenticate_password(ctx, doc, password)) fz_warn(ctx, "cannot authenticate password: %s", filename); if (fz_optind == argc) @@ -264,7 +264,7 @@ int pdfshow_main(int argc, char **argv) if (out != stdout) fclose(out); - pdf_close_document(doc); - fz_free_context(ctx); + pdf_close_document(ctx, doc); + fz_drop_context(ctx); return 0; } |