comparison mupdf-source/include/mupdf/fitz/util.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
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_FITZ_UTIL_H
24 #define MUPDF_FITZ_UTIL_H
25
26 #include "mupdf/fitz/system.h"
27 #include "mupdf/fitz/context.h"
28 #include "mupdf/fitz/geometry.h"
29 #include "mupdf/fitz/document.h"
30 #include "mupdf/fitz/pixmap.h"
31 #include "mupdf/fitz/structured-text.h"
32 #include "mupdf/fitz/buffer.h"
33 #include "mupdf/fitz/xml.h"
34 #include "mupdf/fitz/archive.h"
35 #include "mupdf/fitz/display-list.h"
36
37 /**
38 Create a display list.
39
40 Ownership of the display list is returned to the caller.
41 */
42 fz_display_list *fz_new_display_list_from_page(fz_context *ctx, fz_page *page);
43 fz_display_list *fz_new_display_list_from_page_number(fz_context *ctx, fz_document *doc, int number);
44
45 /**
46 Create a display list from page contents (no annotations).
47
48 Ownership of the display list is returned to the caller.
49 */
50 fz_display_list *fz_new_display_list_from_page_contents(fz_context *ctx, fz_page *page);
51
52 /**
53 Render the page to a pixmap using the transform and colorspace.
54
55 Ownership of the pixmap is returned to the caller.
56 */
57 fz_pixmap *fz_new_pixmap_from_display_list(fz_context *ctx, fz_display_list *list, fz_matrix ctm, fz_colorspace *cs, int alpha);
58 fz_pixmap *fz_new_pixmap_from_page(fz_context *ctx, fz_page *page, fz_matrix ctm, fz_colorspace *cs, int alpha);
59 fz_pixmap *fz_new_pixmap_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_matrix ctm, fz_colorspace *cs, int alpha);
60
61 /**
62 Render the page contents without annotations.
63
64 Ownership of the pixmap is returned to the caller.
65 */
66 fz_pixmap *fz_new_pixmap_from_page_contents(fz_context *ctx, fz_page *page, fz_matrix ctm, fz_colorspace *cs, int alpha);
67
68 /**
69 Render the page contents with control over spot colors.
70
71 Ownership of the pixmap is returned to the caller.
72 */
73 fz_pixmap *fz_new_pixmap_from_display_list_with_separations(fz_context *ctx, fz_display_list *list, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha);
74 fz_pixmap *fz_new_pixmap_from_page_with_separations(fz_context *ctx, fz_page *page, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha);
75 fz_pixmap *fz_new_pixmap_from_page_number_with_separations(fz_context *ctx, fz_document *doc, int number, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha);
76 fz_pixmap *fz_new_pixmap_from_page_contents_with_separations(fz_context *ctx, fz_page *page, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha);
77
78 fz_pixmap *fz_fill_pixmap_from_display_list(fz_context *ctx, fz_display_list *list, fz_matrix ctm, fz_pixmap *pix);
79
80 /**
81 Extract text from page.
82
83 Ownership of the fz_stext_page is returned to the caller.
84 */
85 fz_stext_page *fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, const fz_stext_options *options);
86 fz_stext_page *fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_stext_options *options);
87 fz_stext_page *fz_new_stext_page_from_chapter_page_number(fz_context *ctx, fz_document *doc, int chapter, int number, const fz_stext_options *options);
88 fz_stext_page *fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, const fz_stext_options *options);
89
90 /**
91 Convert structured text into plain text.
92 */
93 fz_buffer *fz_new_buffer_from_stext_page(fz_context *ctx, fz_stext_page *text);
94 fz_buffer *fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_stext_options *options);
95 fz_buffer *fz_new_buffer_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_stext_options *options);
96 fz_buffer *fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz_stext_options *options);
97
98 /**
99 Search for the 'needle' text on the page.
100 Record the hits in the hit_bbox array and return the number of
101 hits. Will stop looking once it has filled hit_max rectangles.
102 */
103 int fz_search_page(fz_context *ctx, fz_page *page, const char *needle, int *hit_mark, fz_quad *hit_bbox, int hit_max);
104 int fz_search_page_number(fz_context *ctx, fz_document *doc, int number, const char *needle, int *hit_mark, fz_quad *hit_bbox, int hit_max);
105 int fz_search_chapter_page_number(fz_context *ctx, fz_document *doc, int chapter, int page, const char *needle, int *hit_mark, fz_quad *hit_bbox, int hit_max);
106 int fz_search_display_list(fz_context *ctx, fz_display_list *list, const char *needle, int *hit_mark, fz_quad *hit_bbox, int hit_max);
107
108 /**
109 Search for the 'needle' text on the page.
110 */
111 int fz_search_page_cb(fz_context *ctx, fz_page *page, const char *needle, fz_search_callback_fn *cb, void *opaque);
112 int fz_search_page_number_cb(fz_context *ctx, fz_document *doc, int number, const char *needle, fz_search_callback_fn *cb, void *opaque);
113 int fz_search_chapter_page_number_cb(fz_context *ctx, fz_document *doc, int chapter, int page, const char *needle, fz_search_callback_fn *cb, void *opaque);
114 int fz_search_display_list_cb(fz_context *ctx, fz_display_list *list, const char *needle, fz_search_callback_fn *cb, void *opaque);
115
116 /**
117 Parse an SVG document into a display-list.
118 */
119 fz_display_list *fz_new_display_list_from_svg(fz_context *ctx, fz_buffer *buf, const char *base_uri, fz_archive *dir, float *w, float *h);
120
121 /**
122 Create a scalable image from an SVG document.
123 */
124 fz_image *fz_new_image_from_svg(fz_context *ctx, fz_buffer *buf, const char *base_uri, fz_archive *dir);
125
126 /**
127 Parse an SVG document into a display-list.
128 */
129 fz_display_list *fz_new_display_list_from_svg_xml(fz_context *ctx, fz_xml_doc *xmldoc, fz_xml *xml, const char *base_uri, fz_archive *dir, float *w, float *h);
130
131 /**
132 Create a scalable image from an SVG document.
133 */
134 fz_image *fz_new_image_from_svg_xml(fz_context *ctx, fz_xml_doc *xmldoc, fz_xml *xml, const char *base_uri, fz_archive *dir);
135
136 /**
137 Write image as a data URI (for HTML and SVG output).
138 */
139 void fz_write_image_as_data_uri(fz_context *ctx, fz_output *out, fz_image *image);
140 void fz_write_pixmap_as_data_uri(fz_context *ctx, fz_output *out, fz_pixmap *pixmap);
141 void fz_append_image_as_data_uri(fz_context *ctx, fz_buffer *out, fz_image *image);
142 void fz_append_pixmap_as_data_uri(fz_context *ctx, fz_buffer *out, fz_pixmap *pixmap);
143
144 /**
145 Use text extraction to convert the input document into XHTML,
146 then open the result as a new document that can be reflowed.
147 */
148 fz_document *fz_new_xhtml_document_from_document(fz_context *ctx, fz_document *old_doc, const fz_stext_options *opts);
149
150 /**
151 Returns an fz_buffer containing a page after conversion to specified format.
152
153 page: The page to convert.
154 format, options: Passed to fz_new_document_writer_with_output() internally.
155 transform, cookie: Passed to fz_run_page() internally.
156 */
157 fz_buffer *fz_new_buffer_from_page_with_format(fz_context *ctx, fz_page *page, const char *format, const char *options, fz_matrix transform, fz_cookie *cookie);
158
159 #endif