1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#include "pdf-interpret-imp.h"
static void
pdf_run_annot_with_usage(pdf_document *doc, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie)
{
fz_matrix local_ctm;
pdf_process process;
fz_concat(&local_ctm, &page->ctm, ctm);
pdf_process_run(&process, dev, &local_ctm, event, NULL, 0);
pdf_process_annot(doc, page, annot, &process, cookie);
}
static void pdf_run_page_contents_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie)
{
fz_matrix local_ctm;
pdf_process process;
fz_concat(&local_ctm, &page->ctm, ctm);
if (page->transparency)
{
fz_rect mediabox = page->mediabox;
fz_begin_group(dev, fz_transform_rect(&mediabox, &local_ctm), 1, 0, 0, 1);
}
pdf_process_run(&process, dev, &local_ctm, event, NULL, 0);
pdf_process_page_contents(doc, page, &process, cookie);
if (page->transparency)
fz_end_group(dev);
}
void pdf_run_page_contents(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie)
{
pdf_run_page_contents_with_usage(doc, page, dev, ctm, "View", cookie);
if (page->incomplete & PDF_PAGE_INCOMPLETE_CONTENTS)
fz_throw(doc->ctx, FZ_ERROR_TRYLATER, "incomplete rendering");
}
void pdf_run_annot(pdf_document *doc, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie)
{
pdf_run_annot_with_usage(doc, page, annot, dev, ctm, "View", cookie);
if (page->incomplete & PDF_PAGE_INCOMPLETE_ANNOTS)
fz_throw(doc->ctx, FZ_ERROR_TRYLATER, "incomplete rendering");
}
static void pdf_run_page_annots_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie)
{
pdf_annot *annot;
if (cookie && cookie->progress_max != -1)
{
int count = 1;
for (annot = page->annots; annot; annot = annot->next)
count++;
cookie->progress_max += count;
}
for (annot = page->annots; annot; annot = annot->next)
{
/* Check the cookie for aborting */
if (cookie)
{
if (cookie->abort)
break;
cookie->progress++;
}
pdf_run_annot_with_usage(doc, page, annot, dev, ctm, event, cookie);
}
}
void
pdf_run_page_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie)
{
pdf_run_page_contents_with_usage(doc, page, dev, ctm, event, cookie);
pdf_run_page_annots_with_usage(doc, page, dev, ctm, event, cookie);
if (page->incomplete)
fz_throw(doc->ctx, FZ_ERROR_TRYLATER, "incomplete rendering");
}
void
pdf_run_page(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie)
{
pdf_run_page_with_usage(doc, page, dev, ctm, "View", cookie);
}
void
pdf_run_glyph(pdf_document *doc, pdf_obj *resources, fz_buffer *contents, fz_device *dev, const fz_matrix *ctm, void *gstate, int nested_depth)
{
fz_context *ctx = doc->ctx;
pdf_process process;
if (nested_depth > 10)
fz_throw(ctx, FZ_ERROR_GENERIC, "Too many nestings of Type3 glyphs");
pdf_process_run(&process, dev, ctm, "View", gstate, nested_depth+1);
pdf_process_glyph(doc, resources, contents, &process);
}
|