]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - QRScanner/mobile/jni/include/mupdf/fitz/document.h
Add MuPDF native source codes
[hornmich/skoda-qr-demo.git] / QRScanner / mobile / jni / include / mupdf / fitz / document.h
1 #ifndef MUPDF_FITZ_DOCUMENT_H
2 #define MUPDF_FITZ_DOCUMENT_H
3
4 #include "mupdf/fitz/system.h"
5 #include "mupdf/fitz/context.h"
6 #include "mupdf/fitz/math.h"
7 #include "mupdf/fitz/device.h"
8 #include "mupdf/fitz/transition.h"
9 #include "mupdf/fitz/link.h"
10 #include "mupdf/fitz/outline.h"
11
12 /*
13         Document interface
14 */
15 typedef struct fz_document_s fz_document;
16 typedef struct fz_document_handler_s fz_document_handler;
17 typedef struct fz_page_s fz_page;
18 typedef struct fz_annot_s fz_annot;
19
20 // TODO: move out of this interface (it's pdf specific)
21 typedef struct fz_write_options_s fz_write_options;
22
23 typedef void (fz_document_close_fn)(fz_document *doc);
24 typedef int (fz_document_needs_password_fn)(fz_document *doc);
25 typedef int (fz_document_authenticate_password_fn)(fz_document *doc, const char *password);
26 typedef fz_outline *(fz_document_load_outline_fn)(fz_document *doc);
27 typedef void (fz_document_layout_fn)(fz_document *doc, float w, float h, float em);
28 typedef int (fz_document_count_pages_fn)(fz_document *doc);
29 typedef fz_page *(fz_document_load_page_fn)(fz_document *doc, int number);
30 typedef fz_link *(fz_document_load_links_fn)(fz_document *doc, fz_page *page);
31 typedef fz_rect *(fz_document_bound_page_fn)(fz_document *doc, fz_page *page, fz_rect *);
32 typedef void (fz_document_run_page_contents_fn)(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
33 typedef void (fz_document_run_annot_fn)(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
34 typedef void (fz_document_free_page_fn)(fz_document *doc, fz_page *page);
35 typedef int (fz_document_meta_fn)(fz_document *doc, int key, void *ptr, int size);
36 typedef fz_transition *(fz_document_page_presentation_fn)(fz_document *doc, fz_page *page, float *duration);
37 typedef fz_annot *(fz_document_first_annot_fn)(fz_document *doc, fz_page *page);
38 typedef fz_annot *(fz_document_next_annot_fn)(fz_document *doc, fz_annot *annot);
39 typedef fz_rect *(fz_document_bound_annot_fn)(fz_document *doc, fz_annot *annot, fz_rect *rect);
40 typedef void (fz_document_write_fn)(fz_document *doc, char *filename, fz_write_options *opts);
41 typedef void (fz_document_rebind_fn)(fz_document *doc, fz_context *ctx);
42
43 struct fz_document_s
44 {
45         fz_document_close_fn *close;
46         fz_document_needs_password_fn *needs_password;
47         fz_document_authenticate_password_fn *authenticate_password;
48         fz_document_load_outline_fn *load_outline;
49         fz_document_layout_fn *layout;
50         fz_document_count_pages_fn *count_pages;
51         fz_document_load_page_fn *load_page;
52         fz_document_load_links_fn *load_links;
53         fz_document_bound_page_fn *bound_page;
54         fz_document_run_page_contents_fn *run_page_contents;
55         fz_document_run_annot_fn *run_annot;
56         fz_document_free_page_fn *free_page;
57         fz_document_meta_fn *meta;
58         fz_document_page_presentation_fn *page_presentation;
59         fz_document_first_annot_fn *first_annot;
60         fz_document_next_annot_fn *next_annot;
61         fz_document_bound_annot_fn *bound_annot;
62         fz_document_write_fn *write;
63         fz_document_rebind_fn *rebind;
64 };
65
66 typedef fz_document *(fz_document_open_fn)(fz_context *ctx, const char *filename);
67 typedef fz_document *(fz_document_open_with_stream_fn)(fz_context *ctx, fz_stream *stream);
68 typedef int (fz_document_recognize_fn)(fz_context *ctx, const char *magic);
69
70 struct fz_document_handler_s
71 {
72         fz_document_recognize_fn *recognize;
73         fz_document_open_fn *open;
74         fz_document_open_with_stream_fn *open_with_stream;
75 };
76
77 extern fz_document_handler pdf_document_handler;
78 extern fz_document_handler pdf_no_run_document_handler;
79 extern fz_document_handler xps_document_handler;
80 extern fz_document_handler cbz_document_handler;
81 extern fz_document_handler img_document_handler;
82 extern fz_document_handler tiff_document_handler;
83
84 void fz_register_document_handler(fz_context *ctx, const fz_document_handler *handler);
85
86 void fz_register_document_handlers(fz_context *ctx);
87 void fz_register_no_run_document_handlers(fz_context *ctx);
88
89 /*
90         fz_open_document: Open a PDF, XPS or CBZ document.
91
92         Open a document file and read its basic structure so pages and
93         objects can be located. MuPDF will try to repair broken
94         documents (without actually changing the file contents).
95
96         The returned fz_document is used when calling most other
97         document related functions. Note that it wraps the context, so
98         those functions implicitly can access the global state in
99         context.
100
101         filename: a path to a file as it would be given to open(2).
102 */
103 fz_document *fz_open_document(fz_context *ctx, const char *filename);
104
105 /*
106         fz_open_document_with_stream: Open a PDF, XPS or CBZ document.
107
108         Open a document using the specified stream object rather than
109         opening a file on disk.
110
111         magic: a string used to detect document type; either a file name or mime-type.
112 */
113 fz_document *fz_open_document_with_stream(fz_context *ctx, const char *magic, fz_stream *stream);
114
115 /*
116         fz_close_document: Close and free an open document.
117
118         The resource store in the context associated with fz_document
119         is emptied, and any allocations for the document are freed.
120
121         Does not throw exceptions.
122 */
123 void fz_close_document(fz_document *doc);
124
125 /*
126         fz_needs_password: Check if a document is encrypted with a
127         non-blank password.
128
129         Does not throw exceptions.
130 */
131 int fz_needs_password(fz_document *doc);
132
133 /*
134         fz_authenticate_password: Test if the given password can
135         decrypt the document.
136
137         password: The password string to be checked. Some document
138         specifications do not specify any particular text encoding, so
139         neither do we.
140
141         Does not throw exceptions.
142 */
143 int fz_authenticate_password(fz_document *doc, const char *password);
144
145 /*
146         fz_load_outline: Load the hierarchical document outline.
147
148         Should be freed by fz_free_outline.
149 */
150 fz_outline *fz_load_outline(fz_document *doc);
151
152 /*
153         fz_layout_document: Layout reflowable document types.
154
155         w, h: Page size in points.
156         em: Default font size in points.
157 */
158 void fz_layout_document(fz_document *doc, float w, float h, float em);
159
160 /*
161         fz_count_pages: Return the number of pages in document
162
163         May return 0 for documents with no pages.
164 */
165 int fz_count_pages(fz_document *doc);
166
167 /*
168         fz_load_page: Load a page.
169
170         After fz_load_page is it possible to retrieve the size of the
171         page using fz_bound_page, or to render the page using
172         fz_run_page_*. Free the page by calling fz_free_page.
173
174         number: page number, 0 is the first page of the document.
175 */
176 fz_page *fz_load_page(fz_document *doc, int number);
177
178 /*
179         fz_load_links: Load the list of links for a page.
180
181         Returns a linked list of all the links on the page, each with
182         its clickable region and link destination. Each link is
183         reference counted so drop and free the list of links by
184         calling fz_drop_link on the pointer return from fz_load_links.
185
186         page: Page obtained from fz_load_page.
187 */
188 fz_link *fz_load_links(fz_document *doc, fz_page *page);
189
190 /*
191         fz_bound_page: Determine the size of a page at 72 dpi.
192
193         Does not throw exceptions.
194 */
195 fz_rect *fz_bound_page(fz_document *doc, fz_page *page, fz_rect *rect);
196
197 /*
198         fz_run_page: Run a page through a device.
199
200         page: Page obtained from fz_load_page.
201
202         dev: Device obtained from fz_new_*_device.
203
204         transform: Transform to apply to page. May include for example
205         scaling and rotation, see fz_scale, fz_rotate and fz_concat.
206         Set to fz_identity if no transformation is desired.
207
208         cookie: Communication mechanism between caller and library
209         rendering the page. Intended for multi-threaded applications,
210         while single-threaded applications set cookie to NULL. The
211         caller may abort an ongoing rendering of a page. Cookie also
212         communicates progress information back to the caller. The
213         fields inside cookie are continually updated while the page is
214         rendering.
215 */
216 void fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
217
218 /*
219         fz_run_page_contents: Run a page through a device. Just the main
220         page content, without the annotations, if any.
221
222         page: Page obtained from fz_load_page.
223
224         dev: Device obtained from fz_new_*_device.
225
226         transform: Transform to apply to page. May include for example
227         scaling and rotation, see fz_scale, fz_rotate and fz_concat.
228         Set to fz_identity if no transformation is desired.
229
230         cookie: Communication mechanism between caller and library
231         rendering the page. Intended for multi-threaded applications,
232         while single-threaded applications set cookie to NULL. The
233         caller may abort an ongoing rendering of a page. Cookie also
234         communicates progress information back to the caller. The
235         fields inside cookie are continually updated while the page is
236         rendering.
237 */
238 void fz_run_page_contents(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
239
240 /*
241         fz_run_annot: Run an annotation through a device.
242
243         page: Page obtained from fz_load_page.
244
245         annot: an annotation.
246
247         dev: Device obtained from fz_new_*_device.
248
249         transform: Transform to apply to page. May include for example
250         scaling and rotation, see fz_scale, fz_rotate and fz_concat.
251         Set to fz_identity if no transformation is desired.
252
253         cookie: Communication mechanism between caller and library
254         rendering the page. Intended for multi-threaded applications,
255         while single-threaded applications set cookie to NULL. The
256         caller may abort an ongoing rendering of a page. Cookie also
257         communicates progress information back to the caller. The
258         fields inside cookie are continually updated while the page is
259         rendering.
260 */
261 void fz_run_annot(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
262
263 /*
264         fz_free_page: Free a loaded page.
265
266         Does not throw exceptions.
267 */
268 void fz_free_page(fz_document *doc, fz_page *page);
269
270 /*
271         fz_page_presentation: Get the presentation details for a given page.
272
273         duration: NULL, or a pointer to a place to set the page duration in
274         seconds. (Will be set to 0 if unspecified).
275
276         Returns: a pointer to a transition structure, or NULL if there isn't
277         one.
278
279         Does not throw exceptions.
280 */
281 fz_transition *fz_page_presentation(fz_document *doc, fz_page *page, float *duration);
282
283 void fz_rebind_document(fz_document *doc, fz_context *ctx);
284
285 #endif