PyMuPDF 1.24.11__cp38-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. PyMuPDF-1.24.11.dist-info/COPYING +1 -0
  2. PyMuPDF-1.24.11.dist-info/METADATA +83 -0
  3. PyMuPDF-1.24.11.dist-info/README.md +60 -0
  4. PyMuPDF-1.24.11.dist-info/RECORD +99 -0
  5. PyMuPDF-1.24.11.dist-info/WHEEL +4 -0
  6. PyMuPDF-1.24.11.dist-info/entry_points.txt +3 -0
  7. fitz/__init__.py +11 -0
  8. fitz/table.py +2 -0
  9. fitz/utils.py +2 -0
  10. pymupdf/__init__.py +22122 -0
  11. pymupdf/__main__.py +1146 -0
  12. pymupdf/_apply_pages.py +253 -0
  13. pymupdf/_build.py +1 -0
  14. pymupdf/_extra.pyd +0 -0
  15. pymupdf/_mupdf.pyd +0 -0
  16. pymupdf/extra.py +214 -0
  17. pymupdf/mupdf-devel/include/mupdf/fitz/archive.h +444 -0
  18. pymupdf/mupdf-devel/include/mupdf/fitz/band-writer.h +117 -0
  19. pymupdf/mupdf-devel/include/mupdf/fitz/bidi.h +90 -0
  20. pymupdf/mupdf-devel/include/mupdf/fitz/bitmap.h +175 -0
  21. pymupdf/mupdf-devel/include/mupdf/fitz/buffer.h +250 -0
  22. pymupdf/mupdf-devel/include/mupdf/fitz/color.h +427 -0
  23. pymupdf/mupdf-devel/include/mupdf/fitz/compress.h +88 -0
  24. pymupdf/mupdf-devel/include/mupdf/fitz/compressed-buffer.h +185 -0
  25. pymupdf/mupdf-devel/include/mupdf/fitz/config.h +223 -0
  26. pymupdf/mupdf-devel/include/mupdf/fitz/context.h +1006 -0
  27. pymupdf/mupdf-devel/include/mupdf/fitz/crypt.h +270 -0
  28. pymupdf/mupdf-devel/include/mupdf/fitz/device.h +654 -0
  29. pymupdf/mupdf-devel/include/mupdf/fitz/display-list.h +142 -0
  30. pymupdf/mupdf-devel/include/mupdf/fitz/document.h +1108 -0
  31. pymupdf/mupdf-devel/include/mupdf/fitz/export.h +52 -0
  32. pymupdf/mupdf-devel/include/mupdf/fitz/filter.h +263 -0
  33. pymupdf/mupdf-devel/include/mupdf/fitz/font.h +815 -0
  34. pymupdf/mupdf-devel/include/mupdf/fitz/geometry.h +818 -0
  35. pymupdf/mupdf-devel/include/mupdf/fitz/getopt.h +128 -0
  36. pymupdf/mupdf-devel/include/mupdf/fitz/glyph-cache.h +96 -0
  37. pymupdf/mupdf-devel/include/mupdf/fitz/glyph.h +81 -0
  38. pymupdf/mupdf-devel/include/mupdf/fitz/hash.h +126 -0
  39. pymupdf/mupdf-devel/include/mupdf/fitz/heap-imp.h +163 -0
  40. pymupdf/mupdf-devel/include/mupdf/fitz/heap.h +140 -0
  41. pymupdf/mupdf-devel/include/mupdf/fitz/image.h +443 -0
  42. pymupdf/mupdf-devel/include/mupdf/fitz/link.h +130 -0
  43. pymupdf/mupdf-devel/include/mupdf/fitz/log.h +61 -0
  44. pymupdf/mupdf-devel/include/mupdf/fitz/outline.h +228 -0
  45. pymupdf/mupdf-devel/include/mupdf/fitz/output-svg.h +64 -0
  46. pymupdf/mupdf-devel/include/mupdf/fitz/output.h +415 -0
  47. pymupdf/mupdf-devel/include/mupdf/fitz/path.h +447 -0
  48. pymupdf/mupdf-devel/include/mupdf/fitz/pixmap.h +501 -0
  49. pymupdf/mupdf-devel/include/mupdf/fitz/pool.h +68 -0
  50. pymupdf/mupdf-devel/include/mupdf/fitz/separation.h +138 -0
  51. pymupdf/mupdf-devel/include/mupdf/fitz/shade.h +233 -0
  52. pymupdf/mupdf-devel/include/mupdf/fitz/store.h +456 -0
  53. pymupdf/mupdf-devel/include/mupdf/fitz/story-writer.h +209 -0
  54. pymupdf/mupdf-devel/include/mupdf/fitz/story.h +232 -0
  55. pymupdf/mupdf-devel/include/mupdf/fitz/stream.h +646 -0
  56. pymupdf/mupdf-devel/include/mupdf/fitz/string-util.h +286 -0
  57. pymupdf/mupdf-devel/include/mupdf/fitz/structured-text.h +365 -0
  58. pymupdf/mupdf-devel/include/mupdf/fitz/system.h +459 -0
  59. pymupdf/mupdf-devel/include/mupdf/fitz/text.h +209 -0
  60. pymupdf/mupdf-devel/include/mupdf/fitz/track-usage.h +57 -0
  61. pymupdf/mupdf-devel/include/mupdf/fitz/transition.h +76 -0
  62. pymupdf/mupdf-devel/include/mupdf/fitz/tree.h +62 -0
  63. pymupdf/mupdf-devel/include/mupdf/fitz/types.h +41 -0
  64. pymupdf/mupdf-devel/include/mupdf/fitz/util.h +151 -0
  65. pymupdf/mupdf-devel/include/mupdf/fitz/version.h +31 -0
  66. pymupdf/mupdf-devel/include/mupdf/fitz/write-pixmap.h +499 -0
  67. pymupdf/mupdf-devel/include/mupdf/fitz/writer.h +266 -0
  68. pymupdf/mupdf-devel/include/mupdf/fitz/xml.h +397 -0
  69. pymupdf/mupdf-devel/include/mupdf/fitz.h +97 -0
  70. pymupdf/mupdf-devel/include/mupdf/helpers/mu-office-lib.h +666 -0
  71. pymupdf/mupdf-devel/include/mupdf/helpers/mu-threads.h +280 -0
  72. pymupdf/mupdf-devel/include/mupdf/helpers/pkcs7-openssl.h +48 -0
  73. pymupdf/mupdf-devel/include/mupdf/html.h +53 -0
  74. pymupdf/mupdf-devel/include/mupdf/memento.h +423 -0
  75. pymupdf/mupdf-devel/include/mupdf/pdf/annot.h +965 -0
  76. pymupdf/mupdf-devel/include/mupdf/pdf/clean.h +48 -0
  77. pymupdf/mupdf-devel/include/mupdf/pdf/cmap.h +145 -0
  78. pymupdf/mupdf-devel/include/mupdf/pdf/crypt.h +107 -0
  79. pymupdf/mupdf-devel/include/mupdf/pdf/document.h +842 -0
  80. pymupdf/mupdf-devel/include/mupdf/pdf/event.h +167 -0
  81. pymupdf/mupdf-devel/include/mupdf/pdf/font.h +168 -0
  82. pymupdf/mupdf-devel/include/mupdf/pdf/form.h +380 -0
  83. pymupdf/mupdf-devel/include/mupdf/pdf/image-rewriter.h +78 -0
  84. pymupdf/mupdf-devel/include/mupdf/pdf/interpret.h +492 -0
  85. pymupdf/mupdf-devel/include/mupdf/pdf/javascript.h +43 -0
  86. pymupdf/mupdf-devel/include/mupdf/pdf/name-table.h +596 -0
  87. pymupdf/mupdf-devel/include/mupdf/pdf/object.h +435 -0
  88. pymupdf/mupdf-devel/include/mupdf/pdf/page.h +316 -0
  89. pymupdf/mupdf-devel/include/mupdf/pdf/parse.h +61 -0
  90. pymupdf/mupdf-devel/include/mupdf/pdf/resource.h +133 -0
  91. pymupdf/mupdf-devel/include/mupdf/pdf/xref.h +300 -0
  92. pymupdf/mupdf-devel/include/mupdf/pdf.h +57 -0
  93. pymupdf/mupdf-devel/include/mupdf/ucdn.h +452 -0
  94. pymupdf/mupdf-devel/lib/mupdfcpp64.lib +0 -0
  95. pymupdf/mupdf.py +58506 -0
  96. pymupdf/mupdfcpp64.dll +0 -0
  97. pymupdf/pymupdf.py +2 -0
  98. pymupdf/table.py +2355 -0
  99. pymupdf/utils.py +5880 -0
@@ -0,0 +1,380 @@
1
+ // Copyright (C) 2004-2021 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_FORM_H
24
+ #define MUPDF_PDF_FORM_H
25
+
26
+ #include "mupdf/fitz/display-list.h"
27
+ #include "mupdf/pdf/document.h"
28
+
29
+ /* Types of widget */
30
+ enum pdf_widget_type
31
+ {
32
+ PDF_WIDGET_TYPE_UNKNOWN,
33
+ PDF_WIDGET_TYPE_BUTTON,
34
+ PDF_WIDGET_TYPE_CHECKBOX,
35
+ PDF_WIDGET_TYPE_COMBOBOX,
36
+ PDF_WIDGET_TYPE_LISTBOX,
37
+ PDF_WIDGET_TYPE_RADIOBUTTON,
38
+ PDF_WIDGET_TYPE_SIGNATURE,
39
+ PDF_WIDGET_TYPE_TEXT,
40
+ };
41
+
42
+ /* Types of text widget content */
43
+ enum pdf_widget_tx_format
44
+ {
45
+ PDF_WIDGET_TX_FORMAT_NONE,
46
+ PDF_WIDGET_TX_FORMAT_NUMBER,
47
+ PDF_WIDGET_TX_FORMAT_SPECIAL,
48
+ PDF_WIDGET_TX_FORMAT_DATE,
49
+ PDF_WIDGET_TX_FORMAT_TIME
50
+ };
51
+
52
+ pdf_annot *pdf_keep_widget(fz_context *ctx, pdf_annot *widget);
53
+ void pdf_drop_widget(fz_context *ctx, pdf_annot *widget);
54
+ pdf_annot *pdf_first_widget(fz_context *ctx, pdf_page *page);
55
+ pdf_annot *pdf_next_widget(fz_context *ctx, pdf_annot *previous);
56
+ int pdf_update_widget(fz_context *ctx, pdf_annot *widget);
57
+
58
+ /*
59
+ create a new signature widget on the specified page, with the
60
+ specified name.
61
+
62
+ The returns pdf_annot reference must be dropped by the caller.
63
+ This is a change from releases up to an including 1.18, where
64
+ the returned reference was owned by the page and did not need
65
+ to be freed by the caller.
66
+ */
67
+ pdf_annot *pdf_create_signature_widget(fz_context *ctx, pdf_page *page, char *name);
68
+
69
+ enum pdf_widget_type pdf_widget_type(fz_context *ctx, pdf_annot *widget);
70
+
71
+ fz_rect pdf_bound_widget(fz_context *ctx, pdf_annot *widget);
72
+
73
+ /*
74
+ get the maximum number of
75
+ characters permitted in a text widget
76
+ */
77
+ int pdf_text_widget_max_len(fz_context *ctx, pdf_annot *tw);
78
+
79
+ /*
80
+ get the type of content
81
+ required by a text widget
82
+ */
83
+ int pdf_text_widget_format(fz_context *ctx, pdf_annot *tw);
84
+
85
+ /*
86
+ get the list of options for a list box or combo box.
87
+
88
+ Returns the number of options and fills in their
89
+ names within the supplied array. Should first be called with a
90
+ NULL array to find out how big the array should be. If exportval
91
+ is true, then the export values will be returned and not the list
92
+ values if there are export values present.
93
+ */
94
+ int pdf_choice_widget_options(fz_context *ctx, pdf_annot *tw, int exportval, const char *opts[]);
95
+ int pdf_choice_widget_is_multiselect(fz_context *ctx, pdf_annot *tw);
96
+
97
+ /*
98
+ get the value of a choice widget.
99
+
100
+ Returns the number of options currently selected and fills in
101
+ the supplied array with their strings. Should first be called
102
+ with NULL as the array to find out how big the array need to
103
+ be. The filled in elements should not be freed by the caller.
104
+ */
105
+ int pdf_choice_widget_value(fz_context *ctx, pdf_annot *tw, const char *opts[]);
106
+
107
+ /*
108
+ set the value of a choice widget.
109
+
110
+ The caller should pass the number of options selected and an
111
+ array of their names
112
+ */
113
+ void pdf_choice_widget_set_value(fz_context *ctx, pdf_annot *tw, int n, const char *opts[]);
114
+
115
+ int pdf_choice_field_option_count(fz_context *ctx, pdf_obj *field);
116
+ const char *pdf_choice_field_option(fz_context *ctx, pdf_obj *field, int exportval, int i);
117
+
118
+ int pdf_widget_is_signed(fz_context *ctx, pdf_annot *widget);
119
+ int pdf_widget_is_readonly(fz_context *ctx, pdf_annot *widget);
120
+
121
+ /* Field flags */
122
+ enum
123
+ {
124
+ /* All fields */
125
+ PDF_FIELD_IS_READ_ONLY = 1,
126
+ PDF_FIELD_IS_REQUIRED = 1 << 1,
127
+ PDF_FIELD_IS_NO_EXPORT = 1 << 2,
128
+
129
+ /* Text fields */
130
+ PDF_TX_FIELD_IS_MULTILINE = 1 << 12,
131
+ PDF_TX_FIELD_IS_PASSWORD = 1 << 13,
132
+ PDF_TX_FIELD_IS_FILE_SELECT = 1 << 20,
133
+ PDF_TX_FIELD_IS_DO_NOT_SPELL_CHECK = 1 << 22,
134
+ PDF_TX_FIELD_IS_DO_NOT_SCROLL = 1 << 23,
135
+ PDF_TX_FIELD_IS_COMB = 1 << 24,
136
+ PDF_TX_FIELD_IS_RICH_TEXT = 1 << 25,
137
+
138
+ /* Button fields */
139
+ PDF_BTN_FIELD_IS_NO_TOGGLE_TO_OFF = 1 << 14,
140
+ PDF_BTN_FIELD_IS_RADIO = 1 << 15,
141
+ PDF_BTN_FIELD_IS_PUSHBUTTON = 1 << 16,
142
+ PDF_BTN_FIELD_IS_RADIOS_IN_UNISON = 1 << 25,
143
+
144
+ /* Choice fields */
145
+ PDF_CH_FIELD_IS_COMBO = 1 << 17,
146
+ PDF_CH_FIELD_IS_EDIT = 1 << 18,
147
+ PDF_CH_FIELD_IS_SORT = 1 << 19,
148
+ PDF_CH_FIELD_IS_MULTI_SELECT = 1 << 21,
149
+ PDF_CH_FIELD_IS_DO_NOT_SPELL_CHECK = 1 << 22,
150
+ PDF_CH_FIELD_IS_COMMIT_ON_SEL_CHANGE = 1 << 25,
151
+ };
152
+
153
+ void pdf_calculate_form(fz_context *ctx, pdf_document *doc);
154
+ void pdf_reset_form(fz_context *ctx, pdf_document *doc, pdf_obj *fields, int exclude);
155
+
156
+ int pdf_field_type(fz_context *ctx, pdf_obj *field);
157
+ const char *pdf_field_type_string(fz_context *ctx, pdf_obj *field);
158
+ int pdf_field_flags(fz_context *ctx, pdf_obj *field);
159
+
160
+ /*
161
+ Retrieve the name for a field as a C string that
162
+ must be freed by the caller.
163
+ */
164
+ char *pdf_load_field_name(fz_context *ctx, pdf_obj *field);
165
+ const char *pdf_field_value(fz_context *ctx, pdf_obj *field);
166
+ void pdf_create_field_name(fz_context *ctx, pdf_document *doc, const char *prefix, char *buf, size_t len);
167
+
168
+ char *pdf_field_border_style(fz_context *ctx, pdf_obj *field);
169
+ void pdf_field_set_border_style(fz_context *ctx, pdf_obj *field, const char *text);
170
+ void pdf_field_set_button_caption(fz_context *ctx, pdf_obj *field, const char *text);
171
+ void pdf_field_set_fill_color(fz_context *ctx, pdf_obj *field, pdf_obj *col);
172
+ void pdf_field_set_text_color(fz_context *ctx, pdf_obj *field, pdf_obj *col);
173
+ int pdf_field_display(fz_context *ctx, pdf_obj *field);
174
+ void pdf_field_set_display(fz_context *ctx, pdf_obj *field, int d);
175
+ const char *pdf_field_label(fz_context *ctx, pdf_obj *field);
176
+ pdf_obj *pdf_button_field_on_state(fz_context *ctx, pdf_obj *field);
177
+
178
+ int pdf_set_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, const char *text, int ignore_trigger_events);
179
+
180
+ /*
181
+ Update the text of a text widget.
182
+
183
+ The text is first validated by the Field/Keystroke event processing and accepted only if it passes.
184
+
185
+ The function returns whether validation passed.
186
+ */
187
+ int pdf_set_text_field_value(fz_context *ctx, pdf_annot *widget, const char *value);
188
+ int pdf_set_choice_field_value(fz_context *ctx, pdf_annot *widget, const char *value);
189
+ int pdf_edit_text_field_value(fz_context *ctx, pdf_annot *widget, const char *value, const char *change, int *selStart, int *selEnd, char **newvalue);
190
+
191
+ typedef struct
192
+ {
193
+ char *cn;
194
+ char *o;
195
+ char *ou;
196
+ char *email;
197
+ char *c;
198
+ }
199
+ pdf_pkcs7_distinguished_name;
200
+
201
+ typedef enum
202
+ {
203
+ PDF_SIGNATURE_ERROR_OKAY,
204
+ PDF_SIGNATURE_ERROR_NO_SIGNATURES,
205
+ PDF_SIGNATURE_ERROR_NO_CERTIFICATE,
206
+ PDF_SIGNATURE_ERROR_DIGEST_FAILURE,
207
+ PDF_SIGNATURE_ERROR_SELF_SIGNED,
208
+ PDF_SIGNATURE_ERROR_SELF_SIGNED_IN_CHAIN,
209
+ PDF_SIGNATURE_ERROR_NOT_TRUSTED,
210
+ PDF_SIGNATURE_ERROR_UNKNOWN
211
+ } pdf_signature_error;
212
+
213
+ /* Increment the reference count for a signer object */
214
+ typedef pdf_pkcs7_signer *(pdf_pkcs7_keep_signer_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
215
+
216
+ /* Drop a reference for a signer object */
217
+ typedef void (pdf_pkcs7_drop_signer_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
218
+
219
+ /* Obtain the distinguished name information from a signer object */
220
+ typedef pdf_pkcs7_distinguished_name *(pdf_pkcs7_get_signing_name_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
221
+
222
+ /* Predict the size of the digest. The actual digest returned by create_digest will be no greater in size */
223
+ typedef size_t (pdf_pkcs7_max_digest_size_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
224
+
225
+ /* Create a signature based on ranges of bytes drawn from a stream */
226
+ typedef int (pdf_pkcs7_create_digest_fn)(fz_context *ctx, pdf_pkcs7_signer *signer, fz_stream *in, unsigned char *digest, size_t digest_len);
227
+
228
+ struct pdf_pkcs7_signer
229
+ {
230
+ pdf_pkcs7_keep_signer_fn *keep;
231
+ pdf_pkcs7_drop_signer_fn *drop;
232
+ pdf_pkcs7_get_signing_name_fn *get_signing_name;
233
+ pdf_pkcs7_max_digest_size_fn *max_digest_size;
234
+ pdf_pkcs7_create_digest_fn *create_digest;
235
+ };
236
+
237
+ typedef struct pdf_pkcs7_verifier pdf_pkcs7_verifier;
238
+
239
+ typedef void (pdf_pkcs7_drop_verifier_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier);
240
+ typedef pdf_signature_error (pdf_pkcs7_check_certificate_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier, unsigned char *signature, size_t len);
241
+ typedef pdf_signature_error (pdf_pkcs7_check_digest_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier, fz_stream *in, unsigned char *signature, size_t len);
242
+ typedef pdf_pkcs7_distinguished_name *(pdf_pkcs7_get_signatory_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier, unsigned char *signature, size_t len);
243
+
244
+ struct pdf_pkcs7_verifier
245
+ {
246
+ pdf_pkcs7_drop_verifier_fn *drop;
247
+ pdf_pkcs7_check_certificate_fn *check_certificate;
248
+ pdf_pkcs7_check_digest_fn *check_digest;
249
+ pdf_pkcs7_get_signatory_fn *get_signatory;
250
+ };
251
+
252
+ int pdf_signature_is_signed(fz_context *ctx, pdf_document *doc, pdf_obj *field);
253
+ void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime);
254
+
255
+ int pdf_count_signatures(fz_context *ctx, pdf_document *doc);
256
+
257
+ char *pdf_signature_error_description(pdf_signature_error err);
258
+
259
+ pdf_pkcs7_distinguished_name *pdf_signature_get_signatory(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_document *doc, pdf_obj *signature);
260
+ pdf_pkcs7_distinguished_name *pdf_signature_get_widget_signatory(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_annot *widget);
261
+ void pdf_signature_drop_distinguished_name(fz_context *ctx, pdf_pkcs7_distinguished_name *name);
262
+ char *pdf_signature_format_distinguished_name(fz_context *ctx, pdf_pkcs7_distinguished_name *name);
263
+ char *pdf_signature_info(fz_context *ctx, const char *name, pdf_pkcs7_distinguished_name *dn, const char *reason, const char *location, int64_t date, int include_labels);
264
+ fz_display_list *pdf_signature_appearance_signed(fz_context *ctx, fz_rect rect, fz_text_language lang, fz_image *img, const char *left_text, const char *right_text, int include_logo);
265
+ fz_display_list *pdf_signature_appearance_unsigned(fz_context *ctx, fz_rect rect, fz_text_language lang);
266
+
267
+ pdf_signature_error pdf_check_digest(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_document *doc, pdf_obj *signature);
268
+ pdf_signature_error pdf_check_certificate(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_document *doc, pdf_obj *signature);
269
+ pdf_signature_error pdf_check_widget_digest(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_annot *widget);
270
+ pdf_signature_error pdf_check_widget_certificate(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_annot *widget);
271
+
272
+ void pdf_clear_signature(fz_context *ctx, pdf_annot *widget);
273
+
274
+ /*
275
+ Sign a signature field, while assigning it an arbitrary apparance determined by a display list.
276
+ The function pdf_signature_appearance can generate a variety of common signature appearances.
277
+ */
278
+ void pdf_sign_signature_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t date, fz_display_list *disp_list);
279
+
280
+ enum {
281
+ PDF_SIGNATURE_SHOW_LABELS = 1,
282
+ PDF_SIGNATURE_SHOW_DN = 2,
283
+ PDF_SIGNATURE_SHOW_DATE = 4,
284
+ PDF_SIGNATURE_SHOW_TEXT_NAME = 8,
285
+ PDF_SIGNATURE_SHOW_GRAPHIC_NAME = 16,
286
+ PDF_SIGNATURE_SHOW_LOGO = 32,
287
+ };
288
+
289
+ #define PDF_SIGNATURE_DEFAULT_APPEARANCE ( \
290
+ PDF_SIGNATURE_SHOW_LABELS | \
291
+ PDF_SIGNATURE_SHOW_DN | \
292
+ PDF_SIGNATURE_SHOW_DATE | \
293
+ PDF_SIGNATURE_SHOW_TEXT_NAME | \
294
+ PDF_SIGNATURE_SHOW_GRAPHIC_NAME | \
295
+ PDF_SIGNATURE_SHOW_LOGO )
296
+
297
+ /*
298
+ Sign a signature field, while assigning it a default appearance.
299
+ */
300
+ void pdf_sign_signature(fz_context *ctx, pdf_annot *widget,
301
+ pdf_pkcs7_signer *signer,
302
+ int appearance_flags,
303
+ fz_image *graphic,
304
+ const char *reason,
305
+ const char *location);
306
+
307
+ /*
308
+ Create a preview of the default signature appearance.
309
+ */
310
+ fz_display_list *pdf_preview_signature_as_display_list(fz_context *ctx,
311
+ float w, float h, fz_text_language lang,
312
+ pdf_pkcs7_signer *signer,
313
+ int appearance_flags,
314
+ fz_image *graphic,
315
+ const char *reason,
316
+ const char *location);
317
+
318
+ fz_pixmap *pdf_preview_signature_as_pixmap(fz_context *ctx,
319
+ int w, int h, fz_text_language lang,
320
+ pdf_pkcs7_signer *signer,
321
+ int appearance_flags,
322
+ fz_image *graphic,
323
+ const char *reason,
324
+ const char *location);
325
+
326
+ void pdf_drop_signer(fz_context *ctx, pdf_pkcs7_signer *signer);
327
+ void pdf_drop_verifier(fz_context *ctx, pdf_pkcs7_verifier *verifier);
328
+
329
+ void pdf_field_reset(fz_context *ctx, pdf_document *doc, pdf_obj *field);
330
+
331
+ pdf_obj *pdf_lookup_field(fz_context *ctx, pdf_obj *form, const char *name);
332
+
333
+ /* Form text field editing events: */
334
+
335
+ typedef struct
336
+ {
337
+ const char *value;
338
+ const char *change;
339
+ int selStart, selEnd;
340
+ int willCommit;
341
+ char *newChange;
342
+ char *newValue;
343
+ } pdf_keystroke_event;
344
+
345
+ int pdf_field_event_keystroke(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_keystroke_event *evt);
346
+ int pdf_field_event_validate(fz_context *ctx, pdf_document *doc, pdf_obj *field, const char *value, char **newvalue);
347
+ void pdf_field_event_calculate(fz_context *ctx, pdf_document *doc, pdf_obj *field);
348
+ char *pdf_field_event_format(fz_context *ctx, pdf_document *doc, pdf_obj *field);
349
+
350
+ int pdf_annot_field_event_keystroke(fz_context *ctx, pdf_document *doc, pdf_annot *annot, pdf_keystroke_event *evt);
351
+
352
+ /* Call these to trigger actions from various UI events: */
353
+
354
+ void pdf_document_event_will_close(fz_context *ctx, pdf_document *doc);
355
+ void pdf_document_event_will_save(fz_context *ctx, pdf_document *doc);
356
+ void pdf_document_event_did_save(fz_context *ctx, pdf_document *doc);
357
+ void pdf_document_event_will_print(fz_context *ctx, pdf_document *doc);
358
+ void pdf_document_event_did_print(fz_context *ctx, pdf_document *doc);
359
+
360
+ void pdf_page_event_open(fz_context *ctx, pdf_page *page);
361
+ void pdf_page_event_close(fz_context *ctx, pdf_page *page);
362
+
363
+ void pdf_annot_event_enter(fz_context *ctx, pdf_annot *annot);
364
+ void pdf_annot_event_exit(fz_context *ctx, pdf_annot *annot);
365
+ void pdf_annot_event_down(fz_context *ctx, pdf_annot *annot);
366
+ void pdf_annot_event_up(fz_context *ctx, pdf_annot *annot);
367
+ void pdf_annot_event_focus(fz_context *ctx, pdf_annot *annot);
368
+ void pdf_annot_event_blur(fz_context *ctx, pdf_annot *annot);
369
+ void pdf_annot_event_page_open(fz_context *ctx, pdf_annot *annot);
370
+ void pdf_annot_event_page_close(fz_context *ctx, pdf_annot *annot);
371
+ void pdf_annot_event_page_visible(fz_context *ctx, pdf_annot *annot);
372
+ void pdf_annot_event_page_invisible(fz_context *ctx, pdf_annot *annot);
373
+
374
+ /*
375
+ * Bake appearances of annotations and/or widgets into static page content,
376
+ * and remove the corresponding interactive PDF objects.
377
+ */
378
+ void pdf_bake_document(fz_context *ctx, pdf_document *doc, int bake_annots, int bake_widgets);
379
+
380
+ #endif
@@ -0,0 +1,78 @@
1
+ // Copyright (C) 2004-2021 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_IMAGE_REWRITER_H
24
+ #define MUPDF_PDF_IMAGE_REWRITER_H
25
+
26
+ #include "mupdf/pdf/document.h"
27
+
28
+ enum
29
+ {
30
+ FZ_SUBSAMPLE_AVERAGE,
31
+ FZ_SUBSAMPLE_BICUBIC
32
+ };
33
+
34
+ enum
35
+ {
36
+ FZ_RECOMPRESS_NEVER,
37
+ FZ_RECOMPRESS_SAME,
38
+ FZ_RECOMPRESS_LOSSLESS,
39
+ FZ_RECOMPRESS_JPEG,
40
+ FZ_RECOMPRESS_J2K,
41
+ FZ_RECOMPRESS_FAX
42
+ };
43
+
44
+ typedef struct
45
+ {
46
+ int color_lossless_image_subsample_method;
47
+ int color_lossy_image_subsample_method;
48
+ int color_lossless_image_subsample_threshold; /* 0, or the threshold dpi at which to subsample color images. */
49
+ int color_lossless_image_subsample_to; /* 0, or the dpi to subsample to */
50
+ int color_lossy_image_subsample_threshold; /* 0, or the threshold dpi at which to subsample color images. */
51
+ int color_lossy_image_subsample_to; /* 0, or the dpi to subsample to */
52
+ int color_lossless_image_recompress_method; /* Which compression method to use for losslessly compressed color images? */
53
+ int color_lossy_image_recompress_method; /* Which compression method to use for lossy compressed color images? */
54
+ char *color_lossy_image_recompress_quality;
55
+ char *color_lossless_image_recompress_quality;
56
+ int gray_lossless_image_subsample_method;
57
+ int gray_lossy_image_subsample_method;
58
+ int gray_lossless_image_subsample_threshold; /* 0, or the threshold at which to subsample gray images. */
59
+ int gray_lossless_image_subsample_to; /* 0, or the dpi to subsample to */
60
+ int gray_lossy_image_subsample_threshold; /* 0, or the threshold at which to subsample gray images. */
61
+ int gray_lossy_image_subsample_to; /* 0, or the dpi to subsample to */
62
+ int gray_lossless_image_recompress_method; /* Which compression method to use for losslessly compressed gray images? */
63
+ int gray_lossy_image_recompress_method; /* Which compression method to use for lossy compressed gray images? */
64
+ char *gray_lossy_image_recompress_quality;
65
+ char *gray_lossless_image_recompress_quality;
66
+ int bitonal_image_subsample_method;
67
+ int bitonal_image_subsample_threshold; /* 0, or the threshold at which to subsample bitonal images. */
68
+ int bitonal_image_subsample_to; /* 0, or the dpi to subsample to */
69
+ int bitonal_image_recompress_method; /* Which compression method to use for bitonal images? */
70
+ char *bitonal_image_recompress_quality;
71
+ } pdf_image_rewriter_options;
72
+
73
+ /*
74
+ Rewrite images within the given document.
75
+ */
76
+ void pdf_rewrite_images(fz_context *ctx, pdf_document *doc, pdf_image_rewriter_options *opts);
77
+
78
+ #endif