PyMuPDF 1.26.6__cp310-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 (112) hide show
  1. fitz/__init__.py +13 -0
  2. fitz/table.py +2 -0
  3. fitz/utils.py +2 -0
  4. pymupdf/__init__.py +25899 -0
  5. pymupdf/__main__.py +1140 -0
  6. pymupdf/_apply_pages.py +253 -0
  7. pymupdf/_build.py +8 -0
  8. pymupdf/_extra.pyd +0 -0
  9. pymupdf/_mupdf.pyd +0 -0
  10. pymupdf/_wxcolors.py +562 -0
  11. pymupdf/extra.py +220 -0
  12. pymupdf/mupdf-devel/include/mupdf/classes.h +19999 -0
  13. pymupdf/mupdf-devel/include/mupdf/classes2.h +12244 -0
  14. pymupdf/mupdf-devel/include/mupdf/exceptions.h +118 -0
  15. pymupdf/mupdf-devel/include/mupdf/extra.h +189 -0
  16. pymupdf/mupdf-devel/include/mupdf/fitz/archive.h +444 -0
  17. pymupdf/mupdf-devel/include/mupdf/fitz/band-writer.h +117 -0
  18. pymupdf/mupdf-devel/include/mupdf/fitz/barcode.h +138 -0
  19. pymupdf/mupdf-devel/include/mupdf/fitz/bidi.h +90 -0
  20. pymupdf/mupdf-devel/include/mupdf/fitz/bitmap.h +188 -0
  21. pymupdf/mupdf-devel/include/mupdf/fitz/buffer.h +250 -0
  22. pymupdf/mupdf-devel/include/mupdf/fitz/color.h +433 -0
  23. pymupdf/mupdf-devel/include/mupdf/fitz/compress.h +132 -0
  24. pymupdf/mupdf-devel/include/mupdf/fitz/compressed-buffer.h +194 -0
  25. pymupdf/mupdf-devel/include/mupdf/fitz/config.h +302 -0
  26. pymupdf/mupdf-devel/include/mupdf/fitz/context.h +1064 -0
  27. pymupdf/mupdf-devel/include/mupdf/fitz/crypt.h +270 -0
  28. pymupdf/mupdf-devel/include/mupdf/fitz/deskew.h +46 -0
  29. pymupdf/mupdf-devel/include/mupdf/fitz/device.h +652 -0
  30. pymupdf/mupdf-devel/include/mupdf/fitz/display-list.h +142 -0
  31. pymupdf/mupdf-devel/include/mupdf/fitz/document.h +1103 -0
  32. pymupdf/mupdf-devel/include/mupdf/fitz/export.h +52 -0
  33. pymupdf/mupdf-devel/include/mupdf/fitz/filter.h +269 -0
  34. pymupdf/mupdf-devel/include/mupdf/fitz/font.h +858 -0
  35. pymupdf/mupdf-devel/include/mupdf/fitz/geometry.h +885 -0
  36. pymupdf/mupdf-devel/include/mupdf/fitz/getopt.h +134 -0
  37. pymupdf/mupdf-devel/include/mupdf/fitz/glyph-cache.h +96 -0
  38. pymupdf/mupdf-devel/include/mupdf/fitz/glyph.h +81 -0
  39. pymupdf/mupdf-devel/include/mupdf/fitz/hash.h +126 -0
  40. pymupdf/mupdf-devel/include/mupdf/fitz/heap-imp.h +190 -0
  41. pymupdf/mupdf-devel/include/mupdf/fitz/heap.h +143 -0
  42. pymupdf/mupdf-devel/include/mupdf/fitz/image.h +451 -0
  43. pymupdf/mupdf-devel/include/mupdf/fitz/json.h +98 -0
  44. pymupdf/mupdf-devel/include/mupdf/fitz/link.h +130 -0
  45. pymupdf/mupdf-devel/include/mupdf/fitz/log.h +61 -0
  46. pymupdf/mupdf-devel/include/mupdf/fitz/outline.h +254 -0
  47. pymupdf/mupdf-devel/include/mupdf/fitz/output-svg.h +64 -0
  48. pymupdf/mupdf-devel/include/mupdf/fitz/output.h +448 -0
  49. pymupdf/mupdf-devel/include/mupdf/fitz/path.h +477 -0
  50. pymupdf/mupdf-devel/include/mupdf/fitz/pixmap.h +516 -0
  51. pymupdf/mupdf-devel/include/mupdf/fitz/pool.h +102 -0
  52. pymupdf/mupdf-devel/include/mupdf/fitz/separation.h +138 -0
  53. pymupdf/mupdf-devel/include/mupdf/fitz/shade.h +233 -0
  54. pymupdf/mupdf-devel/include/mupdf/fitz/store.h +465 -0
  55. pymupdf/mupdf-devel/include/mupdf/fitz/story-writer.h +209 -0
  56. pymupdf/mupdf-devel/include/mupdf/fitz/story.h +232 -0
  57. pymupdf/mupdf-devel/include/mupdf/fitz/stream.h +646 -0
  58. pymupdf/mupdf-devel/include/mupdf/fitz/string-util.h +335 -0
  59. pymupdf/mupdf-devel/include/mupdf/fitz/structured-text.h +924 -0
  60. pymupdf/mupdf-devel/include/mupdf/fitz/system.h +495 -0
  61. pymupdf/mupdf-devel/include/mupdf/fitz/text.h +210 -0
  62. pymupdf/mupdf-devel/include/mupdf/fitz/track-usage.h +57 -0
  63. pymupdf/mupdf-devel/include/mupdf/fitz/transition.h +76 -0
  64. pymupdf/mupdf-devel/include/mupdf/fitz/tree.h +62 -0
  65. pymupdf/mupdf-devel/include/mupdf/fitz/types.h +41 -0
  66. pymupdf/mupdf-devel/include/mupdf/fitz/util.h +159 -0
  67. pymupdf/mupdf-devel/include/mupdf/fitz/version.h +31 -0
  68. pymupdf/mupdf-devel/include/mupdf/fitz/write-pixmap.h +507 -0
  69. pymupdf/mupdf-devel/include/mupdf/fitz/writer.h +269 -0
  70. pymupdf/mupdf-devel/include/mupdf/fitz/xml.h +435 -0
  71. pymupdf/mupdf-devel/include/mupdf/fitz.h +101 -0
  72. pymupdf/mupdf-devel/include/mupdf/functions.h +13819 -0
  73. pymupdf/mupdf-devel/include/mupdf/helpers/mu-office-lib.h +666 -0
  74. pymupdf/mupdf-devel/include/mupdf/helpers/mu-threads.h +280 -0
  75. pymupdf/mupdf-devel/include/mupdf/helpers/pkcs7-openssl.h +48 -0
  76. pymupdf/mupdf-devel/include/mupdf/html.h +53 -0
  77. pymupdf/mupdf-devel/include/mupdf/internal.h +29 -0
  78. pymupdf/mupdf-devel/include/mupdf/memento.h +425 -0
  79. pymupdf/mupdf-devel/include/mupdf/pdf/annot.h +1015 -0
  80. pymupdf/mupdf-devel/include/mupdf/pdf/clean.h +68 -0
  81. pymupdf/mupdf-devel/include/mupdf/pdf/cmap.h +145 -0
  82. pymupdf/mupdf-devel/include/mupdf/pdf/crypt.h +108 -0
  83. pymupdf/mupdf-devel/include/mupdf/pdf/document.h +902 -0
  84. pymupdf/mupdf-devel/include/mupdf/pdf/event.h +167 -0
  85. pymupdf/mupdf-devel/include/mupdf/pdf/font.h +168 -0
  86. pymupdf/mupdf-devel/include/mupdf/pdf/form.h +381 -0
  87. pymupdf/mupdf-devel/include/mupdf/pdf/image-rewriter.h +78 -0
  88. pymupdf/mupdf-devel/include/mupdf/pdf/interpret.h +518 -0
  89. pymupdf/mupdf-devel/include/mupdf/pdf/javascript.h +43 -0
  90. pymupdf/mupdf-devel/include/mupdf/pdf/name-table.h +621 -0
  91. pymupdf/mupdf-devel/include/mupdf/pdf/object.h +445 -0
  92. pymupdf/mupdf-devel/include/mupdf/pdf/page.h +327 -0
  93. pymupdf/mupdf-devel/include/mupdf/pdf/parse.h +61 -0
  94. pymupdf/mupdf-devel/include/mupdf/pdf/recolor.h +49 -0
  95. pymupdf/mupdf-devel/include/mupdf/pdf/resource.h +144 -0
  96. pymupdf/mupdf-devel/include/mupdf/pdf/xref.h +300 -0
  97. pymupdf/mupdf-devel/include/mupdf/pdf/zugferd.h +49 -0
  98. pymupdf/mupdf-devel/include/mupdf/pdf.h +59 -0
  99. pymupdf/mupdf-devel/include/mupdf/ucdn.h +464 -0
  100. pymupdf/mupdf-devel/lib/libmuthreads.lib +0 -0
  101. pymupdf/mupdf-devel/lib/mupdfcpp64.lib +0 -0
  102. pymupdf/mupdf.py +63667 -0
  103. pymupdf/mupdfcpp64.dll +0 -0
  104. pymupdf/pymupdf.py +2 -0
  105. pymupdf/table.py +2697 -0
  106. pymupdf/utils.py +1169 -0
  107. pymupdf-1.26.6.dist-info/COPYING +1 -0
  108. pymupdf-1.26.6.dist-info/METADATA +83 -0
  109. pymupdf-1.26.6.dist-info/README.md +60 -0
  110. pymupdf-1.26.6.dist-info/RECORD +112 -0
  111. pymupdf-1.26.6.dist-info/WHEEL +4 -0
  112. pymupdf-1.26.6.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ Bidirectional text processing.
3
+
4
+ Derived from the SmartOffice code, which is itself derived
5
+ from the example unicode standard code. Original copyright
6
+ messages follow:
7
+
8
+ Copyright (C) Picsel, 2004-2008. All Rights Reserved.
9
+
10
+ Processes Unicode text by arranging the characters into an order
11
+ suitable for display. E.g. Hebrew text will be arranged from
12
+ right-to-left and any English within the text will remain in the
13
+ left-to-right order.
14
+
15
+ This is an implementation of the Unicode Bidirectional Algorithm
16
+ which can be found here: http://www.unicode.org/reports/tr9/ and
17
+ is based on the reference implementation found on Unicode.org.
18
+ */
19
+
20
+ #ifndef FITZ_BIDI_H
21
+ #define FITZ_BIDI_H
22
+
23
+ #include "mupdf/fitz/system.h"
24
+ #include "mupdf/fitz/context.h"
25
+
26
+ /* Implementation details: subject to change. */
27
+
28
+ typedef enum
29
+ {
30
+ FZ_BIDI_LTR = 0,
31
+ FZ_BIDI_RTL = 1,
32
+ FZ_BIDI_NEUTRAL = 2
33
+ }
34
+ fz_bidi_direction;
35
+
36
+ typedef enum
37
+ {
38
+ FZ_BIDI_CLASSIFY_WHITE_SPACE = 1,
39
+ FZ_BIDI_REPLACE_TAB = 2
40
+ }
41
+ fz_bidi_flags;
42
+
43
+ /**
44
+ Prototype for callback function supplied to fz_bidi_fragment_text.
45
+
46
+ @param fragment first character in fragment
47
+ @param fragmentLen number of characters in fragment
48
+ @param bidiLevel The bidirectional level for this text.
49
+ The bottom bit will be set iff block
50
+ should concatenate with other blocks as
51
+ right-to-left
52
+ @param script the script in use for this fragment (other
53
+ than common or inherited)
54
+ @param arg data from caller of Bidi_fragmentText
55
+ */
56
+ typedef void (fz_bidi_fragment_fn)(const uint32_t *fragment,
57
+ size_t fragmentLen,
58
+ int bidiLevel,
59
+ int script,
60
+ void *arg);
61
+
62
+ /**
63
+ Partitions the given Unicode sequence into one or more
64
+ unidirectional fragments and invokes the given callback
65
+ function for each fragment.
66
+
67
+ For example, if directionality of text is:
68
+ 0123456789
69
+ rrlllrrrrr,
70
+ we'll invoke callback with:
71
+ &text[0], length == 2
72
+ &text[2], length == 3
73
+ &text[5], length == 5
74
+
75
+ @param[in] text start of Unicode sequence
76
+ @param[in] textlen number of Unicodes to analyse
77
+ @param[in] baseDir direction of paragraph (specify FZ_BIDI_NEUTRAL to force auto-detection)
78
+ @param[in] callback function to be called for each fragment
79
+ @param[in] arg data to be passed to the callback function
80
+ @param[in] flags flags to control operation (see fz_bidi_flags above)
81
+ */
82
+ void fz_bidi_fragment_text(fz_context *ctx,
83
+ const uint32_t *text,
84
+ size_t textlen,
85
+ fz_bidi_direction *baseDir,
86
+ fz_bidi_fragment_fn *callback,
87
+ void *arg,
88
+ int flags);
89
+
90
+ #endif
@@ -0,0 +1,188 @@
1
+ // Copyright (C) 2004-2025 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_BITMAP_H
24
+ #define MUPDF_FITZ_BITMAP_H
25
+
26
+ #include "mupdf/fitz/system.h"
27
+ #include "mupdf/fitz/context.h"
28
+ #include "mupdf/fitz/pixmap.h"
29
+
30
+ /**
31
+ Bitmaps have 1 bit per component. Only used for creating
32
+ halftoned versions of contone buffers, and saving out. Samples
33
+ are stored msb first, akin to pbms.
34
+
35
+ The internals of this struct are considered implementation
36
+ details and subject to change. Where possible, accessor
37
+ functions should be used in preference.
38
+ */
39
+ typedef struct
40
+ {
41
+ int refs;
42
+ int w, h, stride, n;
43
+ int xres, yres;
44
+ unsigned char *samples;
45
+ } fz_bitmap;
46
+
47
+ /**
48
+ Take an additional reference to the bitmap. The same pointer
49
+ is returned.
50
+
51
+ Never throws exceptions.
52
+ */
53
+ fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit);
54
+
55
+ /**
56
+ Drop a reference to the bitmap. When the reference count reaches
57
+ zero, the bitmap will be destroyed.
58
+
59
+ Never throws exceptions.
60
+ */
61
+ void fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit);
62
+
63
+ /**
64
+ Invert bitmap.
65
+
66
+ Never throws exceptions.
67
+ */
68
+ void fz_invert_bitmap(fz_context *ctx, fz_bitmap *bmp);
69
+
70
+ /**
71
+ A halftone is a set of threshold tiles, one per component. Each
72
+ threshold tile is a pixmap, possibly of varying sizes and
73
+ phases. Currently, we only provide one 'default' halftone tile
74
+ for operating on 1 component plus alpha pixmaps (where the alpha
75
+ is ignored). This is signified by a fz_halftone pointer to NULL.
76
+ */
77
+ typedef struct fz_halftone fz_halftone;
78
+
79
+ /**
80
+ Make a bitmap from a pixmap and a halftone.
81
+
82
+ pix: The pixmap to generate from. Currently must be a single
83
+ color component with no alpha.
84
+
85
+ ht: The halftone to use. NULL implies the default halftone.
86
+
87
+ Returns the resultant bitmap. Throws exceptions in the case of
88
+ failure to allocate.
89
+ */
90
+ fz_bitmap *fz_new_bitmap_from_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht);
91
+
92
+ /**
93
+ Make a bitmap from a pixmap and a halftone.
94
+
95
+ img: The image to generate from. Currently must be a single
96
+ color component with no alpha.
97
+
98
+ ht: The halftone to use. NULL implies the default halftone.
99
+
100
+ Returns the resultant bitmap. Throws exceptions in the case of
101
+ failure to allocate.
102
+ */
103
+ fz_bitmap *fz_new_bitmap_from_image(fz_context *ctx, fz_image *img, fz_halftone *ht);
104
+
105
+ /**
106
+ Make a bitmap from a pixmap and a
107
+ halftone, allowing for the position of the pixmap within an
108
+ overall banded rendering.
109
+
110
+ pix: The pixmap to generate from. Currently must be a single
111
+ color component with no alpha.
112
+
113
+ ht: The halftone to use. NULL implies the default halftone.
114
+
115
+ band_start: Vertical offset within the overall banded rendering
116
+ (in pixels)
117
+
118
+ Returns the resultant bitmap. Throws exceptions in the case of
119
+ failure to allocate.
120
+ */
121
+ fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band_start);
122
+
123
+ /**
124
+ Create a new bitmap.
125
+
126
+ w, h: Width and Height for the bitmap
127
+
128
+ n: Number of color components (assumed to be a divisor of 8)
129
+
130
+ xres, yres: X and Y resolutions (in pixels per inch).
131
+
132
+ Returns pointer to created bitmap structure. The bitmap
133
+ data is uninitialised.
134
+ */
135
+ fz_bitmap *fz_new_bitmap(fz_context *ctx, int w, int h, int n, int xres, int yres);
136
+
137
+ /**
138
+ Retrieve details of a given bitmap.
139
+
140
+ bitmap: The bitmap to query.
141
+
142
+ w: Pointer to storage to retrieve width (or NULL).
143
+
144
+ h: Pointer to storage to retrieve height (or NULL).
145
+
146
+ n: Pointer to storage to retrieve number of color components (or
147
+ NULL).
148
+
149
+ stride: Pointer to storage to retrieve bitmap stride (or NULL).
150
+ */
151
+ void fz_bitmap_details(fz_bitmap *bitmap, int *w, int *h, int *n, int *stride);
152
+
153
+ /**
154
+ Set the entire bitmap to 0.
155
+
156
+ Never throws exceptions.
157
+ */
158
+ void fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit);
159
+
160
+ /**
161
+ Create a 'default' halftone structure
162
+ for the given number of components.
163
+
164
+ num_comps: The number of components to use.
165
+
166
+ Returns a simple default halftone. The default halftone uses
167
+ the same halftone tile for each plane, which may not be ideal
168
+ for all purposes.
169
+ */
170
+ fz_halftone *fz_default_halftone(fz_context *ctx, int num_comps);
171
+
172
+ /**
173
+ Take an additional reference to the halftone. The same pointer
174
+ is returned.
175
+
176
+ Never throws exceptions.
177
+ */
178
+ fz_halftone *fz_keep_halftone(fz_context *ctx, fz_halftone *half);
179
+
180
+ /**
181
+ Drop a reference to the halftone. When the reference count
182
+ reaches zero, the halftone is destroyed.
183
+
184
+ Never throws exceptions.
185
+ */
186
+ void fz_drop_halftone(fz_context *ctx, fz_halftone *ht);
187
+
188
+ #endif
@@ -0,0 +1,250 @@
1
+ // Copyright (C) 2004-2023 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_BUFFER_H
24
+ #define MUPDF_FITZ_BUFFER_H
25
+
26
+ #include "mupdf/fitz/system.h"
27
+ #include "mupdf/fitz/context.h"
28
+
29
+ /**
30
+ fz_buffer is a wrapper around a dynamically allocated array of
31
+ bytes.
32
+
33
+ Buffers have a capacity (the number of bytes storage immediately
34
+ available) and a current size.
35
+
36
+ The contents of the structure are considered implementation
37
+ details and are subject to change. Users should use the accessor
38
+ functions in preference.
39
+ */
40
+ typedef struct
41
+ {
42
+ int refs;
43
+ unsigned char *data;
44
+ size_t cap, len;
45
+ int unused_bits;
46
+ int shared;
47
+ } fz_buffer;
48
+
49
+ /**
50
+ Take an additional reference to the buffer. The same pointer
51
+ is returned.
52
+
53
+ Never throws exceptions.
54
+ */
55
+ fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf);
56
+
57
+ /**
58
+ Drop a reference to the buffer. When the reference count reaches
59
+ zero, the buffer is destroyed.
60
+
61
+ Never throws exceptions.
62
+ */
63
+ void fz_drop_buffer(fz_context *ctx, fz_buffer *buf);
64
+
65
+ /**
66
+ Retrieve internal memory of buffer.
67
+
68
+ datap: Output parameter that will be pointed to the data.
69
+
70
+ Returns the current size of the data in bytes.
71
+ */
72
+ size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap);
73
+
74
+ /**
75
+ Ensure that a buffer's data ends in a
76
+ 0 byte, and return a pointer to it.
77
+ */
78
+ const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf);
79
+
80
+ fz_buffer *fz_new_buffer(fz_context *ctx, size_t capacity);
81
+
82
+ /**
83
+ Create a new buffer with existing data.
84
+
85
+ data: Pointer to existing data.
86
+ size: Size of existing data.
87
+
88
+ Takes ownership of data. Does not make a copy. Calls fz_free on
89
+ the data when the buffer is deallocated. Do not use 'data' after
90
+ passing to this function.
91
+
92
+ Returns pointer to new buffer. Throws exception on allocation
93
+ failure.
94
+ */
95
+ fz_buffer *fz_new_buffer_from_data(fz_context *ctx, unsigned char *data, size_t size);
96
+
97
+ /**
98
+ Like fz_new_buffer, but does not take ownership.
99
+ */
100
+ fz_buffer *fz_new_buffer_from_shared_data(fz_context *ctx, const unsigned char *data, size_t size);
101
+
102
+ /**
103
+ Create a new buffer containing a copy of the passed data.
104
+ */
105
+ fz_buffer *fz_new_buffer_from_copied_data(fz_context *ctx, const unsigned char *data, size_t size);
106
+
107
+ /**
108
+ Make a new buffer, containing a copy of the data used in
109
+ the original.
110
+ */
111
+ fz_buffer *fz_clone_buffer(fz_context *ctx, fz_buffer *buf);
112
+
113
+ /**
114
+ Create a new buffer with data decoded from a base64 input string.
115
+ */
116
+ fz_buffer *fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t size);
117
+
118
+ /**
119
+ Ensure that a buffer has a given capacity,
120
+ truncating data if required.
121
+
122
+ capacity: The desired capacity for the buffer. If the current
123
+ size of the buffer contents is smaller than capacity, it is
124
+ truncated.
125
+ */
126
+ void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t capacity);
127
+
128
+ /**
129
+ Make some space within a buffer (i.e. ensure that
130
+ capacity > size).
131
+ */
132
+ void fz_grow_buffer(fz_context *ctx, fz_buffer *buf);
133
+
134
+ /**
135
+ Trim wasted capacity from a buffer by resizing internal memory.
136
+ */
137
+ void fz_trim_buffer(fz_context *ctx, fz_buffer *buf);
138
+
139
+ /**
140
+ Empties the buffer. Storage is not freed, but is held ready
141
+ to be reused as the buffer is refilled.
142
+
143
+ Never throws exceptions.
144
+ */
145
+ void fz_clear_buffer(fz_context *ctx, fz_buffer *buf);
146
+
147
+ /**
148
+ Create a new buffer with a (subset of) the data from the buffer.
149
+
150
+ start: if >= 0, offset from start of buffer, if < 0 offset from end of buffer.
151
+
152
+ end: if >= 0, offset from start of buffer, if < 0 offset from end of buffer.
153
+
154
+ */
155
+ fz_buffer *fz_slice_buffer(fz_context *ctx, fz_buffer *buf, int64_t start, int64_t end);
156
+
157
+ /**
158
+ Append the contents of the source buffer onto the end of the
159
+ destination buffer, extending automatically as required.
160
+
161
+ Ownership of buffers does not change.
162
+ */
163
+ void fz_append_buffer(fz_context *ctx, fz_buffer *destination, fz_buffer *source);
164
+
165
+ /**
166
+ Write a base64 encoded data block, optionally with periodic newlines.
167
+ */
168
+ void fz_append_base64(fz_context *ctx, fz_buffer *out, const unsigned char *data, size_t size, int newline);
169
+
170
+ /**
171
+ Append a base64 encoded fz_buffer, optionally with periodic newlines.
172
+ */
173
+ void fz_append_base64_buffer(fz_context *ctx, fz_buffer *out, fz_buffer *data, int newline);
174
+
175
+ /**
176
+ fz_append_*: Append data to a buffer.
177
+
178
+ The buffer will automatically grow as required.
179
+ */
180
+ void fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len);
181
+ void fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data);
182
+ void fz_append_byte(fz_context *ctx, fz_buffer *buf, int c);
183
+ void fz_append_rune(fz_context *ctx, fz_buffer *buf, int c);
184
+ void fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int x);
185
+ void fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int x);
186
+ void fz_append_int32_be(fz_context *ctx, fz_buffer *buf, int x);
187
+ void fz_append_int16_be(fz_context *ctx, fz_buffer *buf, int x);
188
+ void fz_append_bits(fz_context *ctx, fz_buffer *buf, int value, int count);
189
+ void fz_append_bits_pad(fz_context *ctx, fz_buffer *buf);
190
+
191
+ /**
192
+ fz_append_pdf_string: Append a string with PDF syntax quotes and
193
+ escapes.
194
+
195
+ The buffer will automatically grow as required.
196
+ */
197
+ void fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
198
+
199
+ /**
200
+ fz_append_printf: Format and append data to buffer using
201
+ printf-like formatting (see fz_vsnprintf).
202
+
203
+ The buffer will automatically grow as required.
204
+ */
205
+ void fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
206
+
207
+ /**
208
+ fz_append_vprintf: Format and append data to buffer using
209
+ printf-like formatting with varargs (see fz_vsnprintf).
210
+ */
211
+ void fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
212
+
213
+ /**
214
+ Zero-terminate buffer in order to use as a C string.
215
+
216
+ This byte is invisible and does not affect the length of the
217
+ buffer as returned by fz_buffer_storage. The zero byte is
218
+ written *after* the data, and subsequent writes will overwrite
219
+ the terminating byte.
220
+
221
+ Subsequent changes to the size of the buffer (such as by
222
+ fz_buffer_trim, fz_buffer_grow, fz_resize_buffer, etc) may
223
+ invalidate this.
224
+ */
225
+ void fz_terminate_buffer(fz_context *ctx, fz_buffer *buf);
226
+
227
+ /**
228
+ Create an MD5 digest from buffer contents.
229
+
230
+ Never throws exceptions.
231
+ */
232
+ void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16]);
233
+
234
+ /**
235
+ Take ownership of buffer contents.
236
+
237
+ Performs the same task as fz_buffer_storage, but ownership of
238
+ the data buffer returns with this call. The buffer is left
239
+ empty.
240
+
241
+ Note: Bad things may happen if this is called on a buffer with
242
+ multiple references that is being used from multiple threads.
243
+
244
+ data: Pointer to place to retrieve data pointer.
245
+
246
+ Returns length of stream.
247
+ */
248
+ size_t fz_buffer_extract(fz_context *ctx, fz_buffer *buf, unsigned char **data);
249
+
250
+ #endif