summaryrefslogtreecommitdiff
path: root/pdf/pdf_interpret.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-06 14:57:56 +0000
committerRobin Watts <robin.watts@artifex.com>2012-01-06 14:57:56 +0000
commit95f29c10759bc42e940869f1a0d2f82db16f8709 (patch)
tree16c0563ee04f58ee8e6ec75ff09764230ca0ef14 /pdf/pdf_interpret.c
parent6dd9108c5865c1ea2ab0e834f4ae85aa279bcca9 (diff)
downloadmupdf-95f29c10759bc42e940869f1a0d2f82db16f8709.tar.xz
PDF fixes/tweaks.
Fix 2 places where we were filling a stroked pattern rather than stroking it. Cope with being asked to run a NULL buffer. If running a stream fails, warn and return what we have, rather than giving up entirely. Should really set a return code for each render. Only look at the Print flag bit for Print renders. Only look at the View flag bit for view renders. If we find an unexpected ) or > during object parsing, warn and continue rather than giving up entirely. If optional content groups are broken, render the rest of the page anyway. Previously indirect objects that point to another indirection would cause a failure; now attempt to resolve these. We set an arbitrary limit of 10 such redirections to avoid infinite loops.
Diffstat (limited to 'pdf/pdf_interpret.c')
-rw-r--r--pdf/pdf_interpret.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index 14574f14..2172eb89 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -500,7 +500,7 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd)
if (gstate->stroke.pattern)
{
fz_clip_stroke_path(csi->dev, path, &bbox, &gstate->stroke_state, gstate->ctm);
- pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL);
+ pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_STROKE);
fz_pop_clip(csi->dev);
}
break;
@@ -623,7 +623,7 @@ pdf_flush_text(pdf_csi *csi)
if (gstate->stroke.pattern)
{
fz_clip_stroke_text(csi->dev, text, &gstate->stroke_state, gstate->ctm);
- pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL);
+ pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_STROKE);
fz_pop_clip(csi->dev);
}
break;
@@ -1491,7 +1491,7 @@ pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate)
else if (!strcmp(s, "TR"))
{
- if (fz_is_name(val) && strcmp(fz_to_name(val), "Identity"))
+ if (!fz_is_name(val) || strcmp(fz_to_name(val), "Identity"))
fz_warn(ctx, "ignoring transfer function");
}
}
@@ -2542,13 +2542,23 @@ pdf_run_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents)
fz_var(buf);
fz_var(file);
+ if (contents == NULL)
+ return;
+
fz_try(ctx)
{
buf = fz_malloc(ctx, len); /* we must be re-entrant for type3 fonts */
file = fz_open_buffer(ctx, contents);
save_in_text = csi->in_text;
csi->in_text = 0;
- pdf_run_stream(csi, rdb, file, buf, len);
+ fz_try(ctx)
+ {
+ pdf_run_stream(csi, rdb, file, buf, len);
+ }
+ fz_catch(ctx)
+ {
+ fz_warn(ctx, "Content stream parsing error - rendering truncated");
+ }
csi->in_text = save_in_text;
}
fz_catch(ctx)
@@ -2609,7 +2619,9 @@ pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matri
continue;
if (flags & (1 << 1)) /* Hidden */
continue;
- if (flags & (1 << 5)) /* NoView */
+ if (!strcmp(event, "Print") && !(flags & (1 << 2))) /* Print */
+ continue;
+ if (!strcmp(event, "View") && (flags & (1 << 5))) /* NoView */
continue;
csi = pdf_new_csi(xref, dev, ctm, event, cookie);