diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-07-03 18:45:55 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-07-03 18:56:15 +0100 |
commit | b33b3b41100f2bb0b63dbf270bdd4401451c081a (patch) | |
tree | f01eef47af62335d0a19300bf1abc8768ff603d1 | |
parent | e433d5c8d2a64d261837c7b25d7378e4ebc1d3d6 (diff) | |
download | mupdf-b33b3b41100f2bb0b63dbf270bdd4401451c081a.tar.xz |
Avoid fz_throw/message on every annotation without appearance.
Annotations can sometimes not have appearance streams (such as
Links). Avoid spewing messages to the console about this. Also
avoids overhead of throw/catch each time.
-rw-r--r-- | include/mupdf/fitz/context.h | 1 | ||||
-rw-r--r-- | source/pdf/pdf-annot.c | 21 |
2 files changed, 14 insertions, 8 deletions
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h index fea8c868..d7365227 100644 --- a/include/mupdf/fitz/context.h +++ b/include/mupdf/fitz/context.h @@ -76,7 +76,6 @@ enum { FZ_ERROR_NONE = 0, FZ_ERROR_GENERIC = 1, - FZ_ERROR_NO_APPEARANCE_STREAM = 2, FZ_ERROR_COUNT }; diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index cbe2d201..bfc31e9a 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -479,12 +479,13 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page) { pdf_annot *annot, *head, **itr; pdf_obj *obj, *ap, *as, *n, *rect; - int i, len, is_dict; + int i, len, keep_annot; fz_context *ctx = doc->ctx; fz_var(annot); fz_var(itr); fz_var(head); + fz_var(keep_annot); head = NULL; @@ -538,10 +539,13 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page) rect = pdf_dict_gets(obj, "Rect"); ap = pdf_dict_gets(obj, "AP"); as = pdf_dict_gets(obj, "AS"); - is_dict = pdf_is_dict(ap); - if (!is_dict) - fz_throw(ctx, FZ_ERROR_NO_APPEARANCE_STREAM, "Annotation has no appearance stream"); + /* We only collect annotations with an appearance + * stream into this list, so remove any that don't + * (such as links) and continue. */ + keep_annot = pdf_is_dict(ap); + if (!keep_annot) + break; if (hp->num == pdf_to_num(obj) && hp->gen == pdf_to_gen(obj) @@ -579,13 +583,16 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page) } fz_catch(ctx) { + keep_annot = 0; + fz_warn(ctx, "ignoring broken annotation"); + /* FIXME: TryLater */ + } + if (!keep_annot) + { /* Move to next item in the linked list, dropping this one */ *itr = annot->next; annot->next = NULL; /* Required because pdf_free_annot follows the "next" chain */ pdf_free_annot(ctx, annot); - if (fz_caught(ctx) != FZ_ERROR_NO_APPEARANCE_STREAM) - fz_warn(ctx, "ignoring broken annotation"); - /* FIXME: TryLater */ } } |