summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-annot.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-07-03 18:45:55 +0100
committerRobin Watts <robin.watts@artifex.com>2013-07-03 18:56:15 +0100
commitb33b3b41100f2bb0b63dbf270bdd4401451c081a (patch)
treef01eef47af62335d0a19300bf1abc8768ff603d1 /source/pdf/pdf-annot.c
parente433d5c8d2a64d261837c7b25d7378e4ebc1d3d6 (diff)
downloadmupdf-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.
Diffstat (limited to 'source/pdf/pdf-annot.c')
-rw-r--r--source/pdf/pdf-annot.c21
1 files changed, 14 insertions, 7 deletions
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 */
}
}