Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7638 views
1
#ifndef MUPDF_PDF_PAGE_H
2
#define MUPDF_PDF_PAGE_H
3
4
int pdf_lookup_page_number(fz_context *ctx, pdf_document *doc, pdf_obj *pageobj);
5
int pdf_count_pages(fz_context *ctx, pdf_document *doc);
6
pdf_obj *pdf_lookup_page_obj(fz_context *ctx, pdf_document *doc, int needle);
7
8
/*
9
pdf_load_page: Load a page and its resources.
10
11
Locates the page in the PDF document and loads the page and its
12
resources. After pdf_load_page is it possible to retrieve the size
13
of the page using pdf_bound_page, or to render the page using
14
pdf_run_page_*.
15
16
number: page number, where 0 is the first page of the document.
17
*/
18
pdf_page *pdf_load_page(fz_context *ctx, pdf_document *doc, int number);
19
20
void pdf_drop_page(fz_context *ctx, pdf_page *page);
21
22
fz_link *pdf_load_links(fz_context *ctx, pdf_page *page);
23
24
/*
25
pdf_bound_page: Determine the size of a page.
26
27
Determine the page size in user space units, taking page rotation
28
into account. The page size is taken to be the crop box if it
29
exists (visible area after cropping), otherwise the media box will
30
be used (possibly including printing marks).
31
32
Does not throw exceptions.
33
*/
34
fz_rect *pdf_bound_page(fz_context *ctx, pdf_page *page, fz_rect *);
35
36
/*
37
pdf_run_page: Interpret a loaded page and render it on a device.
38
39
page: A page loaded by pdf_load_page.
40
41
dev: Device used for rendering, obtained from fz_new_*_device.
42
43
ctm: A transformation matrix applied to the objects on the page,
44
e.g. to scale or rotate the page contents as desired.
45
*/
46
void pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
47
48
/*
49
pdf_run_page: Interpret a loaded page and render it on a device.
50
51
page: A page loaded by pdf_load_page.
52
53
dev: Device used for rendering, obtained from fz_new_*_device.
54
55
ctm: A transformation matrix applied to the objects on the page,
56
e.g. to scale or rotate the page contents as desired.
57
58
cookie: A pointer to an optional fz_cookie structure that can be used
59
to track progress, collect errors etc.
60
*/
61
void pdf_run_page_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie);
62
63
/*
64
pdf_run_page_contents: Interpret a loaded page and render it on a device.
65
Just the main page contents without the annotations
66
67
page: A page loaded by pdf_load_page.
68
69
dev: Device used for rendering, obtained from fz_new_*_device.
70
71
ctm: A transformation matrix applied to the objects on the page,
72
e.g. to scale or rotate the page contents as desired.
73
*/
74
void pdf_run_page_contents(fz_context *ctx, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
75
76
/*
77
pdf_page_contents_process_fn: A function used for processing the
78
cleaned page contents/resources gathered as part of
79
pdf_clean_page_contents.
80
81
buffer: A buffer holding the page contents.
82
83
res: A pdf_obj holding the page resources.
84
85
arg: An opaque arg specific to the particular function.
86
*/
87
typedef void (pdf_page_contents_process_fn)(fz_context *ctx, fz_buffer *buffer, pdf_obj *res, void *arg);
88
89
/*
90
pdf_clean_page_contents: Clean a loaded pages rendering operations,
91
with an optional post processing step.
92
93
Firstly, this filters the PDF operators used to avoid (some cases
94
of) repetition, and leaves the page in a balanced state with an
95
unchanged top level matrix etc. At the same time, the resources
96
used by the page contents are collected.
97
98
Next, the resources themselves are cleaned (as appropriate) in the
99
same way.
100
101
Next, an optional post processing stage is called.
102
103
Finally, the page contents and resources in the documents page tree
104
are replaced by these processed versions.
105
106
Annotations remain unaffected.
107
108
page: A page loaded by pdf_load_page.
109
110
dev: Device used for rendering, obtained from fz_new_*_device.
111
112
cookie: A pointer to an optional fz_cookie structure that can be used
113
to track progress, collect errors etc.
114
*/
115
void pdf_clean_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_cookie *cookie,
116
pdf_page_contents_process_fn *proc, void *proc_arg);
117
118
/*
119
Presentation interface.
120
*/
121
fz_transition *pdf_page_presentation(fz_context *ctx, pdf_page *page, float *duration);
122
123
/*
124
* Page tree, pages and related objects
125
*/
126
127
struct pdf_page_s
128
{
129
fz_page super;
130
pdf_document *doc;
131
132
fz_matrix ctm; /* calculated from mediabox and rotate */
133
fz_rect mediabox;
134
int rotate;
135
int transparency;
136
pdf_obj *resources;
137
pdf_obj *contents;
138
fz_link *links;
139
pdf_annot *annots;
140
pdf_annot **annot_tailp;
141
pdf_annot *changed_annots;
142
pdf_annot *deleted_annots;
143
pdf_annot *tmp_annots;
144
pdf_obj *me;
145
float duration;
146
int transition_present;
147
fz_transition transition;
148
int incomplete;
149
};
150
151
enum
152
{
153
PDF_PAGE_INCOMPLETE_CONTENTS = 1,
154
PDF_PAGE_INCOMPLETE_ANNOTS = 2
155
};
156
157
#endif
158
159