mupdf
Loading...
Searching...
No Matches
page.h
Go to the documentation of this file.
1// Copyright (C) 2004-2024 Artifex Software, Inc.
2//
3// This file is part of MuPDF.
4//
5// MuPDF is free software: you can redistribute it and/or modify it under the
6// terms of the GNU Affero General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Affero General Public License
16// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17//
18// Alternative licensing terms are available from the licensor.
19// For commercial licensing, see <https://www.artifex.com/> or contact
20// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21// CA 94129, USA, for further information.
22
23#ifndef MUPDF_PDF_PAGE_H
24#define MUPDF_PDF_PAGE_H
25
26#include "mupdf/pdf/interpret.h"
27
30
33int pdf_count_pages_imp(fz_context *ctx, fz_document *doc, int chapter);
35pdf_obj *pdf_lookup_page_loc(fz_context *ctx, pdf_document *doc, int needle, pdf_obj **parentp, int *indexp);
36
37/*
38 Enable or disable the page tree cache that is used to speed up page object lookups.
39 The page tree cache is used unless explicitly disabled with this function.
40*/
41void pdf_set_page_tree_cache(fz_context *ctx, pdf_document *doc, int enabled);
42
43/*
44 Cache the page tree for fast forward/reverse page lookups.
45
46 No longer required. This is a No Op, now as page tree
47 maps are loaded automatically 'just in time'.
48*/
50
51/*
52 Discard the page tree maps.
53
54 No longer required. This is a No Op, now as page tree
55 maps are discarded automatically 'just in time'.
56*/
58
59/*
60 Internal function used to drop the page tree.
61
62 Library users should not call this directly.
63*/
65
66/*
67 Make page self sufficient.
68
69 Copy any inheritable page keys into the actual page object, removing
70 any dependencies on the page tree parents.
71*/
73
74/*
75 Load a page and its resources.
76
77 Locates the page in the PDF document and loads the page and its
78 resources. After pdf_load_page is it possible to retrieve the size
79 of the page using pdf_bound_page, or to render the page using
80 pdf_run_page_*.
81
82 number: page number, where 0 is the first page of the document.
83*/
85
86/*
87 Internal function to perform pdf_load_page.
88
89 Do not call this directly.
90*/
91fz_page *pdf_load_page_imp(fz_context *ctx, fz_document *doc, int chapter, int number);
92
93/*
94 Enquire as to whether a given page uses transparency or not.
95*/
97
98/*
99 Fetch the given box for a page, together with a transform that converts
100 from fitz coords to PDF coords.
101
102 pageobj: The object that represents the page.
103
104 outbox: If non-NULL, this will be filled in with the requested box
105 in fitz coordinates.
106
107 outctm: A transform to map from fitz page space to PDF page space.
108
109 box: Which box to return.
110*/
112
113/*
114 As for pdf_page_obj_transform_box, always requesting the
115 cropbox.
116*/
117void pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *outbox, fz_matrix *outctm);
118
119/*
120 As for pdf_page_obj_transform_box, but working from a pdf_page
121 object rather than the pdf_obj representing the page.
122*/
124
125/*
126 As for pdf_page_transform_box, always requesting the
127 cropbox.
128*/
129void pdf_page_transform(fz_context *ctx, pdf_page *page, fz_rect *mediabox, fz_matrix *ctm);
130
131/*
132 Find the pdf object that represents the resources dictionary
133 for a page.
134
135 This is a borrowed pointer that the caller should pdf_keep_obj
136 if. This may be NULL.
137*/
139
140/*
141 Find the pdf object that represents the page contents
142 for a page.
143
144 This is a borrowed pointer that the caller should pdf_keep_obj
145 if. This may be NULL.
146*/
148
149/*
150 Find the pdf object that represents the transparency group
151 for a page.
152
153 This is a borrowed pointer that the caller should pdf_keep_obj
154 if. This may be NULL.
155*/
157
158/*
159 Modify the page boxes (using fitz space coordinates).
160
161 Note that changing the CropBox will change the fitz coordinate space mapping,
162 invalidating all bounding boxes previously acquired.
163*/
165
166/*
167 Get the separation details for a page.
168*/
170
173int pdf_is_ocg_hidden(fz_context *ctx, pdf_document *doc, pdf_resource_stack *rdb, const char *usage, pdf_obj *ocg);
174
176
177/*
178 Determine the size of a page.
179
180 Determine the page size in points, taking page rotation
181 into account. The page size is taken to be the crop box if it
182 exists (visible area after cropping), otherwise the media box will
183 be used (possibly including printing marks).
184*/
186
187/*
188 Interpret a loaded page and render it on a device.
189
190 page: A page loaded by pdf_load_page.
191
192 dev: Device used for rendering, obtained from fz_new_*_device.
193
194 ctm: A transformation matrix applied to the objects on the page,
195 e.g. to scale or rotate the page contents as desired.
196*/
197void pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie);
198
199/*
200 Interpret a loaded page and render it on a device.
201
202 page: A page loaded by pdf_load_page.
203
204 dev: Device used for rendering, obtained from fz_new_*_device.
205
206 ctm: A transformation matrix applied to the objects on the page,
207 e.g. to scale or rotate the page contents as desired.
208
209 usage: The 'usage' for displaying the file (typically
210 'View', 'Print' or 'Export'). NULL means 'View'.
211
212 cookie: A pointer to an optional fz_cookie structure that can be used
213 to track progress, collect errors etc.
214*/
215void pdf_run_page_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
216
217/*
218 Interpret a loaded page and render it on a device.
219 Just the main page contents without the annotations
220
221 page: A page loaded by pdf_load_page.
222
223 dev: Device used for rendering, obtained from fz_new_*_device.
224
225 ctm: A transformation matrix applied to the objects on the page,
226 e.g. to scale or rotate the page contents as desired.
227*/
231void pdf_run_page_contents_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
232void pdf_run_page_annots_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
233void pdf_run_page_widgets_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
234
237
239fz_pixmap *pdf_new_pixmap_from_page_with_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, int alpha, const char *usage, fz_box_type box);
242
243enum {
244 /* Do not change images at all */
246
247 /* If the image intrudes across the redaction region (even if clipped),
248 * remove it. */
250
251 /* If the image intrudes across the redaction region (even if clipped),
252 * replace the bit that intrudes with black pixels. */
254
255 /* If the image, when clipped, intrudes across the redaction
256 * region, remove it completely. Note: clipped is a rough estimate
257 * based on the bbox of clipping paths.
258 *
259 * Essentially this says "remove any image that has visible parts
260 * that extend into the redaction region".
261 *
262 * This method can effectively 'leak' invisible information during
263 * the redaction phase, so should be used with caution.
264 */
266};
267
268enum {
272};
273
274enum {
275 /* Remove any text that overlaps with the redaction region,
276 * however slightly. This is the default option, and is the
277 * correct option for secure behaviour. */
279 /* Do not remove any text at all as part of this redaction
280 * operation. Using this option is INSECURE! Use at your own
281 * risk. */
283 /* Remove any invisible text that overlaps with the redaction
284 * region however slightly. This is intended to allow the
285 * removal of invisible text layers added by OCR passes.
286 * This will remove text that is made invisible by rendering
287 * mode, but will NOT remove other cases (like white-on-white
288 * text, etc). */
290};
291
292typedef struct
293{
297 int text;
299
301
302fz_transition *pdf_page_presentation(fz_context *ctx, pdf_page *page, fz_transition *transition, float *duration);
303
305
306void pdf_clip_page(fz_context *ctx, pdf_page *page, fz_rect *clip);
307
309
310/*
311 Update default colorspaces for an xobject.
312*/
314
315/*
316 * Page tree, pages and related objects
317 */
318
332
333/* Keep pdf_page, pdf_annot, and pdf_link structs in sync with underlying pdf objects. */
341
342#endif
struct pdf_annot pdf_annot
Definition annot.h:32
fz_box_type
Definition document.h:42
struct pdf_obj pdf_obj
Definition object.h:44
void pdf_run_page_widgets(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie)
pdf_obj * pdf_lookup_page_loc(fz_context *ctx, pdf_document *doc, int needle, pdf_obj **parentp, int *indexp)
void pdf_run_page_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie)
fz_transition * pdf_page_presentation(fz_context *ctx, pdf_page *page, fz_transition *transition, float *duration)
int pdf_count_pages(fz_context *ctx, pdf_document *doc)
pdf_obj * pdf_page_group(fz_context *ctx, pdf_page *page)
void pdf_run_page_widgets_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie)
void pdf_nuke_page(fz_context *ctx, pdf_page *page)
@ PDF_REDACT_TEXT_REMOVE_INVISIBLE
Definition page.h:289
@ PDF_REDACT_TEXT_REMOVE
Definition page.h:278
@ PDF_REDACT_TEXT_NONE
Definition page.h:282
void pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie)
void pdf_nuke_annots(fz_context *ctx, pdf_page *page)
void pdf_drop_page(fz_context *ctx, pdf_page *page)
fz_pixmap * pdf_new_pixmap_from_page_with_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, int alpha, const char *usage, fz_box_type box)
void pdf_flatten_inheritable_page_items(fz_context *ctx, pdf_obj *page)
void pdf_set_page_tree_cache(fz_context *ctx, pdf_document *doc, int enabled)
int pdf_redact_page(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_redact_options *opts)
fz_default_colorspaces * pdf_update_default_colorspaces(fz_context *ctx, fz_default_colorspaces *old_cs, pdf_obj *res)
fz_pixmap * pdf_new_pixmap_from_page_contents_with_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, int alpha, const char *usage, fz_box_type box)
void pdf_drop_page_tree_internal(fz_context *ctx, pdf_document *doc)
int pdf_count_pages_imp(fz_context *ctx, fz_document *doc, int chapter)
void pdf_clip_page(fz_context *ctx, pdf_page *page, fz_rect *clip)
pdf_page * pdf_load_page(fz_context *ctx, pdf_document *doc, int number)
void pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *outbox, fz_matrix *outctm)
int pdf_is_ocg_hidden(fz_context *ctx, pdf_document *doc, pdf_resource_stack *rdb, const char *usage, pdf_obj *ocg)
void pdf_filter_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot, pdf_filter_options *options)
fz_page * pdf_load_page_imp(fz_context *ctx, fz_document *doc, int chapter, int number)
int pdf_lookup_page_number(fz_context *ctx, pdf_document *doc, pdf_obj *pageobj)
void pdf_nuke_links(fz_context *ctx, pdf_page *page)
pdf_obj * pdf_lookup_page_obj(fz_context *ctx, pdf_document *doc, int needle)
void pdf_page_transform_box(fz_context *ctx, pdf_page *page, fz_rect *mediabox, fz_matrix *ctm, fz_box_type box)
fz_link * pdf_load_links(fz_context *ctx, pdf_page *page)
fz_separations * pdf_page_separations(fz_context *ctx, pdf_page *page)
void pdf_page_transform(fz_context *ctx, pdf_page *page, fz_rect *mediabox, fz_matrix *ctm)
void pdf_page_obj_transform_box(fz_context *ctx, pdf_obj *pageobj, fz_rect *outbox, fz_matrix *out, fz_box_type box)
void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_filter_options *options)
void pdf_run_page_annots_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie)
void pdf_run_page_contents_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie)
fz_pixmap * pdf_new_pixmap_from_page_contents_with_separations_and_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha, const char *usage, fz_box_type box)
void pdf_sync_open_pages(fz_context *ctx, pdf_document *doc)
@ PDF_REDACT_IMAGE_NONE
Definition page.h:245
@ PDF_REDACT_IMAGE_PIXELS
Definition page.h:253
@ PDF_REDACT_IMAGE_REMOVE_UNLESS_INVISIBLE
Definition page.h:265
@ PDF_REDACT_IMAGE_REMOVE
Definition page.h:249
@ PDF_REDACT_LINE_ART_REMOVE_IF_TOUCHED
Definition page.h:271
@ PDF_REDACT_LINE_ART_REMOVE_IF_COVERED
Definition page.h:270
@ PDF_REDACT_LINE_ART_NONE
Definition page.h:269
void pdf_sync_page(fz_context *ctx, pdf_page *page)
void pdf_sync_links(fz_context *ctx, pdf_page *page)
void pdf_set_page_box(fz_context *ctx, pdf_page *page, fz_box_type box, fz_rect rect)
void pdf_load_page_tree(fz_context *ctx, pdf_document *doc)
pdf_ocg_descriptor * pdf_read_ocg(fz_context *ctx, pdf_document *doc)
fz_pixmap * pdf_new_pixmap_from_page_with_separations_and_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha, const char *usage, fz_box_type box)
void pdf_sync_annots(fz_context *ctx, pdf_page *page)
void pdf_drop_page_tree(fz_context *ctx, pdf_document *doc)
void pdf_run_page_contents(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie)
fz_default_colorspaces * pdf_load_default_colorspaces(fz_context *ctx, pdf_document *doc, pdf_page *page)
fz_rect pdf_bound_page(fz_context *ctx, pdf_page *page, fz_box_type box)
void pdf_run_page_annots(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie)
int pdf_page_has_transparency(fz_context *ctx, pdf_page *page)
pdf_page * pdf_keep_page(fz_context *ctx, pdf_page *page)
pdf_obj * pdf_page_contents(fz_context *ctx, pdf_page *page)
void pdf_drop_ocg(fz_context *ctx, pdf_document *doc)
pdf_obj * pdf_page_resources(fz_context *ctx, pdf_page *page)
void pdf_vectorize_page(fz_context *ctx, pdf_page *page)
struct pdf_ocg_descriptor pdf_ocg_descriptor
Definition document.h:34
struct fz_separations fz_separations
Definition separation.h:43
Definition color.h:417
Definition context.h:886
Definition color.h:339
Definition device.h:290
Definition document.h:1080
Definition geometry.h:388
Definition document.h:1044
Definition pixmap.h:432
Definition geometry.h:231
Definition transition.h:46
Definition document.h:463
Definition interpret.h:337
Definition page.h:320
pdf_obj * obj
Definition page.h:323
int transparency
Definition page.h:325
pdf_annot ** widget_tailp
Definition page.h:330
pdf_annot * annots
Definition page.h:329
pdf_annot ** annot_tailp
Definition page.h:329
fz_link * links
Definition page.h:328
pdf_document * doc
Definition page.h:322
int overprint
Definition page.h:326
fz_page super
Definition page.h:321
pdf_annot * widgets
Definition page.h:330
Definition page.h:293
int black_boxes
Definition page.h:294
int image_method
Definition page.h:295
int text
Definition page.h:297
int line_art
Definition page.h:296
Definition interpret.h:44