summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz/context.h1
-rw-r--r--source/pdf/pdf-annot.c21
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 */
}
}