From 646abf766e4037ba1ce9e564423cf827a203b94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Fri, 3 Jan 2014 11:39:19 +0100 Subject: tolerate slightly broken page trees At https://code.google.com/p/sumatrapdf/issues/detail?id=2460 , there's a file with missing /Type keys in the page tree nodes. In that case, leaf nodes and intermediary nodes have to be distinguished in a different way. --- source/pdf/pdf-page.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index 10496d57..f3c929d2 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -64,7 +64,7 @@ pdf_lookup_page_loc_imp(pdf_document *doc, pdf_obj *node, int *skip, pdf_obj **p { pdf_obj *kid = pdf_array_get(kids, i); char *type = pdf_to_name(pdf_dict_gets(kid, "Type")); - if (!strcmp(type, "Page")) + if (!strcmp(type, "Page") || (!*type && pdf_dict_gets(kid, "MediaBox"))) { if (*skip == 0) { @@ -78,7 +78,7 @@ pdf_lookup_page_loc_imp(pdf_document *doc, pdf_obj *node, int *skip, pdf_obj **p (*skip)--; } } - else if (!strcmp(type, "Pages")) + else if (!strcmp(type, "Pages") || (!*type && pdf_dict_gets(kid, "Kids"))) { int count = pdf_to_int(pdf_dict_gets(kid, "Count")); if (*skip < count) @@ -93,7 +93,7 @@ pdf_lookup_page_loc_imp(pdf_document *doc, pdf_obj *node, int *skip, pdf_obj **p } else { - fz_throw(ctx, FZ_ERROR_GENERIC, "non-page object in page tree"); + fz_throw(ctx, FZ_ERROR_GENERIC, "non-page object in page tree (%s)", type); } } } -- cgit v1.2.3