@muhammara/native-core 7.0.0-beta.4 → 7.0.0-rc.2
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.
- package/README.md +57 -7
- package/THIRD_PARTY_NOTICES.md +39 -0
- package/index.js +120 -1
- package/lib/PDFRStreamForBuffer.js +52 -7
- package/lib/PDFRStreamForFile.js +56 -7
- package/lib/PDFStreamForResponse.js +22 -5
- package/lib/PDFWStreamForBuffer.js +49 -10
- package/lib/PDFWStreamForFile.js +26 -5
- package/lib/Recipe.js +91 -38
- package/lib/content-stream.js +503 -0
- package/lib/css-colors.js +149 -0
- package/lib/font-text.js +1461 -0
- package/lib/glyph-list.js +1127 -0
- package/lib/recipe/annotation.js +464 -101
- package/lib/recipe/appendPage.js +2 -0
- package/lib/recipe/colors.js +132 -35
- package/lib/recipe/coordinate.js +82 -16
- package/lib/recipe/encrypt.js +32 -13
- package/lib/recipe/font.js +70 -25
- package/lib/recipe/graphics-state.js +3 -2
- package/lib/recipe/htmlToTextObjects.js +121 -24
- package/lib/recipe/image.js +385 -39
- package/lib/recipe/info.js +93 -22
- package/lib/recipe/insertPage.js +12 -3
- package/lib/recipe/overlay.js +4 -2
- package/lib/recipe/page-references.js +436 -0
- package/lib/recipe/page.js +363 -262
- package/lib/recipe/parameters.js +8 -1
- package/lib/recipe/replaceText.js +464 -30
- package/lib/recipe/shapes.js +418 -45
- package/lib/recipe/split.js +6 -2
- package/lib/recipe/table.js +41 -8
- package/lib/recipe/text.helper.js +172 -8
- package/lib/recipe/text.js +294 -56
- package/lib/recipe/utils.js +17 -6
- package/lib/recipe/vector-line.js +101 -39
- package/lib/recipe/vector-polygon.js +18 -6
- package/lib/recipe/vector.helper.js +156 -14
- package/lib/recipe/vector.js +156 -52
- package/lib/recipe/xObjectForm.js +73 -10
- package/lib/recipe-constants.js +373 -0
- package/lib/recipe-options.js +47 -0
- package/muhammara.d.ts +3501 -160
- package/package.json +2 -3
package/muhammara.d.ts
CHANGED
|
@@ -13,63 +13,225 @@ declare namespace muhammara {
|
|
|
13
13
|
export let PDFRStreamForBuffer: PDFRStreamForBuffer;
|
|
14
14
|
export let PDFWStreamForBuffer: PDFWStreamForBuffer;
|
|
15
15
|
export let PDFStreamForResponse: PDFStreamForResponse;
|
|
16
|
+
export let PDFDate: {
|
|
17
|
+
new (value?: string | Date): PDFDate;
|
|
18
|
+
};
|
|
19
|
+
export let PDFTextString: {
|
|
20
|
+
new (value?: string | number[]): PDFTextString;
|
|
21
|
+
};
|
|
16
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Starts writing a new PDF.
|
|
25
|
+
* @param input - The output path, or a stream that receives the bytes.
|
|
26
|
+
* @param options - The PDF version, compression, log and encryption.
|
|
27
|
+
* @returns The writer; call end() to finish the PDF.
|
|
28
|
+
* @throws {TypeError} If the arguments are wrong, the version is not a valid
|
|
29
|
+
* PDF version, or the output cannot be opened.
|
|
30
|
+
*/
|
|
17
31
|
export function createWriter(
|
|
18
32
|
input: FilePath | WriteStream,
|
|
19
33
|
options?: PDFWriterOptions,
|
|
20
34
|
): PDFWriter;
|
|
35
|
+
/**
|
|
36
|
+
* Starts an incremental update of a PDF file, in place or into
|
|
37
|
+
* options.modifiedFilePath.
|
|
38
|
+
* @param inFile - The PDF path.
|
|
39
|
+
* @param options - The output path, version, compression, log and encryption.
|
|
40
|
+
* @returns The writer; call end() to append the update.
|
|
41
|
+
* @throws {TypeError} If the arguments are wrong or the PDF cannot be read.
|
|
42
|
+
*/
|
|
21
43
|
export function createWriterToModify(
|
|
22
44
|
inFile: FilePath,
|
|
23
45
|
options?: PDFWriterToModifyOptions,
|
|
24
46
|
): PDFWriter;
|
|
47
|
+
/**
|
|
48
|
+
* Starts an incremental update of a PDF stream. The output receives the
|
|
49
|
+
* original bytes followed by the update.
|
|
50
|
+
* @param inStream - The source PDF.
|
|
51
|
+
* @param outStream - The output stream.
|
|
52
|
+
* @param options - The version, compression, log and encryption.
|
|
53
|
+
* @returns The writer; call end() to append the update.
|
|
54
|
+
* @throws {TypeError} If the arguments are wrong or the PDF cannot be read.
|
|
55
|
+
*/
|
|
25
56
|
export function createWriterToModify(
|
|
26
57
|
inStream: ReadStream,
|
|
27
58
|
outStream: WriteStream,
|
|
28
59
|
options?: PDFWriterToModifyOptions,
|
|
29
60
|
): PDFWriter;
|
|
30
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Continues a PDF whose writer was retired with shutdown().
|
|
64
|
+
* @param restartFile - The output path, or the output stream, of the
|
|
65
|
+
* interrupted PDF.
|
|
66
|
+
* @param restartStateFile - The state file written by shutdown().
|
|
67
|
+
* @param options - The modified PDF path or stream, and the log.
|
|
68
|
+
* @returns The writer.
|
|
69
|
+
* @throws {TypeError} If the arguments are wrong or the state cannot be read.
|
|
70
|
+
*/
|
|
31
71
|
export function createWriterToContinue(
|
|
32
72
|
restartFile: string,
|
|
33
73
|
restartStateFile: string,
|
|
34
74
|
options?: PDFWriterToContinueOptions,
|
|
35
75
|
): PDFWriter;
|
|
76
|
+
/**
|
|
77
|
+
* Opens a PDF for reading.
|
|
78
|
+
* @param input - The PDF path or a read stream.
|
|
79
|
+
* @param options - The password of an encrypted PDF.
|
|
80
|
+
* @returns The reader; call end() to release the file.
|
|
81
|
+
* @throws {TypeError} If the arguments are wrong or the PDF cannot be parsed.
|
|
82
|
+
*/
|
|
36
83
|
export function createReader(
|
|
37
84
|
input: FilePath | ReadStream,
|
|
38
85
|
options?: PDFReaderOptions,
|
|
39
86
|
): PDFReader;
|
|
87
|
+
/**
|
|
88
|
+
* Writes a copy of a PDF with new encryption settings, or decrypted when
|
|
89
|
+
* no passwords are given.
|
|
90
|
+
* @param originalPdfPath - The source PDF path.
|
|
91
|
+
* @param newPdfPath - The output path.
|
|
92
|
+
* @param options - The source password and the new encryption settings.
|
|
93
|
+
* @throws {TypeError} If the arguments are wrong, one side is a path and the
|
|
94
|
+
* other a stream, or the PDF cannot be recrypted.
|
|
95
|
+
*/
|
|
40
96
|
export function recrypt(
|
|
41
97
|
originalPdfPath: FilePath,
|
|
42
98
|
newPdfPath: FilePath,
|
|
43
99
|
options?: PDFRecryptOptions,
|
|
44
100
|
): void;
|
|
101
|
+
/**
|
|
102
|
+
* Writes a copy of a PDF stream with new encryption settings, or decrypted
|
|
103
|
+
* when no passwords are given.
|
|
104
|
+
* @param originalPdfStream - The source PDF.
|
|
105
|
+
* @param newPdfStream - The output stream.
|
|
106
|
+
* @param options - The source password and the new encryption settings.
|
|
107
|
+
* @throws {TypeError} If the arguments are wrong or the PDF cannot be
|
|
108
|
+
* recrypted.
|
|
109
|
+
*/
|
|
45
110
|
export function recrypt(
|
|
46
111
|
originalPdfStream: PDFRStreamForFile | PDFRStreamForBuffer,
|
|
47
112
|
newPdfStream: PDFWStreamForFile | PDFWStreamForBuffer,
|
|
48
113
|
options?: PDFRecryptOptions,
|
|
49
114
|
): void;
|
|
50
115
|
|
|
116
|
+
/**
|
|
117
|
+
* A JavaScript output stream. `write` receives each chunk as a `Buffer` the
|
|
118
|
+
* stream owns and may keep, and returns the number of bytes it accepted.
|
|
119
|
+
*/
|
|
51
120
|
export interface WriteStream {
|
|
52
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Writes bytes. Implement it on a custom output stream.
|
|
123
|
+
* @param inBytes - The bytes to write.
|
|
124
|
+
* @returns The number of bytes written.
|
|
125
|
+
*/
|
|
126
|
+
write(inBytes: Buffer): number;
|
|
127
|
+
/**
|
|
128
|
+
* Returns the number of bytes written so far.
|
|
129
|
+
* @returns The current byte offset.
|
|
130
|
+
*/
|
|
53
131
|
getCurrentPosition(): number;
|
|
54
132
|
}
|
|
55
133
|
|
|
134
|
+
/**
|
|
135
|
+
* A JavaScript log sink. `write` receives each chunk as a `Buffer` the sink
|
|
136
|
+
* owns and may keep, and returns the number of bytes it accepted.
|
|
137
|
+
*/
|
|
138
|
+
export interface LogStream {
|
|
139
|
+
/**
|
|
140
|
+
* Writes log bytes synchronously.
|
|
141
|
+
* @param inBytes - The bytes to write.
|
|
142
|
+
* @returns The number of bytes written.
|
|
143
|
+
*/
|
|
144
|
+
write(inBytes: Buffer): number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A JavaScript input stream. `read` returns at most `inAmount` bytes as a
|
|
149
|
+
* `Uint8Array` (a `Buffer` qualifies) or an array of byte values.
|
|
150
|
+
*/
|
|
56
151
|
export interface ReadStream {
|
|
57
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Reads the next bytes and advances the position by the amount read.
|
|
154
|
+
* Implement it on a custom input stream.
|
|
155
|
+
* @param inAmount - The maximum number of bytes to read.
|
|
156
|
+
* @returns The bytes read; shorter than requested at the end.
|
|
157
|
+
*/
|
|
158
|
+
read(inAmount: number): Uint8Array | number[];
|
|
159
|
+
/**
|
|
160
|
+
* Tells whether bytes remain after the current position.
|
|
161
|
+
* @returns True while the end has not been reached.
|
|
162
|
+
*/
|
|
58
163
|
notEnded(): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Moves to a position relative to the start position.
|
|
166
|
+
* @param inPosition - The byte offset from the start position.
|
|
167
|
+
*/
|
|
59
168
|
setPosition(inPosition: number): void;
|
|
169
|
+
/**
|
|
170
|
+
* Moves to a position counted back from the end.
|
|
171
|
+
* @param inPosition - The number of bytes before the end.
|
|
172
|
+
*/
|
|
60
173
|
setPositionFromEnd(inPosition: number): void;
|
|
174
|
+
/**
|
|
175
|
+
* Advances the position without reading.
|
|
176
|
+
* @param inAmount - The number of bytes to skip.
|
|
177
|
+
*/
|
|
61
178
|
skip(inAmount: number): void;
|
|
179
|
+
/**
|
|
180
|
+
* Returns the position relative to the start position.
|
|
181
|
+
* @returns The current byte offset.
|
|
182
|
+
*/
|
|
62
183
|
getCurrentPosition(): number;
|
|
63
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Sets the offset that later positions are counted from, for PDF data
|
|
186
|
+
* that does not begin at byte zero. Optional: the reader never calls it, so
|
|
187
|
+
* a 6.x stream without it works unchanged.
|
|
188
|
+
* @param inPosition - The absolute byte offset of the start.
|
|
189
|
+
*/
|
|
190
|
+
moveStartPosition?(inPosition: number): void;
|
|
64
191
|
}
|
|
65
192
|
|
|
66
193
|
export interface PDFPageInput {
|
|
194
|
+
/**
|
|
195
|
+
* Returns the page dictionary.
|
|
196
|
+
* @returns The dictionary.
|
|
197
|
+
* @throws {TypeError} If the page input was not created by a reader.
|
|
198
|
+
*/
|
|
67
199
|
getDictionary(): PDFDictionary;
|
|
200
|
+
/**
|
|
201
|
+
* Returns the media box, inherited from parent pages when not set.
|
|
202
|
+
* @returns The box [left, bottom, right, top].
|
|
203
|
+
* @throws {TypeError} If the page input was not created by a reader.
|
|
204
|
+
*/
|
|
68
205
|
getMediaBox(): PDFBox;
|
|
206
|
+
/**
|
|
207
|
+
* Returns the crop box, inherited from parent pages when not set.
|
|
208
|
+
* @returns The box [left, bottom, right, top]; the media box when not set.
|
|
209
|
+
* @throws {TypeError} If the page input was not created by a reader.
|
|
210
|
+
*/
|
|
69
211
|
getCropBox(): PDFBox;
|
|
212
|
+
/**
|
|
213
|
+
* Returns the trim box, inherited from parent pages when not set.
|
|
214
|
+
* @returns The box [left, bottom, right, top]; the crop box when not set.
|
|
215
|
+
* @throws {TypeError} If the page input was not created by a reader.
|
|
216
|
+
*/
|
|
70
217
|
getTrimBox(): PDFBox;
|
|
218
|
+
/**
|
|
219
|
+
* Returns the bleed box, inherited from parent pages when not set.
|
|
220
|
+
* @returns The box [left, bottom, right, top]; the crop box when not set.
|
|
221
|
+
* @throws {TypeError} If the page input was not created by a reader.
|
|
222
|
+
*/
|
|
71
223
|
getBleedBox(): PDFBox;
|
|
224
|
+
/**
|
|
225
|
+
* Returns the art box, inherited from parent pages when not set.
|
|
226
|
+
* @returns The box [left, bottom, right, top]; the crop box when not set.
|
|
227
|
+
* @throws {TypeError} If the page input was not created by a reader.
|
|
228
|
+
*/
|
|
72
229
|
getArtBox(): PDFBox;
|
|
230
|
+
/**
|
|
231
|
+
* Returns the page rotation, inherited from parent pages when not set.
|
|
232
|
+
* @returns The rotation in degrees, a multiple of 90.
|
|
233
|
+
* @throws {TypeError} If the page input was not created by a reader.
|
|
234
|
+
*/
|
|
73
235
|
getRotate(): number;
|
|
74
236
|
}
|
|
75
237
|
|
|
@@ -79,9 +241,38 @@ declare namespace muhammara {
|
|
|
79
241
|
pageIndex?: number,
|
|
80
242
|
ensureContentEncapsulation?: boolean,
|
|
81
243
|
): PDFPageModifier;
|
|
244
|
+
/**
|
|
245
|
+
* Starts a content stream drawn over the existing page content.
|
|
246
|
+
* @returns This modifier.
|
|
247
|
+
* @throws {TypeError} If the page does not exist.
|
|
248
|
+
* @throws {TypeError} If the modifier was not created with a writer.
|
|
249
|
+
*/
|
|
82
250
|
startContext(): this;
|
|
251
|
+
/**
|
|
252
|
+
* Returns the started content context.
|
|
253
|
+
* @returns The content context.
|
|
254
|
+
* @throws {TypeError} If startContext() was not called.
|
|
255
|
+
* @throws {TypeError} If the modifier was not created with a writer.
|
|
256
|
+
*/
|
|
83
257
|
getContext(): XObjectContentContext;
|
|
258
|
+
/**
|
|
259
|
+
* Ends the content stream started by startContext().
|
|
260
|
+
* @returns This modifier.
|
|
261
|
+
* @throws {TypeError} If the modifier was not created with a writer.
|
|
262
|
+
*/
|
|
84
263
|
endContext(): this;
|
|
264
|
+
/**
|
|
265
|
+
* Adds a link annotation to the modified page.
|
|
266
|
+
* @param inUrl - The ASCII link target.
|
|
267
|
+
* @param left - The clickable area left edge.
|
|
268
|
+
* @param bottom - The clickable area bottom edge.
|
|
269
|
+
* @param right - The clickable area right edge.
|
|
270
|
+
* @param top - The clickable area top edge.
|
|
271
|
+
* @returns This modifier.
|
|
272
|
+
* @throws {TypeError} If the arguments are not a string and four numbers, or
|
|
273
|
+
* the URL cannot be encoded as ASCII.
|
|
274
|
+
* @throws {TypeError} If the modifier was not created with a writer.
|
|
275
|
+
*/
|
|
85
276
|
attachURLLinktoCurrentPage(
|
|
86
277
|
inUrl: string,
|
|
87
278
|
left: number,
|
|
@@ -89,28 +280,103 @@ declare namespace muhammara {
|
|
|
89
280
|
right: number,
|
|
90
281
|
top: number,
|
|
91
282
|
): this;
|
|
283
|
+
/**
|
|
284
|
+
* Writes the modified page.
|
|
285
|
+
* @returns This modifier.
|
|
286
|
+
* @throws {TypeError} If the page cannot be written.
|
|
287
|
+
* @throws {TypeError} If the modifier was not created with a writer.
|
|
288
|
+
*/
|
|
92
289
|
writePage(): this;
|
|
93
290
|
}
|
|
94
291
|
|
|
95
|
-
|
|
292
|
+
/** Image or document format reported by `getImageType()`. */
|
|
293
|
+
export const PDFImageType: {
|
|
294
|
+
readonly PDF: "PDF";
|
|
295
|
+
readonly JPG: "JPG";
|
|
296
|
+
readonly TIFF: "TIFF";
|
|
297
|
+
readonly PNG: "PNG";
|
|
298
|
+
};
|
|
299
|
+
export type PDFImageType = (typeof PDFImageType)[keyof typeof PDFImageType];
|
|
96
300
|
|
|
97
301
|
export interface PDFRStreamForFile extends ReadStream {
|
|
302
|
+
/**
|
|
303
|
+
* Opens a file for reading.
|
|
304
|
+
* @param inPath - The file path.
|
|
305
|
+
* @throws {Error} If the file cannot be opened or read.
|
|
306
|
+
*/
|
|
98
307
|
new (inPath: FilePath): PDFRStreamForFile;
|
|
308
|
+
/**
|
|
309
|
+
* Reads the next bytes from the file.
|
|
310
|
+
* @param inAmount - The maximum number of bytes to read.
|
|
311
|
+
* @returns The bytes read; shorter than requested at the end.
|
|
312
|
+
*/
|
|
313
|
+
read(inAmount: number): Buffer;
|
|
314
|
+
/**
|
|
315
|
+
* Closes the file.
|
|
316
|
+
* @param inCallback - Called once the file is closed.
|
|
317
|
+
*/
|
|
99
318
|
close(inCallback?: () => void): void;
|
|
319
|
+
/**
|
|
320
|
+
* Sets the offset that later positions are counted from.
|
|
321
|
+
* @param inPosition - The absolute byte offset of the start.
|
|
322
|
+
*/
|
|
323
|
+
moveStartPosition(inPosition: number): void;
|
|
100
324
|
}
|
|
101
325
|
|
|
102
326
|
export interface PDFRStreamForBuffer extends ReadStream {
|
|
327
|
+
/**
|
|
328
|
+
* Creates a read stream over a buffer.
|
|
329
|
+
* @param buffer - The bytes to read.
|
|
330
|
+
*/
|
|
103
331
|
new (buffer: Buffer): PDFRStreamForBuffer;
|
|
332
|
+
/**
|
|
333
|
+
* Reads a copy of the next bytes.
|
|
334
|
+
* @param inAmount - The maximum number of bytes to read.
|
|
335
|
+
* @returns The bytes read; shorter than requested at the end.
|
|
336
|
+
*/
|
|
337
|
+
read(inAmount: number): Buffer;
|
|
338
|
+
/**
|
|
339
|
+
* Sets the offset that later positions are counted from.
|
|
340
|
+
* @param inPosition - The absolute byte offset of the start.
|
|
341
|
+
*/
|
|
342
|
+
moveStartPosition(inPosition: number): void;
|
|
104
343
|
}
|
|
105
344
|
|
|
345
|
+
/** Device color space of a drawing color option. */
|
|
346
|
+
export const DeviceColorSpace: {
|
|
347
|
+
readonly RGB: "rgb";
|
|
348
|
+
readonly GRAY: "gray";
|
|
349
|
+
readonly CMYK: "cmyk";
|
|
350
|
+
};
|
|
351
|
+
export type DeviceColorSpace =
|
|
352
|
+
(typeof DeviceColorSpace)[keyof typeof DeviceColorSpace];
|
|
353
|
+
|
|
106
354
|
export interface ColorOptions {
|
|
107
|
-
|
|
355
|
+
/**
|
|
356
|
+
* A DeviceColorSpace value. A `gray` or `cmyk` color must be a number; a
|
|
357
|
+
* color name or `#rrggbb` string is RGB and throws a `TypeError` with them.
|
|
358
|
+
*/
|
|
359
|
+
colorspace?: DeviceColorSpace;
|
|
108
360
|
color?: string | number;
|
|
109
361
|
}
|
|
110
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Paint operation a drawing helper finishes its path with. `"stroke"` is the
|
|
365
|
+
* default when `type` is omitted, `"fill"` fills the path, and `"clip"`
|
|
366
|
+
* intersects the clipping region without painting; scope it with q()/Q().
|
|
367
|
+
* `null` selects no paint operation and ends the path unpainted.
|
|
368
|
+
*/
|
|
369
|
+
/** Paint operations for the `type` option of the drawing helpers. */
|
|
370
|
+
export const DrawingPathType: {
|
|
371
|
+
readonly STROKE: "stroke";
|
|
372
|
+
readonly FILL: "fill";
|
|
373
|
+
readonly CLIP: "clip";
|
|
374
|
+
};
|
|
375
|
+
export type DrawingPathType =
|
|
376
|
+
(typeof DrawingPathType)[keyof typeof DrawingPathType] | null;
|
|
377
|
+
|
|
111
378
|
export interface GraphicOptions extends ColorOptions {
|
|
112
|
-
|
|
113
|
-
type?: "stroke" | "fill" | "clip";
|
|
379
|
+
type?: DrawingPathType;
|
|
114
380
|
width?: number;
|
|
115
381
|
close?: boolean;
|
|
116
382
|
}
|
|
@@ -125,7 +391,13 @@ declare namespace muhammara {
|
|
|
125
391
|
|
|
126
392
|
export type LineJoinStyle = 0 | 1 | 2;
|
|
127
393
|
|
|
128
|
-
|
|
394
|
+
/** How text-showing operators encode string text. */
|
|
395
|
+
export const EEncoding: {
|
|
396
|
+
readonly TEXT: "text";
|
|
397
|
+
readonly CODE: "code";
|
|
398
|
+
readonly HEX: "hex";
|
|
399
|
+
};
|
|
400
|
+
export type EEncoding = (typeof EEncoding)[keyof typeof EEncoding];
|
|
129
401
|
|
|
130
402
|
export const LineCapStyle: {
|
|
131
403
|
readonly LINECAP_BUTT: 0;
|
|
@@ -141,90 +413,605 @@ declare namespace muhammara {
|
|
|
141
413
|
export type Glyph = Array<[number, number]>;
|
|
142
414
|
|
|
143
415
|
export interface AbstractContentContext {
|
|
416
|
+
/**
|
|
417
|
+
* Closes, fills (nonzero winding) and strokes the path; operator b.
|
|
418
|
+
* @returns This context.
|
|
419
|
+
* @throws {TypeError} If there is no content context.
|
|
420
|
+
*/
|
|
144
421
|
b(): this;
|
|
422
|
+
/**
|
|
423
|
+
* Fills (nonzero winding) and strokes the path; operator B.
|
|
424
|
+
* @returns This context.
|
|
425
|
+
* @throws {TypeError} If there is no content context.
|
|
426
|
+
*/
|
|
145
427
|
B(): this;
|
|
428
|
+
/**
|
|
429
|
+
* Closes, fills (even-odd) and strokes the path; operator b*.
|
|
430
|
+
* @returns This context.
|
|
431
|
+
* @throws {TypeError} If there is no content context.
|
|
432
|
+
*/
|
|
146
433
|
bStar(): this;
|
|
434
|
+
/**
|
|
435
|
+
* Fills (even-odd) and strokes the path; operator B*.
|
|
436
|
+
* @returns This context.
|
|
437
|
+
* @throws {TypeError} If there is no content context.
|
|
438
|
+
*/
|
|
147
439
|
BStar(): this;
|
|
440
|
+
/**
|
|
441
|
+
* Closes and strokes the path; operator s.
|
|
442
|
+
* @returns This context.
|
|
443
|
+
* @throws {TypeError} If there is no content context.
|
|
444
|
+
*/
|
|
148
445
|
s(): this;
|
|
446
|
+
/**
|
|
447
|
+
* Strokes the path; operator S.
|
|
448
|
+
* @returns This context.
|
|
449
|
+
* @throws {TypeError} If there is no content context.
|
|
450
|
+
*/
|
|
149
451
|
S(): this;
|
|
452
|
+
/**
|
|
453
|
+
* Fills the path (nonzero winding); operator f.
|
|
454
|
+
* @returns This context.
|
|
455
|
+
* @throws {TypeError} If there is no content context.
|
|
456
|
+
*/
|
|
150
457
|
f(): this;
|
|
458
|
+
/**
|
|
459
|
+
* Fills the path (nonzero winding); operator F, the obsolete form of f.
|
|
460
|
+
* @returns This context.
|
|
461
|
+
* @throws {TypeError} If there is no content context.
|
|
462
|
+
*/
|
|
151
463
|
F(): this;
|
|
464
|
+
/**
|
|
465
|
+
* Fills the path (even-odd); operator f*.
|
|
466
|
+
* @returns This context.
|
|
467
|
+
* @throws {TypeError} If there is no content context.
|
|
468
|
+
*/
|
|
152
469
|
fStar(): this;
|
|
470
|
+
/**
|
|
471
|
+
* Ends the path without painting it, for clipping; operator n.
|
|
472
|
+
* @returns This context.
|
|
473
|
+
* @throws {TypeError} If there is no content context.
|
|
474
|
+
*/
|
|
153
475
|
n(): this;
|
|
476
|
+
/**
|
|
477
|
+
* Starts a subpath; operator m.
|
|
478
|
+
* @param x - The x coordinate.
|
|
479
|
+
* @param y - The y coordinate.
|
|
480
|
+
* @returns This context.
|
|
481
|
+
* @throws {TypeError} If the arguments are not 2 numbers.
|
|
482
|
+
* @throws {TypeError} If there is no content context.
|
|
483
|
+
*/
|
|
154
484
|
m(x: PosX, y: PosY): this;
|
|
485
|
+
/**
|
|
486
|
+
* Adds a line to the path; operator l.
|
|
487
|
+
* @param x - The x coordinate.
|
|
488
|
+
* @param y - The y coordinate.
|
|
489
|
+
* @returns This context.
|
|
490
|
+
* @throws {TypeError} If the arguments are not 2 numbers.
|
|
491
|
+
* @throws {TypeError} If there is no content context.
|
|
492
|
+
*/
|
|
155
493
|
l(x: PosX, y: PosY): this;
|
|
494
|
+
/**
|
|
495
|
+
* Adds a cubic Bezier curve; operator c.
|
|
496
|
+
* @param x1 - The first control point x.
|
|
497
|
+
* @param y1 - The first control point y.
|
|
498
|
+
* @param x2 - The second control point x.
|
|
499
|
+
* @param y2 - The second control point y.
|
|
500
|
+
* @param x3 - The end point x.
|
|
501
|
+
* @param y3 - The end point y.
|
|
502
|
+
* @returns This context.
|
|
503
|
+
* @throws {TypeError} If the arguments are not 6 numbers.
|
|
504
|
+
* @throws {TypeError} If there is no content context.
|
|
505
|
+
*/
|
|
156
506
|
c(x1: PosX, y1: PosY, x2: PosX, y2: PosY, x3: PosX, y3: PosY): this;
|
|
507
|
+
/**
|
|
508
|
+
* Adds a Bezier curve whose first control point is the current point;
|
|
509
|
+
* operator v.
|
|
510
|
+
* @param x2 - The second control point x.
|
|
511
|
+
* @param y2 - The second control point y.
|
|
512
|
+
* @param x3 - The end point x.
|
|
513
|
+
* @param y3 - The end point y.
|
|
514
|
+
* @returns This context.
|
|
515
|
+
* @throws {TypeError} If the arguments are not 4 numbers.
|
|
516
|
+
* @throws {TypeError} If there is no content context.
|
|
517
|
+
*/
|
|
157
518
|
v(x2: PosX, y2: PosY, x3: PosX, y3: PosY): this;
|
|
519
|
+
/**
|
|
520
|
+
* Adds a Bezier curve whose second control point is the end point;
|
|
521
|
+
* operator y.
|
|
522
|
+
* @param x1 - The first control point x.
|
|
523
|
+
* @param y1 - The first control point y.
|
|
524
|
+
* @param x3 - The end point x.
|
|
525
|
+
* @param y3 - The end point y.
|
|
526
|
+
* @returns This context.
|
|
527
|
+
* @throws {TypeError} If the arguments are not 4 numbers.
|
|
528
|
+
* @throws {TypeError} If there is no content context.
|
|
529
|
+
*/
|
|
158
530
|
y(x1: PosX, y1: PosY, x3: PosX, y3: PosY): this;
|
|
531
|
+
/**
|
|
532
|
+
* Closes the current subpath; operator h.
|
|
533
|
+
* @returns This context.
|
|
534
|
+
* @throws {TypeError} If there is no content context.
|
|
535
|
+
*/
|
|
159
536
|
h(): this;
|
|
537
|
+
/**
|
|
538
|
+
* Adds a rectangle to the path; operator re.
|
|
539
|
+
* @param left - The left edge.
|
|
540
|
+
* @param bottom - The bottom edge.
|
|
541
|
+
* @param width - The width.
|
|
542
|
+
* @param height - The height.
|
|
543
|
+
* @returns This context.
|
|
544
|
+
* @throws {TypeError} If the arguments are not 4 numbers.
|
|
545
|
+
* @throws {TypeError} If there is no content context.
|
|
546
|
+
*/
|
|
160
547
|
re(left: number, bottom: number, width: Width, height: Height): this;
|
|
548
|
+
/**
|
|
549
|
+
* Saves the graphics state; operator q.
|
|
550
|
+
* @returns This context.
|
|
551
|
+
* @throws {TypeError} If there is no content context.
|
|
552
|
+
*/
|
|
161
553
|
q(): this;
|
|
554
|
+
/**
|
|
555
|
+
* Restores the graphics state; operator Q.
|
|
556
|
+
* @returns This context.
|
|
557
|
+
* @throws {TypeError} If there is no content context.
|
|
558
|
+
*/
|
|
162
559
|
Q(): this;
|
|
163
560
|
/**
|
|
164
|
-
* a
|
|
165
|
-
* c d 0
|
|
166
|
-
* e f
|
|
561
|
+
* Concatenates a matrix to the current transformation; operator cm. The
|
|
562
|
+
* matrix is [a b 0, c d 0, e f 1].
|
|
563
|
+
* @param args - The matrix values a, b, c, d, e and f.
|
|
564
|
+
* @returns This context.
|
|
565
|
+
* @throws {TypeError} If the arguments are not 6 numbers.
|
|
566
|
+
* @throws {TypeError} If there is no content context.
|
|
167
567
|
*/
|
|
168
568
|
cm(...args: TransformationMatrix): this;
|
|
569
|
+
/**
|
|
570
|
+
* Sets the line width; operator w.
|
|
571
|
+
* @param lineWidth - The width in user units.
|
|
572
|
+
* @returns This context.
|
|
573
|
+
* @throws {TypeError} If lineWidth is not a single number.
|
|
574
|
+
* @throws {TypeError} If there is no content context.
|
|
575
|
+
*/
|
|
169
576
|
w(lineWidth: Width): this;
|
|
577
|
+
/**
|
|
578
|
+
* Sets the line cap style; operator J.
|
|
579
|
+
* @param lineCapStyle - A LineCapStyle value.
|
|
580
|
+
* @returns This context.
|
|
581
|
+
* @throws {TypeError} If lineCapStyle is not a single number.
|
|
582
|
+
* @throws {TypeError} If there is no content context.
|
|
583
|
+
*/
|
|
170
584
|
J(lineCapStyle: LineCapStyle): this;
|
|
585
|
+
/**
|
|
586
|
+
* Sets the line join style; operator j.
|
|
587
|
+
* @param lineJoinStyle - 0 miter, 1 round or 2 bevel.
|
|
588
|
+
* @returns This context.
|
|
589
|
+
* @throws {TypeError} If lineJoinStyle is not a single number.
|
|
590
|
+
* @throws {TypeError} If there is no content context.
|
|
591
|
+
*/
|
|
171
592
|
j(lineJoinStyle: LineJoinStyle): this;
|
|
593
|
+
/**
|
|
594
|
+
* Sets the miter limit; operator M.
|
|
595
|
+
* @param miterLimit - The miter limit.
|
|
596
|
+
* @returns This context.
|
|
597
|
+
* @throws {TypeError} If miterLimit is not a single number.
|
|
598
|
+
* @throws {TypeError} If there is no content context.
|
|
599
|
+
*/
|
|
172
600
|
M(miterLimit: number): this;
|
|
173
|
-
|
|
601
|
+
/**
|
|
602
|
+
* Sets the dash pattern; operator d. Values are truncated to integers.
|
|
603
|
+
* @param dashArray - Alternating dash and gap lengths; empty for a solid line.
|
|
604
|
+
* @param dashPhase - The offset into the pattern; 0 when omitted.
|
|
605
|
+
* @returns This context.
|
|
606
|
+
* @throws {TypeError} If dashArray is not an array or dashPhase is not a
|
|
607
|
+
* number.
|
|
608
|
+
* @throws {TypeError} If there is no content context.
|
|
609
|
+
*/
|
|
610
|
+
d(dashArray: number[], dashPhase?: number): this;
|
|
611
|
+
/**
|
|
612
|
+
* Sets the rendering intent; operator ri.
|
|
613
|
+
* @param renderingIntentName - The intent, for example Perceptual.
|
|
614
|
+
* @returns This context.
|
|
615
|
+
* @throws {TypeError} If renderingIntentName is not a single string.
|
|
616
|
+
* @throws {TypeError} If there is no content context.
|
|
617
|
+
*/
|
|
174
618
|
ri(renderingIntentName: string): this;
|
|
619
|
+
/**
|
|
620
|
+
* Sets the flatness tolerance; operator i. The value is truncated to an
|
|
621
|
+
* integer.
|
|
622
|
+
* @param flatness - The tolerance, 0 to 100.
|
|
623
|
+
* @returns This context.
|
|
624
|
+
* @throws {TypeError} If flatness is not a single number.
|
|
625
|
+
* @throws {TypeError} If there is no content context.
|
|
626
|
+
*/
|
|
175
627
|
i(flatness: number): this;
|
|
628
|
+
/**
|
|
629
|
+
* Applies a graphics state resource; operator gs.
|
|
630
|
+
* @param graphicStateName - The ExtGState resource name.
|
|
631
|
+
* @returns This context.
|
|
632
|
+
* @throws {TypeError} If graphicStateName is not a single string.
|
|
633
|
+
* @throws {TypeError} If there is no content context.
|
|
634
|
+
*/
|
|
176
635
|
gs(graphicStateName: string): this;
|
|
636
|
+
/**
|
|
637
|
+
* Sets the fill and stroke opacity through a graphics state resource.
|
|
638
|
+
* @param opacity - The opacity, 0 to 1.
|
|
639
|
+
* @returns This context.
|
|
640
|
+
* @throws {TypeError} If opacity is not a single number from 0 to 1.
|
|
641
|
+
* @throws {TypeError} If there is no content context.
|
|
642
|
+
*/
|
|
177
643
|
setOpacity(opacity: number): this;
|
|
644
|
+
/**
|
|
645
|
+
* Sets the stroke color space; operator CS.
|
|
646
|
+
* @param colorSpaceName - A color space name or resource name.
|
|
647
|
+
* @returns This context.
|
|
648
|
+
* @throws {TypeError} If colorSpaceName is not a single string.
|
|
649
|
+
* @throws {TypeError} If there is no content context.
|
|
650
|
+
*/
|
|
178
651
|
CS(colorSpaceName: string): this;
|
|
652
|
+
/**
|
|
653
|
+
* Sets the fill color space; operator cs.
|
|
654
|
+
* @param colorSpaceName - A color space name or resource name.
|
|
655
|
+
* @returns This context.
|
|
656
|
+
* @throws {TypeError} If colorSpaceName is not a single string.
|
|
657
|
+
* @throws {TypeError} If there is no content context.
|
|
658
|
+
*/
|
|
179
659
|
cs(colorSpaceName: string): this;
|
|
660
|
+
/**
|
|
661
|
+
* Sets the stroke color in the current color space; operator SC.
|
|
662
|
+
* @param colorComponents - The components, each 0 to 1.
|
|
663
|
+
* @returns This context.
|
|
664
|
+
* @throws {TypeError} If no component is given.
|
|
665
|
+
* @throws {TypeError} If there is no content context.
|
|
666
|
+
*/
|
|
180
667
|
SC(...colorComponents: number[]): this;
|
|
668
|
+
/**
|
|
669
|
+
* Sets the stroke color, optionally with a pattern; operator SCN. Pass
|
|
670
|
+
* the components as arguments or as one array, then an optional pattern name. A pattern
|
|
671
|
+
* name alone selects a colored (PaintType 1) pattern.
|
|
672
|
+
* @param parameters - The components and an optional pattern name.
|
|
673
|
+
* @returns This context.
|
|
674
|
+
* @throws {TypeError} If the arguments are neither components nor components and a pattern name.
|
|
675
|
+
* @throws {TypeError} If there is no content context.
|
|
676
|
+
*/
|
|
181
677
|
SCN(...parameters: any[]): this; // This can't be materialized in TypeScript
|
|
182
678
|
////SCN(...colorComponents: number[], patternName?: string): this;
|
|
183
679
|
SCN(colorComponents: number[], patternName?: string): this;
|
|
680
|
+
SCN(patternName: string): this;
|
|
681
|
+
/**
|
|
682
|
+
* Sets the fill color in the current color space; operator sc.
|
|
683
|
+
* @param colorComponents - The components, each 0 to 1.
|
|
684
|
+
* @returns This context.
|
|
685
|
+
* @throws {TypeError} If no component is given.
|
|
686
|
+
* @throws {TypeError} If there is no content context.
|
|
687
|
+
*/
|
|
184
688
|
sc(...colorComponents: number[]): this;
|
|
689
|
+
/**
|
|
690
|
+
* Sets the fill color, optionally with a pattern; operator scn. Pass the
|
|
691
|
+
* components as arguments or as one array, then an optional pattern name. A pattern
|
|
692
|
+
* name alone selects a colored (PaintType 1) pattern.
|
|
693
|
+
* @param parameters - The components and an optional pattern name.
|
|
694
|
+
* @returns This context.
|
|
695
|
+
* @throws {TypeError} If the arguments are neither components nor components and a pattern name.
|
|
696
|
+
* @throws {TypeError} If there is no content context.
|
|
697
|
+
*/
|
|
185
698
|
scn(...parameters: any[]): this; // This can't be materialized in TypeScript
|
|
186
699
|
////scn(...colorComponents: number[], patternName?: string): this;
|
|
187
700
|
scn(colorComponents: number[], patternName?: string): this;
|
|
701
|
+
scn(patternName: string): this;
|
|
702
|
+
/**
|
|
703
|
+
* Sets a gray stroke color; operator G.
|
|
704
|
+
* @param gray - The gray level, 0 (black) to 1 (white).
|
|
705
|
+
* @returns This context.
|
|
706
|
+
* @throws {TypeError} If gray is not a single number.
|
|
707
|
+
* @throws {TypeError} If there is no content context.
|
|
708
|
+
*/
|
|
188
709
|
G(gray: number): this;
|
|
710
|
+
/**
|
|
711
|
+
* Sets a gray fill color; operator g.
|
|
712
|
+
* @param gray - The gray level, 0 (black) to 1 (white).
|
|
713
|
+
* @returns This context.
|
|
714
|
+
* @throws {TypeError} If gray is not a single number.
|
|
715
|
+
* @throws {TypeError} If there is no content context.
|
|
716
|
+
*/
|
|
189
717
|
g(gray: number): this;
|
|
718
|
+
/**
|
|
719
|
+
* Sets an RGB stroke color; operator RG.
|
|
720
|
+
* @param r - Red, 0 to 1.
|
|
721
|
+
* @param g - Green, 0 to 1.
|
|
722
|
+
* @param b - Blue, 0 to 1.
|
|
723
|
+
* @returns This context.
|
|
724
|
+
* @throws {TypeError} If the arguments are not 3 numbers.
|
|
725
|
+
* @throws {TypeError} If there is no content context.
|
|
726
|
+
*/
|
|
190
727
|
RG(r: number, g: number, b: number): this;
|
|
728
|
+
/**
|
|
729
|
+
* Sets an RGB fill color; operator rg.
|
|
730
|
+
* @param r - Red, 0 to 1.
|
|
731
|
+
* @param g - Green, 0 to 1.
|
|
732
|
+
* @param b - Blue, 0 to 1.
|
|
733
|
+
* @returns This context.
|
|
734
|
+
* @throws {TypeError} If the arguments are not 3 numbers.
|
|
735
|
+
* @throws {TypeError} If there is no content context.
|
|
736
|
+
*/
|
|
191
737
|
rg(r: number, g: number, b: number): this;
|
|
738
|
+
/**
|
|
739
|
+
* Sets a CMYK stroke color; operator K.
|
|
740
|
+
* @param c - Cyan, 0 to 1.
|
|
741
|
+
* @param m - Magenta, 0 to 1.
|
|
742
|
+
* @param y - Yellow, 0 to 1.
|
|
743
|
+
* @param k - Black, 0 to 1.
|
|
744
|
+
* @returns This context.
|
|
745
|
+
* @throws {TypeError} If the arguments are not 4 numbers.
|
|
746
|
+
* @throws {TypeError} If there is no content context.
|
|
747
|
+
*/
|
|
192
748
|
K(c: number, m: number, y: number, k: number): this;
|
|
749
|
+
/**
|
|
750
|
+
* Sets a CMYK fill color; operator k.
|
|
751
|
+
* @param c - Cyan, 0 to 1.
|
|
752
|
+
* @param m - Magenta, 0 to 1.
|
|
753
|
+
* @param y - Yellow, 0 to 1.
|
|
754
|
+
* @param k - Black, 0 to 1.
|
|
755
|
+
* @returns This context.
|
|
756
|
+
* @throws {TypeError} If the arguments are not 4 numbers.
|
|
757
|
+
* @throws {TypeError} If there is no content context.
|
|
758
|
+
*/
|
|
193
759
|
k(c: number, m: number, y: number, k: number): this;
|
|
760
|
+
/**
|
|
761
|
+
* Clips to the path (nonzero winding); operator W. Follow it with n.
|
|
762
|
+
* @returns This context.
|
|
763
|
+
* @throws {TypeError} If there is no content context.
|
|
764
|
+
*/
|
|
194
765
|
W(): this;
|
|
766
|
+
/**
|
|
767
|
+
* Clips to the path (even-odd); operator W*. Follow it with n.
|
|
768
|
+
* @returns This context.
|
|
769
|
+
* @throws {TypeError} If there is no content context.
|
|
770
|
+
*/
|
|
195
771
|
WStar(): this;
|
|
196
|
-
|
|
772
|
+
/**
|
|
773
|
+
* Draws an XObject; operator Do. A form or image is added to the
|
|
774
|
+
* resources.
|
|
775
|
+
* @param xObject - A resource name, a form or image, or a form object ID.
|
|
776
|
+
* @returns This context.
|
|
777
|
+
* @throws {TypeError} If xObject is not a single XObject, name or ID.
|
|
778
|
+
* @throws {TypeError} If there is no content context.
|
|
779
|
+
*/
|
|
780
|
+
doXObject(
|
|
781
|
+
xObject: string | FormXObjectId | FormXObject | ImageXObject,
|
|
782
|
+
): this;
|
|
783
|
+
/**
|
|
784
|
+
* Sets the character spacing; operator Tc.
|
|
785
|
+
* @param characterSpace - The extra space per character in text space units.
|
|
786
|
+
* @returns This context.
|
|
787
|
+
* @throws {TypeError} If characterSpace is not a single number.
|
|
788
|
+
* @throws {TypeError} If there is no content context.
|
|
789
|
+
*/
|
|
197
790
|
Tc(characterSpace: number): this;
|
|
791
|
+
/**
|
|
792
|
+
* Sets the word spacing; operator Tw.
|
|
793
|
+
* @param wordSpace - The extra space per space character in text space units.
|
|
794
|
+
* @returns This context.
|
|
795
|
+
* @throws {TypeError} If wordSpace is not a single number.
|
|
796
|
+
* @throws {TypeError} If there is no content context.
|
|
797
|
+
*/
|
|
198
798
|
Tw(wordSpace: number): this;
|
|
799
|
+
/**
|
|
800
|
+
* Sets the horizontal scaling; operator Tz. The value is truncated to an
|
|
801
|
+
* integer.
|
|
802
|
+
* @param horizontalScaling - The scaling in percent; 100 is normal.
|
|
803
|
+
* @returns This context.
|
|
804
|
+
* @throws {TypeError} If horizontalScaling is not a single number.
|
|
805
|
+
* @throws {TypeError} If there is no content context.
|
|
806
|
+
*/
|
|
199
807
|
Tz(horizontalScaling: number): this;
|
|
808
|
+
/**
|
|
809
|
+
* Sets the text leading used by T*, ' and "; operator TL.
|
|
810
|
+
* @param textLeading - The leading in text space units.
|
|
811
|
+
* @returns This context.
|
|
812
|
+
* @throws {TypeError} If textLeading is not a single number.
|
|
813
|
+
* @throws {TypeError} If there is no content context.
|
|
814
|
+
*/
|
|
200
815
|
TL(textLeading: number): this;
|
|
816
|
+
/**
|
|
817
|
+
* Sets the text rendering mode; operator Tr.
|
|
818
|
+
* @param renderingMode - 0 fill to 7 clip, as in ISO 32000-1 table 106.
|
|
819
|
+
* @returns This context.
|
|
820
|
+
* @throws {TypeError} If renderingMode is not a single number.
|
|
821
|
+
* @throws {TypeError} If there is no content context.
|
|
822
|
+
*/
|
|
201
823
|
Tr(renderingMode: number): this;
|
|
824
|
+
/**
|
|
825
|
+
* Sets the text rise; operator Ts.
|
|
826
|
+
* @param fontRise - The baseline shift in text space units.
|
|
827
|
+
* @returns This context.
|
|
828
|
+
* @throws {TypeError} If fontRise is not a single number.
|
|
829
|
+
* @throws {TypeError} If there is no content context.
|
|
830
|
+
*/
|
|
202
831
|
Ts(fontRise: number): this;
|
|
832
|
+
/**
|
|
833
|
+
* Begins a text object; operator BT.
|
|
834
|
+
* @returns This context.
|
|
835
|
+
* @throws {TypeError} If there is no content context.
|
|
836
|
+
*/
|
|
203
837
|
BT(): this;
|
|
838
|
+
/**
|
|
839
|
+
* Ends a text object; operator ET.
|
|
840
|
+
* @returns This context.
|
|
841
|
+
* @throws {TypeError} If there is no content context.
|
|
842
|
+
*/
|
|
204
843
|
ET(): this;
|
|
844
|
+
/**
|
|
845
|
+
* Moves to the start of the next line by an offset; operator Td.
|
|
846
|
+
* @param tX - The horizontal offset.
|
|
847
|
+
* @param tY - The vertical offset.
|
|
848
|
+
* @returns This context.
|
|
849
|
+
* @throws {TypeError} If the arguments are not 2 numbers.
|
|
850
|
+
* @throws {TypeError} If there is no content context.
|
|
851
|
+
*/
|
|
205
852
|
Td(tX: number, tY: number): this;
|
|
853
|
+
/**
|
|
854
|
+
* Moves to the next line by an offset and sets the leading to -tY;
|
|
855
|
+
* operator TD.
|
|
856
|
+
* @param tX - The horizontal offset.
|
|
857
|
+
* @param tY - The vertical offset.
|
|
858
|
+
* @returns This context.
|
|
859
|
+
* @throws {TypeError} If the arguments are not 2 numbers.
|
|
860
|
+
* @throws {TypeError} If there is no content context.
|
|
861
|
+
*/
|
|
206
862
|
TD(tX: number, tY: number): this;
|
|
863
|
+
/**
|
|
864
|
+
* Sets the text matrix; operator Tm.
|
|
865
|
+
* @param a - The matrix value a.
|
|
866
|
+
* @param b - The matrix value b.
|
|
867
|
+
* @param c - The matrix value c.
|
|
868
|
+
* @param d - The matrix value d.
|
|
869
|
+
* @param e - The matrix value e.
|
|
870
|
+
* @param f - The matrix value f.
|
|
871
|
+
* @returns This context.
|
|
872
|
+
* @throws {TypeError} If the arguments are not 6 numbers.
|
|
873
|
+
* @throws {TypeError} If there is no content context.
|
|
874
|
+
*/
|
|
207
875
|
Tm(a: number, b: number, c: number, d: number, e: number, f: number): this;
|
|
876
|
+
/**
|
|
877
|
+
* Moves to the start of the next line; operator T*.
|
|
878
|
+
* @returns This context.
|
|
879
|
+
* @throws {TypeError} If there is no content context.
|
|
880
|
+
*/
|
|
208
881
|
TStar(): this;
|
|
882
|
+
/**
|
|
883
|
+
* Sets the font and size; operator Tf.
|
|
884
|
+
* @param fontReferenced - A font from getFontForFile(), or a font resource name.
|
|
885
|
+
* @param fontSize - The font size.
|
|
886
|
+
* @returns This context.
|
|
887
|
+
* @throws {TypeError} If the arguments are not a font or string and a number.
|
|
888
|
+
* @throws {TypeError} If there is no content context.
|
|
889
|
+
*/
|
|
209
890
|
Tf(fontReferenced: UsedFont | string, fontSize: number): this;
|
|
891
|
+
/**
|
|
892
|
+
* Shows text; operator Tj. Set a font with Tf() first.
|
|
893
|
+
* @param text - The text, or glyphs of the current font.
|
|
894
|
+
* @param options - Text encoding options.
|
|
895
|
+
* @returns This context.
|
|
896
|
+
* @throws {TypeError} If the arguments are wrong.
|
|
897
|
+
* @throws {TypeError} If there is no content context.
|
|
898
|
+
*/
|
|
899
|
+
Tj(text: string, options?: TextRenderOptions): this;
|
|
900
|
+
Tj(glyphs: Glyph): this;
|
|
210
901
|
Tj(text: string | Glyph): this;
|
|
902
|
+
/**
|
|
903
|
+
* Moves to the next line and shows text; operator '.
|
|
904
|
+
* @param text - The text, or glyphs of the current font.
|
|
905
|
+
* @param options - Text encoding options.
|
|
906
|
+
* @returns This context.
|
|
907
|
+
* @throws {TypeError} If the arguments are wrong.
|
|
908
|
+
* @throws {TypeError} If there is no content context.
|
|
909
|
+
*/
|
|
910
|
+
Quote(text: string, options?: TextRenderOptions): this;
|
|
911
|
+
Quote(glyphs: Glyph): this;
|
|
211
912
|
Quote(text: string | Glyph): this;
|
|
913
|
+
/**
|
|
914
|
+
* Sets word and character spacing, moves to the next line and shows text;
|
|
915
|
+
* operator ".
|
|
916
|
+
* @param wordSpacing - The word spacing.
|
|
917
|
+
* @param characterSpacing - The character spacing.
|
|
918
|
+
* @param text - The text, or glyphs of the current font.
|
|
919
|
+
* @param options - Text encoding options.
|
|
920
|
+
* @returns This context.
|
|
921
|
+
* @throws {TypeError} If the arguments are wrong.
|
|
922
|
+
* @throws {TypeError} If there is no content context.
|
|
923
|
+
*/
|
|
924
|
+
DoubleQuote(
|
|
925
|
+
wordSpacing: number,
|
|
926
|
+
characterSpacing: number,
|
|
927
|
+
text: string,
|
|
928
|
+
options?: TextRenderOptions,
|
|
929
|
+
): this;
|
|
930
|
+
DoubleQuote(
|
|
931
|
+
wordSpacing: number,
|
|
932
|
+
characterSpacing: number,
|
|
933
|
+
glyphs: Glyph,
|
|
934
|
+
): this;
|
|
212
935
|
DoubleQuote(
|
|
213
936
|
wordSpacing: number,
|
|
214
|
-
|
|
937
|
+
characterSpacing: number,
|
|
215
938
|
text: string | Glyph,
|
|
216
939
|
): this;
|
|
217
|
-
|
|
940
|
+
/**
|
|
941
|
+
* Shows text with kerning adjustments; operator TJ. Pass the array items
|
|
942
|
+
* as separate arguments: strings with numeric adjustments in thousandths of
|
|
943
|
+
* text space, optionally followed by options.
|
|
944
|
+
* @param items - The strings or glyphs and adjustments.
|
|
945
|
+
* @returns This context.
|
|
946
|
+
* @throws {TypeError} If an item is not a string, glyph list or number.
|
|
947
|
+
* @throws {TypeError} If there is no content context.
|
|
948
|
+
*/
|
|
949
|
+
TJ(...items: (string | number)[]): this;
|
|
950
|
+
TJ(
|
|
951
|
+
...items: [string | number, ...(string | number)[], TextRenderOptions]
|
|
952
|
+
): this;
|
|
953
|
+
/** Glyph variant: glyph lists with numeric kerning adjustments. */
|
|
954
|
+
TJ(...items: (Glyph | number)[]): this;
|
|
955
|
+
/**
|
|
956
|
+
* Writes content-stream code as given, unchecked.
|
|
957
|
+
* @param freeCode - The code.
|
|
958
|
+
* @returns This context.
|
|
959
|
+
* @throws {TypeError} If freeCode is not a single string.
|
|
960
|
+
* @throws {TypeError} If there is no content context.
|
|
961
|
+
*/
|
|
218
962
|
writeFreeCode(freeCode: string): this;
|
|
219
|
-
/**
|
|
963
|
+
/**
|
|
964
|
+
* Draws a path through points. Pass x, y numbers as arguments or one array
|
|
965
|
+
* of [x, y] pairs, then optional options. Invalid input emits no operators.
|
|
966
|
+
* @param parameters - The coordinates and optional options.
|
|
967
|
+
* @returns This context.
|
|
968
|
+
* @throws {TypeError} If fewer than two complete finite coordinate pairs are
|
|
969
|
+
* given.
|
|
970
|
+
* @throws {TypeError} If there is no content context.
|
|
971
|
+
* @throws {TypeError} If `options.type` is not "stroke", "fill", "clip" or null.
|
|
972
|
+
*/
|
|
220
973
|
drawPath(...parameters: any[]): this; // This can't be materialized in TypeScript
|
|
221
974
|
////drawPath(...xyPairs: number[], options: GraphicOptions): this;
|
|
222
975
|
drawPath(xyPairs: Array<[number, number]>, options: GraphicOptions): this;
|
|
223
|
-
/**
|
|
976
|
+
/**
|
|
977
|
+
* Draws a circle.
|
|
978
|
+
* @param x - The center x.
|
|
979
|
+
* @param y - The center y.
|
|
980
|
+
* @param r - The radius.
|
|
981
|
+
* @param options - The paint type, color and line width.
|
|
982
|
+
* @returns This context.
|
|
983
|
+
* @throws {TypeError} If fewer than 3 arguments are given, or the coordinates,
|
|
984
|
+
* radius or calculated geometry are not finite.
|
|
985
|
+
* @throws {TypeError} If there is no content context.
|
|
986
|
+
* @throws {TypeError} If `options.type` is not "stroke", "fill", "clip" or null.
|
|
987
|
+
*/
|
|
224
988
|
drawCircle(x: PosX, y: PosY, r: number, options?: GraphicOptions): this;
|
|
225
|
-
/**
|
|
989
|
+
/**
|
|
990
|
+
* Draws a square.
|
|
991
|
+
* @param x - The left edge.
|
|
992
|
+
* @param y - The bottom edge.
|
|
993
|
+
* @param l - The edge length.
|
|
994
|
+
* @param options - The paint type, color and line width.
|
|
995
|
+
* @returns This context.
|
|
996
|
+
* @throws {TypeError} If fewer than 3 arguments are given or a value is not
|
|
997
|
+
* finite.
|
|
998
|
+
* @throws {TypeError} If there is no content context.
|
|
999
|
+
* @throws {TypeError} If `options.type` is not "stroke", "fill", "clip" or null.
|
|
1000
|
+
*/
|
|
226
1001
|
drawSquare(x: PosX, y: PosY, l: number, options?: GraphicOptions): this;
|
|
227
|
-
/**
|
|
1002
|
+
/**
|
|
1003
|
+
* Draws a rectangle.
|
|
1004
|
+
* @param x - The left edge.
|
|
1005
|
+
* @param y - The bottom edge.
|
|
1006
|
+
* @param w - The width.
|
|
1007
|
+
* @param h - The height.
|
|
1008
|
+
* @param options - The paint type, color and line width.
|
|
1009
|
+
* @returns This context.
|
|
1010
|
+
* @throws {TypeError} If fewer than 4 arguments are given or a value is not
|
|
1011
|
+
* finite.
|
|
1012
|
+
* @throws {TypeError} If there is no content context.
|
|
1013
|
+
* @throws {TypeError} If `options.type` is not "stroke", "fill", "clip" or null.
|
|
1014
|
+
*/
|
|
228
1015
|
drawRectangle(
|
|
229
1016
|
x: PosX,
|
|
230
1017
|
y: PosY,
|
|
@@ -232,8 +1019,29 @@ declare namespace muhammara {
|
|
|
232
1019
|
h: number,
|
|
233
1020
|
options?: GraphicOptions,
|
|
234
1021
|
): this;
|
|
235
|
-
/**
|
|
1022
|
+
/**
|
|
1023
|
+
* Writes a line of text with its own text object.
|
|
1024
|
+
* @param text - The text.
|
|
1025
|
+
* @param x - The baseline start x.
|
|
1026
|
+
* @param y - The baseline y.
|
|
1027
|
+
* @param options - The font, size, color, underline and strike-out.
|
|
1028
|
+
* @returns This context.
|
|
1029
|
+
* @throws {TypeError} If fewer than 3 arguments are given, or the coordinates,
|
|
1030
|
+
* font size or underline geometry are not finite.
|
|
1031
|
+
* @throws {TypeError} If there is no content context.
|
|
1032
|
+
*/
|
|
236
1033
|
writeText(text: string, x: PosX, y: PosY, options?: WriteTextOptions): this;
|
|
1034
|
+
/**
|
|
1035
|
+
* Draws an image file: JPEG, PNG, TIFF or a PDF page.
|
|
1036
|
+
* @param x - The left edge.
|
|
1037
|
+
* @param y - The bottom edge.
|
|
1038
|
+
* @param imagePath - The image path.
|
|
1039
|
+
* @param options - The image index, transformation and PDF password.
|
|
1040
|
+
* @returns This context.
|
|
1041
|
+
* @throws {TypeError} If the arguments are not 2 numbers, a string and an
|
|
1042
|
+
* optional object. An image that cannot be read draws nothing.
|
|
1043
|
+
* @throws {TypeError} If there is no content context.
|
|
1044
|
+
*/
|
|
237
1045
|
drawImage(
|
|
238
1046
|
x: PosX,
|
|
239
1047
|
y: PosY,
|
|
@@ -242,11 +1050,21 @@ declare namespace muhammara {
|
|
|
242
1050
|
): this;
|
|
243
1051
|
}
|
|
244
1052
|
|
|
1053
|
+
/** When `drawImage()` scales an image into its transformation box. */
|
|
1054
|
+
export const ImageFit: {
|
|
1055
|
+
/** Always scale the image to the box. */
|
|
1056
|
+
readonly ALWAYS: "always";
|
|
1057
|
+
/** Scale only an image larger than the box. */
|
|
1058
|
+
readonly OVERFLOW: "overflow";
|
|
1059
|
+
};
|
|
1060
|
+
export type ImageFit = (typeof ImageFit)[keyof typeof ImageFit];
|
|
1061
|
+
|
|
245
1062
|
export interface TransformationObject {
|
|
246
1063
|
width: number;
|
|
247
1064
|
height: number;
|
|
248
1065
|
proportional?: boolean;
|
|
249
|
-
|
|
1066
|
+
/** ImageFit.OVERFLOW when omitted. */
|
|
1067
|
+
fit?: ImageFit;
|
|
250
1068
|
}
|
|
251
1069
|
|
|
252
1070
|
export interface ImageOptions {
|
|
@@ -262,23 +1080,56 @@ declare namespace muhammara {
|
|
|
262
1080
|
|
|
263
1081
|
export interface WriteTextOptions extends FontOptions, ColorOptions {
|
|
264
1082
|
underline?: boolean;
|
|
265
|
-
strikeOut?: boolean;
|
|
266
|
-
lineWidth?: number;
|
|
267
1083
|
}
|
|
268
1084
|
|
|
269
1085
|
export interface XObjectContentContext extends AbstractContentContext {}
|
|
270
1086
|
|
|
271
1087
|
export interface PDFWStreamForFile extends WriteStream {
|
|
1088
|
+
/**
|
|
1089
|
+
* Creates a write stream to a file, replacing an existing one.
|
|
1090
|
+
* @param inPath - The file path.
|
|
1091
|
+
*/
|
|
272
1092
|
new (inPath: string): PDFWStreamForFile;
|
|
1093
|
+
/**
|
|
1094
|
+
* Writes bytes to the file.
|
|
1095
|
+
* @param inBytes - The bytes to write; an array of byte values is also
|
|
1096
|
+
* accepted when called directly.
|
|
1097
|
+
* @returns The number of bytes written.
|
|
1098
|
+
*/
|
|
1099
|
+
write(inBytes: Buffer | number[]): number;
|
|
1100
|
+
/**
|
|
1101
|
+
* Flushes and closes the file.
|
|
1102
|
+
* @param inCallback - Called once the file is closed.
|
|
1103
|
+
*/
|
|
273
1104
|
close(inCallback?: () => void): void;
|
|
274
1105
|
}
|
|
275
1106
|
|
|
276
1107
|
export interface PDFStreamForResponse extends WriteStream {
|
|
1108
|
+
/**
|
|
1109
|
+
* Creates a write stream that writes to an HTTP response.
|
|
1110
|
+
* @param res - The response, or any writable stream.
|
|
1111
|
+
*/
|
|
277
1112
|
new (res: NodeJS.WritableStream): PDFStreamForResponse;
|
|
1113
|
+
/**
|
|
1114
|
+
* Writes bytes to the response.
|
|
1115
|
+
* @param inBytes - The bytes to write; an array of byte values is also
|
|
1116
|
+
* accepted when called directly.
|
|
1117
|
+
* @returns The number of bytes written.
|
|
1118
|
+
*/
|
|
1119
|
+
write(inBytes: Buffer | number[]): number;
|
|
278
1120
|
}
|
|
279
1121
|
|
|
280
1122
|
export interface PDFWStreamForBuffer extends WriteStream {
|
|
1123
|
+
/** Creates a write stream that collects the bytes in memory. */
|
|
281
1124
|
new (): PDFWStreamForBuffer;
|
|
1125
|
+
/**
|
|
1126
|
+
* Writes bytes to the buffer.
|
|
1127
|
+
* @param inBytes - The bytes to write; an array of byte values is also
|
|
1128
|
+
* accepted when called directly.
|
|
1129
|
+
* @returns The number of bytes written.
|
|
1130
|
+
*/
|
|
1131
|
+
write(inBytes: Buffer | number[]): number;
|
|
1132
|
+
/** The bytes written so far; null before the first write. */
|
|
282
1133
|
buffer: Buffer | null;
|
|
283
1134
|
}
|
|
284
1135
|
|
|
@@ -294,7 +1145,7 @@ declare namespace muhammara {
|
|
|
294
1145
|
modifiedFilePath?: string;
|
|
295
1146
|
modifiedStream?: PDFRStreamForFile; // TODO
|
|
296
1147
|
/** Log file path or synchronous byte writer returning the number of bytes written. */
|
|
297
|
-
log?: string |
|
|
1148
|
+
log?: string | LogStream;
|
|
298
1149
|
}
|
|
299
1150
|
|
|
300
1151
|
export interface PDFRecryptOptions extends PDFWriterOptions {
|
|
@@ -332,6 +1183,12 @@ declare namespace muhammara {
|
|
|
332
1183
|
export const ePDFObjectStream = 10;
|
|
333
1184
|
export const ePDFObjectSymbol = 11;
|
|
334
1185
|
export type PDFObjectType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
1186
|
+
/**
|
|
1187
|
+
* Returns the name of a PDF object type.
|
|
1188
|
+
* @param type - One of the ePDFObject* constants.
|
|
1189
|
+
* @returns The label, for example Dictionary.
|
|
1190
|
+
* @throws {TypeError} If type is not a single valid type number.
|
|
1191
|
+
*/
|
|
335
1192
|
export function getTypeLabel(type: PDFObjectType): string;
|
|
336
1193
|
|
|
337
1194
|
export const ePDFPageContentItemText = 0;
|
|
@@ -350,7 +1207,15 @@ declare namespace muhammara {
|
|
|
350
1207
|
export const ePDFPageBoxTrimBox = 3;
|
|
351
1208
|
export const ePDFPageBoxArtBox = 4;
|
|
352
1209
|
export type PDFPageBoxType = 0 | 1 | 2 | 3 | 4;
|
|
353
|
-
|
|
1210
|
+
/** Page box names. */
|
|
1211
|
+
export const PageBox: {
|
|
1212
|
+
readonly MEDIA: "media";
|
|
1213
|
+
readonly CROP: "crop";
|
|
1214
|
+
readonly BLEED: "bleed";
|
|
1215
|
+
readonly TRIM: "trim";
|
|
1216
|
+
readonly ART: "art";
|
|
1217
|
+
};
|
|
1218
|
+
export type PageBox = (typeof PageBox)[keyof typeof PageBox];
|
|
354
1219
|
|
|
355
1220
|
export const eRangeTypeAll = 0;
|
|
356
1221
|
export const eRangeTypeSpecific = 1;
|
|
@@ -370,20 +1235,93 @@ declare namespace muhammara {
|
|
|
370
1235
|
|
|
371
1236
|
export interface FormXObject {
|
|
372
1237
|
id: FormXObjectId;
|
|
373
|
-
|
|
1238
|
+
/**
|
|
1239
|
+
* Returns the content context for drawing on the form.
|
|
1240
|
+
* @returns The content context.
|
|
1241
|
+
*/
|
|
1242
|
+
getContentContext(): XObjectContentContext;
|
|
1243
|
+
/**
|
|
1244
|
+
* Returns the form content stream.
|
|
1245
|
+
* @returns The stream.
|
|
1246
|
+
*/
|
|
1247
|
+
getContentStream(): PDFStream;
|
|
1248
|
+
/**
|
|
1249
|
+
* Returns the form resources.
|
|
1250
|
+
* @returns The resources dictionary.
|
|
1251
|
+
*/
|
|
1252
|
+
getResourcesDictionary(): ResourcesDictionary;
|
|
1253
|
+
}
|
|
374
1254
|
|
|
375
1255
|
export interface ResourcesDictionary {
|
|
376
|
-
|
|
1256
|
+
/**
|
|
1257
|
+
* Adds a form XObject to the resources and returns its resource name.
|
|
1258
|
+
* @param formXObjectId - The object ID.
|
|
1259
|
+
* @returns The resource name to use in content-stream operators.
|
|
1260
|
+
* @throws {TypeError} If formXObjectId is not a single number.
|
|
1261
|
+
*/
|
|
1262
|
+
addFormXObjectMapping(formXObjectId: FormXObjectId): string;
|
|
1263
|
+
/**
|
|
1264
|
+
* Adds an image XObject to the resources and returns its resource name.
|
|
1265
|
+
* @param imageXObject - The image, or its object ID.
|
|
1266
|
+
* @returns The resource name to use in content-stream operators.
|
|
1267
|
+
* @throws {TypeError} If imageXObject is neither an image nor a number.
|
|
1268
|
+
*/
|
|
377
1269
|
addImageXObjectMapping(imageXObject: ImageXObject | number): string;
|
|
1270
|
+
/**
|
|
1271
|
+
* Adds a procedure set name to the ProcSet array.
|
|
1272
|
+
* @param procSetName - The procedure set, for example PDF or Text.
|
|
1273
|
+
* @throws {TypeError} If procSetName is not a single string.
|
|
1274
|
+
*/
|
|
378
1275
|
addProcsetResource(procSetName: string): void;
|
|
1276
|
+
/**
|
|
1277
|
+
* Adds a graphics state dictionary to the resources and returns its resource name.
|
|
1278
|
+
* @param stateObjectId - The object ID.
|
|
1279
|
+
* @returns The resource name to use in content-stream operators.
|
|
1280
|
+
* @throws {TypeError} If stateObjectId is not a single number.
|
|
1281
|
+
*/
|
|
379
1282
|
addExtGStateMapping(stateObjectId: number): string;
|
|
1283
|
+
/**
|
|
1284
|
+
* Adds a font to the resources and returns its resource name.
|
|
1285
|
+
* @param fontObjectId - The object ID.
|
|
1286
|
+
* @returns The resource name to use in content-stream operators.
|
|
1287
|
+
* @throws {TypeError} If fontObjectId is not a single number.
|
|
1288
|
+
*/
|
|
380
1289
|
addFontMapping(fontObjectId: number): string;
|
|
1290
|
+
/**
|
|
1291
|
+
* Adds a color space to the resources and returns its resource name.
|
|
1292
|
+
* @param colorSpaceId - The object ID.
|
|
1293
|
+
* @returns The resource name to use in content-stream operators.
|
|
1294
|
+
* @throws {TypeError} If colorSpaceId is not a single number.
|
|
1295
|
+
*/
|
|
381
1296
|
addColorSpaceMapping(colorSpaceId: number): string;
|
|
382
|
-
|
|
1297
|
+
/**
|
|
1298
|
+
* Adds a pattern to the resources and returns its resource name.
|
|
1299
|
+
* @param patternObjectId - The object ID.
|
|
1300
|
+
* @returns The resource name to use in content-stream operators.
|
|
1301
|
+
* @throws {TypeError} If patternObjectId is not a single number.
|
|
1302
|
+
*/
|
|
383
1303
|
addPatternMapping(patternObjectId: number): string;
|
|
1304
|
+
/**
|
|
1305
|
+
* Adds a marked-content property list to the resources and returns its resource name.
|
|
1306
|
+
* @param propertyObjectId - The object ID.
|
|
1307
|
+
* @returns The resource name to use in content-stream operators.
|
|
1308
|
+
* @throws {TypeError} If propertyObjectId is not a single number.
|
|
1309
|
+
*/
|
|
384
1310
|
addPropertyMapping(propertyObjectId: number): string;
|
|
1311
|
+
/**
|
|
1312
|
+
* Adds a XObject to the resources and returns its resource name.
|
|
1313
|
+
* @param xObjectId - The object ID.
|
|
1314
|
+
* @returns The resource name to use in content-stream operators.
|
|
1315
|
+
* @throws {TypeError} If xObjectId is not a single number.
|
|
1316
|
+
*/
|
|
385
1317
|
addXObjectMapping(xObjectId: number): string;
|
|
386
|
-
|
|
1318
|
+
/**
|
|
1319
|
+
* Adds a shading to the resources and returns its resource name.
|
|
1320
|
+
* @param shadingObjectId - The object ID.
|
|
1321
|
+
* @returns The resource name to use in content-stream operators.
|
|
1322
|
+
* @throws {TypeError} If shadingObjectId is not a single number.
|
|
1323
|
+
*/
|
|
1324
|
+
addShadingMapping(shadingObjectId: number): string;
|
|
387
1325
|
}
|
|
388
1326
|
|
|
389
1327
|
export type PDFBox = [PosX, PosY, Width, Height];
|
|
@@ -395,6 +1333,10 @@ declare namespace muhammara {
|
|
|
395
1333
|
trimBox?: PDFBox;
|
|
396
1334
|
artBox?: PDFBox;
|
|
397
1335
|
rotate?: number;
|
|
1336
|
+
/**
|
|
1337
|
+
* Returns the page resources.
|
|
1338
|
+
* @returns The resources dictionary.
|
|
1339
|
+
*/
|
|
398
1340
|
getResourcesDictionary(): ResourcesDictionary;
|
|
399
1341
|
}
|
|
400
1342
|
|
|
@@ -407,9 +1349,12 @@ declare namespace muhammara {
|
|
|
407
1349
|
height: number;
|
|
408
1350
|
}
|
|
409
1351
|
|
|
410
|
-
/**
|
|
411
|
-
|
|
412
|
-
|
|
1352
|
+
/**
|
|
1353
|
+
* A text-showing operation in a page content stream, as returned when
|
|
1354
|
+
* `extractPageText()` is called with `{ decodeText: false }`.
|
|
1355
|
+
*/
|
|
1356
|
+
export interface PDFRawTextElement {
|
|
1357
|
+
/** Raw character codes from the content stream, one byte per code unit. */
|
|
413
1358
|
content: string;
|
|
414
1359
|
/** The page resource name selected by the most recent Tf operation. */
|
|
415
1360
|
fontResource: string;
|
|
@@ -418,6 +1363,29 @@ declare namespace muhammara {
|
|
|
418
1363
|
textMatrix: [number, number, number, number, number, number];
|
|
419
1364
|
}
|
|
420
1365
|
|
|
1366
|
+
/** A text-showing operation in a page content stream, with decoded text. */
|
|
1367
|
+
export interface PDFTextElement extends PDFRawTextElement {
|
|
1368
|
+
/**
|
|
1369
|
+
* `content` decoded to Unicode through the active font: its `/ToUnicode`
|
|
1370
|
+
* CMap, then its simple-font `/Encoding` and `/Differences`. Codes the font
|
|
1371
|
+
* does not map become U+FFFD, as do codes of fonts whose built-in encoding
|
|
1372
|
+
* cannot be read, the Symbol and ZapfDingbats standard fonts, embedded Type
|
|
1373
|
+
* 1 fonts without `/Encoding`, and Type 3 fonts, unless `/ToUnicode` or
|
|
1374
|
+
* `/Differences` maps them, and every byte shown without a font or with a
|
|
1375
|
+
* font that cannot be resolved or read.
|
|
1376
|
+
*/
|
|
1377
|
+
text: string;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
/** Options for `PDFReader#extractPageText()`. */
|
|
1381
|
+
export interface PDFTextExtractionOptions {
|
|
1382
|
+
/**
|
|
1383
|
+
* Decode each element's `text` through its font. Defaults to true; false
|
|
1384
|
+
* leaves `text` out and skips reading the page's fonts.
|
|
1385
|
+
*/
|
|
1386
|
+
decodeText?: boolean;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
421
1389
|
/** A content-stream operation that produces a page mark. */
|
|
422
1390
|
export interface PDFPageContentItem {
|
|
423
1391
|
type: PDFPageContentItemType;
|
|
@@ -446,59 +1414,221 @@ declare namespace muhammara {
|
|
|
446
1414
|
}
|
|
447
1415
|
|
|
448
1416
|
export interface UsedFont {
|
|
1417
|
+
/**
|
|
1418
|
+
* Measures a string, or a list of glyph ids.
|
|
1419
|
+
* @param text - The text, or the glyph ids.
|
|
1420
|
+
* @param fontSize - The font size; 1 when omitted.
|
|
1421
|
+
* @returns The bounding box of the text at that size.
|
|
1422
|
+
* @throws {TypeError} If text is not a string or glyph id array, or
|
|
1423
|
+
* fontSize is not a number.
|
|
1424
|
+
*/
|
|
449
1425
|
calculateTextDimensions(
|
|
450
|
-
text: string |
|
|
451
|
-
fontSize
|
|
1426
|
+
text: string | number[],
|
|
1427
|
+
fontSize?: number,
|
|
452
1428
|
): TextDimension;
|
|
453
|
-
|
|
1429
|
+
/**
|
|
1430
|
+
* Returns the font metrics scaled to a font size.
|
|
1431
|
+
* @param fontSize - The font size; 1 when omitted.
|
|
1432
|
+
* @returns The ascent, descent and related metrics.
|
|
1433
|
+
* @throws {TypeError} If more than one argument is given or the metrics
|
|
1434
|
+
* cannot be read.
|
|
1435
|
+
*/
|
|
1436
|
+
getFontMetrics(fontSize?: number): FontMetrics;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
export interface FontMetrics {
|
|
1440
|
+
pixelsPerEm: { x: number; y: number; xScale: number; yScale: number };
|
|
1441
|
+
ascender: number;
|
|
1442
|
+
descender: number;
|
|
1443
|
+
height: number;
|
|
1444
|
+
max_advance: number;
|
|
454
1445
|
}
|
|
455
1446
|
|
|
456
1447
|
export interface ByteWriter {
|
|
457
|
-
|
|
1448
|
+
/**
|
|
1449
|
+
* Writes bytes to the stream.
|
|
1450
|
+
* @param buffer - The bytes to write.
|
|
1451
|
+
* @returns The number of bytes written.
|
|
1452
|
+
* @throws {TypeError} If buffer is not a single Uint8Array or byte array.
|
|
1453
|
+
*/
|
|
1454
|
+
write(buffer: Uint8Array | number[]): number;
|
|
458
1455
|
}
|
|
459
1456
|
|
|
460
1457
|
export interface ByteReader {
|
|
461
|
-
|
|
1458
|
+
/**
|
|
1459
|
+
* Reads the next bytes.
|
|
1460
|
+
* @param length - The maximum number of bytes to read.
|
|
1461
|
+
* @returns The bytes read; shorter than requested at the end.
|
|
1462
|
+
* @throws {TypeError} If length is not a single number.
|
|
1463
|
+
* @throws {Error} If the reader has no stream.
|
|
1464
|
+
*/
|
|
1465
|
+
read(length: number): Buffer;
|
|
1466
|
+
/**
|
|
1467
|
+
* Tells whether bytes remain.
|
|
1468
|
+
* @returns True while the end has not been reached.
|
|
1469
|
+
* @throws {Error} If the reader has no stream.
|
|
1470
|
+
*/
|
|
462
1471
|
notEnded(): boolean;
|
|
463
1472
|
}
|
|
464
1473
|
|
|
465
1474
|
export interface ByteReaderWithPosition {
|
|
466
|
-
|
|
1475
|
+
/**
|
|
1476
|
+
* Reads the next bytes.
|
|
1477
|
+
* @param length - The maximum number of bytes to read.
|
|
1478
|
+
* @returns The bytes read; shorter than requested at the end.
|
|
1479
|
+
* @throws {TypeError} If length is not a single number.
|
|
1480
|
+
*/
|
|
1481
|
+
read(length: number): Buffer;
|
|
1482
|
+
/**
|
|
1483
|
+
* Tells whether bytes remain.
|
|
1484
|
+
* @returns True while the end has not been reached.
|
|
1485
|
+
*/
|
|
467
1486
|
notEnded(): boolean;
|
|
1487
|
+
/**
|
|
1488
|
+
* Returns the current position.
|
|
1489
|
+
* @returns The byte offset.
|
|
1490
|
+
*/
|
|
468
1491
|
getCurrentPosition(): number;
|
|
1492
|
+
/**
|
|
1493
|
+
* Advances the position without reading.
|
|
1494
|
+
* @param length - The number of bytes to skip.
|
|
1495
|
+
* @returns This reader.
|
|
1496
|
+
* @throws {TypeError} If length is not a single number.
|
|
1497
|
+
*/
|
|
469
1498
|
skip(length: number): this;
|
|
1499
|
+
/**
|
|
1500
|
+
* Moves to a position.
|
|
1501
|
+
* @param position - The byte offset.
|
|
1502
|
+
* @returns This reader.
|
|
1503
|
+
* @throws {TypeError} If position is not a single number.
|
|
1504
|
+
*/
|
|
470
1505
|
setPosition(position: number): this;
|
|
471
|
-
|
|
1506
|
+
/**
|
|
1507
|
+
* Moves to a position counted back from the end.
|
|
1508
|
+
* @param position - The number of bytes before the end.
|
|
1509
|
+
* @returns This reader.
|
|
1510
|
+
* @throws {TypeError} If position is not a single number.
|
|
1511
|
+
*/
|
|
472
1512
|
setPositionFromEnd(position: number): this;
|
|
473
1513
|
}
|
|
474
1514
|
|
|
475
1515
|
export interface PDFReader {
|
|
1516
|
+
/**
|
|
1517
|
+
* Ends the reader and closes its file; later calls throw. Safe to repeat.
|
|
1518
|
+
* @returns This reader.
|
|
1519
|
+
*/
|
|
476
1520
|
end(): PDFReader;
|
|
1521
|
+
/**
|
|
1522
|
+
* Returns the PDF version from the file header, for example 1.7.
|
|
1523
|
+
* @returns The PDF version.
|
|
1524
|
+
* @throws {TypeError} If the reader has ended.
|
|
1525
|
+
*/
|
|
477
1526
|
getPDFLevel(): number;
|
|
1527
|
+
/**
|
|
1528
|
+
* Returns the number of pages.
|
|
1529
|
+
* @returns The page count.
|
|
1530
|
+
* @throws {TypeError} If the reader has ended.
|
|
1531
|
+
*/
|
|
478
1532
|
getPagesCount(): number;
|
|
1533
|
+
/**
|
|
1534
|
+
* Returns the trailer dictionary.
|
|
1535
|
+
* @returns The trailer; undefined when the file has none.
|
|
1536
|
+
* @throws {TypeError} If the reader has ended.
|
|
1537
|
+
*/
|
|
479
1538
|
getTrailer(): PDFDictionary;
|
|
1539
|
+
/**
|
|
1540
|
+
* Returns a dictionary value, resolving an indirect reference.
|
|
1541
|
+
* @param dictionary - The dictionary to read.
|
|
1542
|
+
* @param name - The key, without a leading slash.
|
|
1543
|
+
* @returns The value; undefined when the key is missing.
|
|
1544
|
+
* @throws {TypeError} If the reader has ended or the arguments are not a
|
|
1545
|
+
* dictionary and a string.
|
|
1546
|
+
*/
|
|
480
1547
|
queryDictionaryObject(dictionary: PDFDictionary, name: string): PDFObject;
|
|
1548
|
+
/**
|
|
1549
|
+
* Returns an array item, resolving an indirect reference.
|
|
1550
|
+
* @param objectList - The array to read.
|
|
1551
|
+
* @param index - The zero-based item index.
|
|
1552
|
+
* @returns The item; undefined when the index is out of range.
|
|
1553
|
+
* @throws {TypeError} If the reader has ended or the arguments are not an
|
|
1554
|
+
* array and a number.
|
|
1555
|
+
*/
|
|
481
1556
|
queryArrayObject(
|
|
482
1557
|
objectList: PDFArray,
|
|
483
1558
|
index: number,
|
|
484
1559
|
): undefined | PDFObject;
|
|
1560
|
+
/**
|
|
1561
|
+
* Parses an indirect object by its ID.
|
|
1562
|
+
* @param objectId - The object ID.
|
|
1563
|
+
* @returns The parsed object.
|
|
1564
|
+
* @throws {TypeError} If the reader has ended, objectId is not a non-negative
|
|
1565
|
+
* integer, or the object cannot be read.
|
|
1566
|
+
*/
|
|
485
1567
|
parseNewObject(objectId: number): PDFObject;
|
|
486
|
-
|
|
1568
|
+
/**
|
|
1569
|
+
* Returns the object ID of a page.
|
|
1570
|
+
* @param pageIndex - The zero-based page index.
|
|
1571
|
+
* @returns The page object ID; 0 when the page does not exist.
|
|
1572
|
+
* @throws {TypeError} If the reader has ended or pageIndex is not a
|
|
1573
|
+
* non-negative integer.
|
|
1574
|
+
*/
|
|
1575
|
+
getPageObjectID(pageIndex: number): number;
|
|
1576
|
+
/**
|
|
1577
|
+
* Parses a page dictionary.
|
|
1578
|
+
* @param pageIndex - The zero-based page index.
|
|
1579
|
+
* @returns The page dictionary.
|
|
1580
|
+
* @throws {TypeError} If the reader has ended.
|
|
1581
|
+
* @throws {TypeError} If pageIndex is not a non-negative integer or the page
|
|
1582
|
+
* cannot be read.
|
|
1583
|
+
*/
|
|
487
1584
|
parsePageDictionary(pageIndex: number): PDFDictionary;
|
|
1585
|
+
/**
|
|
1586
|
+
* Parses a page with helpers for its boxes and rotation.
|
|
1587
|
+
* @param pageIndex - The zero-based page index.
|
|
1588
|
+
* @returns The page.
|
|
1589
|
+
* @throws {TypeError} If the reader has ended.
|
|
1590
|
+
* @throws {TypeError} If pageIndex is not a non-negative integer or the page
|
|
1591
|
+
* cannot be read.
|
|
1592
|
+
*/
|
|
488
1593
|
parsePage(pageIndex: number): PDFPageInput;
|
|
489
1594
|
/**
|
|
490
|
-
* Returns text-showing operations in PDF content-stream drawing order.
|
|
491
|
-
*
|
|
1595
|
+
* Returns text-showing operations in PDF content-stream drawing order. Each
|
|
1596
|
+
* element's `text` is decoded through the active font and `content` keeps
|
|
1597
|
+
* the raw character codes. Glyph bounds are not calculated. Font decoding
|
|
1598
|
+
* caches each font per reader but charges every call the font's cost: it
|
|
1599
|
+
* ignores a `/ToUnicode` CMap over 4 MiB or beyond 32 MiB per call, and
|
|
1600
|
+
* counts the PDF objects it reads against `maxParsedObjects` on their own,
|
|
1601
|
+
* so results never depend on earlier calls.
|
|
492
1602
|
*
|
|
493
1603
|
* Throws when the page exceeds the extraction budget. `limits` may only
|
|
494
1604
|
* tighten the defaults: higher values are clamped to the built-in ceilings
|
|
495
1605
|
* of 1,000,000 content objects, 100,000 text operations, 1024 operands, and
|
|
496
1606
|
* 16 MiB of text.
|
|
1607
|
+
* @param pageIndex - The zero-based page index.
|
|
1608
|
+
* @param limits - Tighter extraction limits.
|
|
1609
|
+
* @param options - `{ decodeText: false }` skips font decoding and leaves
|
|
1610
|
+
* `text` out.
|
|
1611
|
+
* @returns The text elements in drawing order.
|
|
1612
|
+
* @throws {TypeError} If the arguments are not a page index, an optional
|
|
1613
|
+
* limits object, and optional options, or the page cannot be read.
|
|
1614
|
+
* @throws {RangeError} If a limit is not a positive 32-bit integer.
|
|
1615
|
+
* @throws {Error} If the page exceeds the extraction limits.
|
|
497
1616
|
*/
|
|
498
1617
|
extractPageText(
|
|
499
1618
|
pageIndex: number,
|
|
500
1619
|
limits?: PDFExtractionLimits,
|
|
1620
|
+
options?: PDFTextExtractionOptions & { decodeText?: true },
|
|
501
1621
|
): PDFTextElement[];
|
|
1622
|
+
extractPageText(
|
|
1623
|
+
pageIndex: number,
|
|
1624
|
+
limits: PDFExtractionLimits | undefined,
|
|
1625
|
+
options: PDFTextExtractionOptions & { decodeText: false },
|
|
1626
|
+
): PDFRawTextElement[];
|
|
1627
|
+
extractPageText(
|
|
1628
|
+
pageIndex: number,
|
|
1629
|
+
limits?: PDFExtractionLimits,
|
|
1630
|
+
options?: PDFTextExtractionOptions,
|
|
1631
|
+
): PDFRawTextElement[];
|
|
502
1632
|
/**
|
|
503
1633
|
* Returns every direct content-stream operation that produces a page mark.
|
|
504
1634
|
* White-on-white content is included; non-painting operations are excluded.
|
|
@@ -506,34 +1636,109 @@ declare namespace muhammara {
|
|
|
506
1636
|
* Shares `extractPageText`'s budget and clamping. `limits.maxTextBytes` is
|
|
507
1637
|
* accepted for signature parity but has no effect here, because items carry
|
|
508
1638
|
* an operator name rather than extracted text.
|
|
1639
|
+
* @param pageIndex - The zero-based page index.
|
|
1640
|
+
* @param limits - Tighter extraction limits.
|
|
1641
|
+
* @returns The content items in drawing order.
|
|
1642
|
+
* @throws {TypeError} If the arguments are not a page index and an optional
|
|
1643
|
+
* limits object, or the page cannot be read.
|
|
1644
|
+
* @throws {RangeError} If a limit is not a positive 32-bit integer.
|
|
1645
|
+
* @throws {Error} If the page exceeds the extraction limits.
|
|
509
1646
|
*/
|
|
510
1647
|
extractPageContentItems(
|
|
511
1648
|
pageIndex: number,
|
|
512
1649
|
limits?: PDFExtractionLimits,
|
|
513
1650
|
): PDFPageContentItem[];
|
|
1651
|
+
/**
|
|
1652
|
+
* Returns the number of objects in the cross-reference table.
|
|
1653
|
+
* @returns The object count.
|
|
1654
|
+
* @throws {TypeError} If the reader has ended.
|
|
1655
|
+
*/
|
|
514
1656
|
getObjectsCount(): number;
|
|
1657
|
+
/**
|
|
1658
|
+
* Tells whether the PDF is encrypted.
|
|
1659
|
+
* @returns True when the PDF is encrypted.
|
|
1660
|
+
* @throws {TypeError} If the reader has ended.
|
|
1661
|
+
*/
|
|
515
1662
|
isEncrypted(): boolean;
|
|
1663
|
+
/**
|
|
1664
|
+
* Returns the size of the cross-reference table.
|
|
1665
|
+
* @returns The number of cross-reference entries.
|
|
1666
|
+
* @throws {TypeError} If the reader has ended.
|
|
1667
|
+
*/
|
|
516
1668
|
getXrefSize(): number;
|
|
1669
|
+
/**
|
|
1670
|
+
* Returns the cross-reference entry of an object.
|
|
1671
|
+
* @param objectId - The object ID.
|
|
1672
|
+
* @returns The entry: byte position, revision and entry type.
|
|
1673
|
+
* @throws {TypeError} If the reader has ended, objectId is not a non-negative
|
|
1674
|
+
* integer, or it is out of range.
|
|
1675
|
+
*/
|
|
517
1676
|
getXrefEntry(objectId: number): {
|
|
518
1677
|
objectPosition: number;
|
|
519
1678
|
revision: number;
|
|
520
1679
|
type: number;
|
|
521
1680
|
};
|
|
1681
|
+
/**
|
|
1682
|
+
* Returns the byte position of the last cross-reference section.
|
|
1683
|
+
* @returns The byte position.
|
|
1684
|
+
* @throws {TypeError} If the reader has ended.
|
|
1685
|
+
*/
|
|
522
1686
|
getXrefPosition(): number;
|
|
1687
|
+
/**
|
|
1688
|
+
* Opens a stream's contents with its filters decoded.
|
|
1689
|
+
* @param inputStream - The stream to read.
|
|
1690
|
+
* @returns A reader over the decoded bytes.
|
|
1691
|
+
* @throws {TypeError} If the reader has ended or inputStream is not a stream.
|
|
1692
|
+
* @throws {Error} If the stream cannot be read.
|
|
1693
|
+
*/
|
|
523
1694
|
startReadingFromStream(inputStream: PDFStreamInput): ByteReader;
|
|
1695
|
+
/**
|
|
1696
|
+
* Opens a stream's contents as stored, decrypted but not decoded.
|
|
1697
|
+
* @param inputStream - The stream to read.
|
|
1698
|
+
* @returns A reader over the stored bytes.
|
|
1699
|
+
* @throws {TypeError} If the reader has ended or inputStream is not a stream.
|
|
1700
|
+
* @throws {Error} If the stream cannot be read.
|
|
1701
|
+
*/
|
|
524
1702
|
startReadingFromStreamForPlainCopying(
|
|
525
1703
|
inputStream: PDFStreamInput,
|
|
526
1704
|
): ByteReader;
|
|
1705
|
+
/**
|
|
1706
|
+
* Parses a content stream as a sequence of objects.
|
|
1707
|
+
* @param stream - The stream to parse.
|
|
1708
|
+
* @returns A parser returning one object per call.
|
|
1709
|
+
* @throws {TypeError} If the reader has ended or stream is not a stream.
|
|
1710
|
+
* @throws {Error} If the stream cannot be read.
|
|
1711
|
+
*/
|
|
527
1712
|
startReadingObjectsFromStream(stream: PDFStreamInput): PDFObjectParser;
|
|
1713
|
+
/**
|
|
1714
|
+
* Parses several content streams as one sequence of objects, as for a
|
|
1715
|
+
* page whose Contents is an array.
|
|
1716
|
+
* @param streams - The array of stream references.
|
|
1717
|
+
* @returns A parser returning one object per call.
|
|
1718
|
+
* @throws {TypeError} If the reader has ended or streams is not an array.
|
|
1719
|
+
*/
|
|
528
1720
|
startReadingObjectsFromStreams(streams: PDFArray): PDFObjectParser;
|
|
1721
|
+
/**
|
|
1722
|
+
* Returns the underlying stream the reader parses.
|
|
1723
|
+
* @returns The positioned byte reader.
|
|
1724
|
+
* @throws {TypeError} If the reader has ended.
|
|
1725
|
+
*/
|
|
529
1726
|
getParserStream(): ByteReaderWithPosition;
|
|
530
1727
|
}
|
|
531
1728
|
|
|
532
1729
|
export interface PDFObjectParser {
|
|
1730
|
+
/**
|
|
1731
|
+
* Parses the next object.
|
|
1732
|
+
* @returns The object; undefined at the end.
|
|
1733
|
+
*/
|
|
533
1734
|
parseNewObject(): PDFObject | undefined;
|
|
534
1735
|
}
|
|
535
1736
|
|
|
536
1737
|
export interface PDFStream {
|
|
1738
|
+
/**
|
|
1739
|
+
* Returns the writer for the stream contents.
|
|
1740
|
+
* @returns The byte writer.
|
|
1741
|
+
*/
|
|
537
1742
|
getWriteStream(): ByteWriter;
|
|
538
1743
|
}
|
|
539
1744
|
|
|
@@ -546,7 +1751,16 @@ declare namespace muhammara {
|
|
|
546
1751
|
}
|
|
547
1752
|
|
|
548
1753
|
export interface PDFLiteralString extends PDFObject {
|
|
1754
|
+
/**
|
|
1755
|
+
* Decodes the string as a PDF text string, PDFDocEncoding or UTF-16BE.
|
|
1756
|
+
* @returns The text.
|
|
1757
|
+
*/
|
|
549
1758
|
toText(): string;
|
|
1759
|
+
/**
|
|
1760
|
+
* Returns the raw bytes of the string.
|
|
1761
|
+
* @returns The byte values.
|
|
1762
|
+
*/
|
|
1763
|
+
toBytesArray(): number[];
|
|
550
1764
|
value: string;
|
|
551
1765
|
}
|
|
552
1766
|
|
|
@@ -555,7 +1769,15 @@ declare namespace muhammara {
|
|
|
555
1769
|
}
|
|
556
1770
|
|
|
557
1771
|
export interface PDFIndirectObjectReference extends PDFObject {
|
|
1772
|
+
/**
|
|
1773
|
+
* Returns the referenced object ID.
|
|
1774
|
+
* @returns The object ID.
|
|
1775
|
+
*/
|
|
558
1776
|
getObjectID(): number;
|
|
1777
|
+
/**
|
|
1778
|
+
* Returns the referenced generation number.
|
|
1779
|
+
* @returns The generation number.
|
|
1780
|
+
*/
|
|
559
1781
|
getVersion(): number;
|
|
560
1782
|
}
|
|
561
1783
|
|
|
@@ -564,13 +1786,39 @@ declare namespace muhammara {
|
|
|
564
1786
|
}
|
|
565
1787
|
|
|
566
1788
|
export interface PDFDictionary extends PDFObject {
|
|
567
|
-
|
|
1789
|
+
/**
|
|
1790
|
+
* Returns the entries, without resolving indirect references.
|
|
1791
|
+
* @returns The values by key.
|
|
1792
|
+
*/
|
|
1793
|
+
toJSObject(): { [key: string]: PDFObject };
|
|
1794
|
+
/**
|
|
1795
|
+
* Tells whether a key exists.
|
|
1796
|
+
* @param inName - The key, without a leading slash.
|
|
1797
|
+
* @returns True when the key exists.
|
|
1798
|
+
* @throws {TypeError} If inName is not a single string.
|
|
1799
|
+
*/
|
|
568
1800
|
exists(inName: string): boolean;
|
|
1801
|
+
/**
|
|
1802
|
+
* Returns a value, without resolving an indirect reference.
|
|
1803
|
+
* @param inName - The key, without a leading slash.
|
|
1804
|
+
* @returns The value.
|
|
1805
|
+
* @throws {TypeError} If inName is not a single string or the key is
|
|
1806
|
+
* missing.
|
|
1807
|
+
*/
|
|
569
1808
|
queryObject(inName: string): PDFObject;
|
|
570
1809
|
}
|
|
571
1810
|
|
|
572
1811
|
export interface PDFDate {
|
|
1812
|
+
/**
|
|
1813
|
+
* Returns the date in PDF date format, for example
|
|
1814
|
+
* D:20260926120000+02'00'.
|
|
1815
|
+
* @returns The PDF date string.
|
|
1816
|
+
*/
|
|
573
1817
|
toString(): string;
|
|
1818
|
+
/**
|
|
1819
|
+
* Sets the date to now.
|
|
1820
|
+
* @returns This date.
|
|
1821
|
+
*/
|
|
574
1822
|
setToCurrentTime(): this;
|
|
575
1823
|
}
|
|
576
1824
|
|
|
@@ -579,23 +1827,85 @@ declare namespace muhammara {
|
|
|
579
1827
|
}
|
|
580
1828
|
|
|
581
1829
|
export interface PDFArray extends PDFObject {
|
|
1830
|
+
/**
|
|
1831
|
+
* Returns the items, without resolving indirect references.
|
|
1832
|
+
* @returns The items as PDF objects.
|
|
1833
|
+
*/
|
|
582
1834
|
toJSArray(): Array<any>;
|
|
1835
|
+
/**
|
|
1836
|
+
* Returns an item, without resolving an indirect reference.
|
|
1837
|
+
* @param index - The zero-based item index.
|
|
1838
|
+
* @returns The item as a PDF object.
|
|
1839
|
+
* @throws {TypeError} If index is not a number or is out of range.
|
|
1840
|
+
*/
|
|
583
1841
|
queryObject(index: number): any;
|
|
1842
|
+
/**
|
|
1843
|
+
* Returns the number of items.
|
|
1844
|
+
* @returns The length.
|
|
1845
|
+
*/
|
|
584
1846
|
getLength(): number;
|
|
585
1847
|
}
|
|
586
1848
|
|
|
587
1849
|
export interface OutputFile {
|
|
1850
|
+
/**
|
|
1851
|
+
* Opens a file for writing.
|
|
1852
|
+
* @param filePath - The file path.
|
|
1853
|
+
* @param append - True to append to an existing file.
|
|
1854
|
+
* @throws {TypeError} If the arguments are wrong or the file cannot be
|
|
1855
|
+
* opened.
|
|
1856
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1857
|
+
*/
|
|
588
1858
|
openFile(filePath: FilePath, append?: boolean): void;
|
|
1859
|
+
/**
|
|
1860
|
+
* Closes the file.
|
|
1861
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1862
|
+
*/
|
|
589
1863
|
closeFile(): void;
|
|
1864
|
+
/**
|
|
1865
|
+
* Returns the path of the open file.
|
|
1866
|
+
* @returns The path; undefined when no file is open.
|
|
1867
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1868
|
+
*/
|
|
590
1869
|
getFilePath(): string | undefined;
|
|
1870
|
+
/**
|
|
1871
|
+
* Returns the writer of the open file.
|
|
1872
|
+
* @returns The writer; undefined when no file is open.
|
|
1873
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1874
|
+
*/
|
|
591
1875
|
getOutputStream(): ByteWriterWithPosition | undefined;
|
|
592
1876
|
}
|
|
593
1877
|
|
|
594
1878
|
export interface InputFile {
|
|
1879
|
+
/**
|
|
1880
|
+
* Opens a file for reading.
|
|
1881
|
+
* @param filePath - The file path.
|
|
1882
|
+
* @throws {TypeError} If filePath is not a single string or the file cannot
|
|
1883
|
+
* be opened.
|
|
1884
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1885
|
+
*/
|
|
595
1886
|
openFile(filePath: FilePath): void;
|
|
1887
|
+
/**
|
|
1888
|
+
* Closes the file.
|
|
1889
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1890
|
+
*/
|
|
596
1891
|
closeFile(): void;
|
|
1892
|
+
/**
|
|
1893
|
+
* Returns the path of the open file.
|
|
1894
|
+
* @returns The path; undefined when no file is open.
|
|
1895
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1896
|
+
*/
|
|
597
1897
|
getFilePath(): string | undefined;
|
|
1898
|
+
/**
|
|
1899
|
+
* Returns the size of the open file.
|
|
1900
|
+
* @returns The size in bytes; undefined when no file is open.
|
|
1901
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1902
|
+
*/
|
|
598
1903
|
getFileSize(): number | undefined;
|
|
1904
|
+
/**
|
|
1905
|
+
* Returns the reader of the open file.
|
|
1906
|
+
* @returns The reader; undefined when no file is open.
|
|
1907
|
+
* @throws {TypeError} If the file object was not obtained from a writer.
|
|
1908
|
+
*/
|
|
599
1909
|
getInputStream(): ByteReaderWithPosition | undefined;
|
|
600
1910
|
}
|
|
601
1911
|
|
|
@@ -605,13 +1915,60 @@ declare namespace muhammara {
|
|
|
605
1915
|
export const EInfoTrappedUnknown = 2;
|
|
606
1916
|
|
|
607
1917
|
export interface InfoDictionary {
|
|
1918
|
+
/**
|
|
1919
|
+
* Sets a custom info entry.
|
|
1920
|
+
* @param key - The entry key.
|
|
1921
|
+
* @param value - The entry text.
|
|
1922
|
+
* @throws {TypeError} If key and value are not two strings.
|
|
1923
|
+
* @throws {TypeError} If the dictionary was not obtained from a document
|
|
1924
|
+
* context.
|
|
1925
|
+
*/
|
|
608
1926
|
addAdditionalInfoEntry(key: string, value: string): void;
|
|
1927
|
+
/**
|
|
1928
|
+
* Removes a custom info entry.
|
|
1929
|
+
* @param key - The entry key.
|
|
1930
|
+
* @throws {TypeError} If key is not a single string.
|
|
1931
|
+
* @throws {TypeError} If the dictionary was not obtained from a document
|
|
1932
|
+
* context.
|
|
1933
|
+
*/
|
|
609
1934
|
removeAdditionalInfoEntry(key: string): void;
|
|
1935
|
+
/**
|
|
1936
|
+
* Removes every custom info entry.
|
|
1937
|
+
* @throws {TypeError} If the dictionary was not obtained from a document
|
|
1938
|
+
* context.
|
|
1939
|
+
*/
|
|
610
1940
|
clearAdditionalInfoEntries(): void;
|
|
1941
|
+
/**
|
|
1942
|
+
* Returns a custom info entry.
|
|
1943
|
+
* @param key - The entry key.
|
|
1944
|
+
* @returns The entry text; an empty string when it is not set.
|
|
1945
|
+
* @throws {TypeError} If key is not a single string.
|
|
1946
|
+
* @throws {TypeError} If the dictionary was not obtained from a document
|
|
1947
|
+
* context.
|
|
1948
|
+
*/
|
|
611
1949
|
getAdditionalInfoEntry(key: string): string;
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
1950
|
+
/**
|
|
1951
|
+
* Returns every additional Info entry.
|
|
1952
|
+
* @param key - Ignored; kept so 6.x calls that passed a key still compile.
|
|
1953
|
+
* @returns The entries by key.
|
|
1954
|
+
* @throws {TypeError} If the dictionary was not obtained from a document
|
|
1955
|
+
* context.
|
|
1956
|
+
*/
|
|
1957
|
+
getAdditionalInfoEntries(): { [key: string]: string };
|
|
1958
|
+
/**
|
|
1959
|
+
* Sets the creation date.
|
|
1960
|
+
* @param date - The date, a PDF date string, or a PDFDate to copy.
|
|
1961
|
+
* @throws {TypeError} If the dictionary was not obtained from a document
|
|
1962
|
+
* context.
|
|
1963
|
+
*/
|
|
1964
|
+
setCreationDate(date: string | Date | PDFDate): void;
|
|
1965
|
+
/**
|
|
1966
|
+
* Sets the modification date.
|
|
1967
|
+
* @param date - The date, a PDF date string, or a PDFDate to copy.
|
|
1968
|
+
* @throws {TypeError} If the dictionary was not obtained from a document
|
|
1969
|
+
* context.
|
|
1970
|
+
*/
|
|
1971
|
+
setModDate(date: string | Date | PDFDate): void;
|
|
615
1972
|
|
|
616
1973
|
title: string;
|
|
617
1974
|
author: string;
|
|
@@ -628,56 +1985,228 @@ declare namespace muhammara {
|
|
|
628
1985
|
|
|
629
1986
|
export interface FormObject {
|
|
630
1987
|
id: number;
|
|
1988
|
+
/**
|
|
1989
|
+
* Returns the content context for drawing on the form.
|
|
1990
|
+
* @returns The content context.
|
|
1991
|
+
*/
|
|
631
1992
|
getContentContext(): XObjectContentContext;
|
|
1993
|
+
/**
|
|
1994
|
+
* Misspelled alias of getResourcesDictionary().
|
|
1995
|
+
* @deprecated Use getResourcesDictionary().
|
|
1996
|
+
* @returns The resources dictionary.
|
|
1997
|
+
*/
|
|
632
1998
|
getResourcesDictinary(): ResourcesDictionary;
|
|
1999
|
+
/**
|
|
2000
|
+
* Returns the form resources.
|
|
2001
|
+
* @returns The resources dictionary.
|
|
2002
|
+
*/
|
|
633
2003
|
getResourcesDictionary(): ResourcesDictionary;
|
|
2004
|
+
/**
|
|
2005
|
+
* Returns the form content stream.
|
|
2006
|
+
* @returns The stream.
|
|
2007
|
+
*/
|
|
634
2008
|
getContentStream(): PDFStream;
|
|
635
2009
|
}
|
|
636
2010
|
|
|
637
2011
|
export interface DocumentCopyingContext {
|
|
2012
|
+
/**
|
|
2013
|
+
* Ends the copying context and releases its source; later calls throw.
|
|
2014
|
+
* @returns This context.
|
|
2015
|
+
*/
|
|
638
2016
|
end(): DocumentCopyingContext;
|
|
2017
|
+
/**
|
|
2018
|
+
* Creates a form XObject from a source page.
|
|
2019
|
+
* @param sourcePageIndex - The zero-based source page index.
|
|
2020
|
+
* @param ePDFPageBox - The page box to use, or an explicit [left, bottom,
|
|
2021
|
+
* right, top].
|
|
2022
|
+
* @param transformation - The form matrix.
|
|
2023
|
+
* @returns The form object ID.
|
|
2024
|
+
* @throws {TypeError} If the arguments are wrong or the page does not exist.
|
|
2025
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2026
|
+
*/
|
|
639
2027
|
createFormXObjectFromPDFPage(
|
|
640
2028
|
sourcePageIndex: number,
|
|
641
|
-
|
|
2029
|
+
/** Defaults to the media box. */
|
|
2030
|
+
ePDFPageBox?: PDFPageBoxType | PDFBox,
|
|
642
2031
|
transformation?: TransformationMatrix,
|
|
643
2032
|
): number;
|
|
2033
|
+
/**
|
|
2034
|
+
* Draws a source page onto a page of this document.
|
|
2035
|
+
* @param target - The target page.
|
|
2036
|
+
* @param sourcePageIndex - The zero-based source page index.
|
|
2037
|
+
* @throws {TypeError} If the arguments are not a page and a number, or the
|
|
2038
|
+
* source page does not exist.
|
|
2039
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2040
|
+
*/
|
|
644
2041
|
mergePDFPageToPage(target: PDFPage, sourcePageIndex: number): void;
|
|
645
|
-
|
|
2042
|
+
/**
|
|
2043
|
+
* Appends a source page as a new page.
|
|
2044
|
+
* @param sourcePageNumber - The zero-based source page index.
|
|
2045
|
+
* @returns The object ID of the new page.
|
|
2046
|
+
* @throws {TypeError} If the argument is not a number or the page does not
|
|
2047
|
+
* exist.
|
|
2048
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2049
|
+
*/
|
|
2050
|
+
appendPDFPageFromPDF(sourcePageNumber: number): number;
|
|
2051
|
+
/**
|
|
2052
|
+
* Draws a source page into a form XObject of this document.
|
|
2053
|
+
* @param targetForm - The target form.
|
|
2054
|
+
* @param sourcePageIndex - The zero-based source page index.
|
|
2055
|
+
* @throws {TypeError} If the arguments are not a form and a number, or the
|
|
2056
|
+
* source page does not exist.
|
|
2057
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2058
|
+
*/
|
|
646
2059
|
mergePDFPageToFormXObject(
|
|
647
|
-
|
|
648
|
-
|
|
2060
|
+
targetForm: FormXObject,
|
|
2061
|
+
sourcePageIndex: number,
|
|
649
2062
|
): void;
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
2063
|
+
/**
|
|
2064
|
+
* Returns the reader of the source document.
|
|
2065
|
+
* @returns The source document reader.
|
|
2066
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2067
|
+
*/
|
|
2068
|
+
getSourceDocumentParser(): PDFReader;
|
|
2069
|
+
/**
|
|
2070
|
+
* Writes a source object at the current output position, copying the
|
|
2071
|
+
* objects it references later.
|
|
2072
|
+
* @param objectToCopy - The source object.
|
|
2073
|
+
* @throws {TypeError} If objectToCopy is not a PDF object or cannot be copied.
|
|
2074
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2075
|
+
*/
|
|
654
2076
|
copyDirectObjectAsIs(objectToCopy: PDFObject): void;
|
|
2077
|
+
/**
|
|
2078
|
+
* Copies a source indirect object and the objects it references.
|
|
2079
|
+
* @param objectId - The source object ID.
|
|
2080
|
+
* @returns The object ID in this document.
|
|
2081
|
+
* @throws {TypeError} If objectId is not a number or the object cannot be
|
|
2082
|
+
* copied.
|
|
2083
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2084
|
+
*/
|
|
655
2085
|
copyObject(objectId: number): number;
|
|
2086
|
+
/**
|
|
2087
|
+
* Writes a source object at the current output position. The objects it
|
|
2088
|
+
* references are not copied yet; pass the returned IDs to
|
|
2089
|
+
* copyNewObjectsForDirectObject() once the current object ends.
|
|
2090
|
+
* @param objectToCopy - The source object.
|
|
2091
|
+
* @returns The source IDs of the referenced objects still to copy.
|
|
2092
|
+
* @throws {TypeError} If objectToCopy is not a PDF object or cannot be copied.
|
|
2093
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2094
|
+
*/
|
|
656
2095
|
copyDirectObjectWithDeepCopy(objectToCopy: PDFObject): Array<number>;
|
|
2096
|
+
/**
|
|
2097
|
+
* Copies the objects returned by copyDirectObjectWithDeepCopy().
|
|
2098
|
+
* @param objectIds - The source object IDs.
|
|
2099
|
+
* @throws {TypeError} If objectIds is not an array or the objects cannot be
|
|
2100
|
+
* copied.
|
|
2101
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2102
|
+
*/
|
|
657
2103
|
copyNewObjectsForDirectObject(objectIds: Array<number>): void;
|
|
2104
|
+
/**
|
|
2105
|
+
* Returns the ID in this document of an already copied source object.
|
|
2106
|
+
* @param objectId - The source object ID.
|
|
2107
|
+
* @returns The object ID in this document.
|
|
2108
|
+
* @throws {TypeError} If objectId is not a number or has not been copied.
|
|
2109
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2110
|
+
*/
|
|
658
2111
|
getCopiedObjectID(objectId: number): number;
|
|
2112
|
+
/**
|
|
2113
|
+
* Returns every copied source object ID with its ID in this document.
|
|
2114
|
+
* @returns The map from source object ID to object ID in this document.
|
|
2115
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2116
|
+
*/
|
|
659
2117
|
getCopiedObjects(): { [key: string]: number };
|
|
2118
|
+
/**
|
|
2119
|
+
* Makes later copies reference existing objects instead of copying the
|
|
2120
|
+
* given source objects.
|
|
2121
|
+
* @param replaceMap - The map from source object ID to object ID in this
|
|
2122
|
+
* document.
|
|
2123
|
+
* @throws {TypeError} If replaceMap is not an object or a key is not an
|
|
2124
|
+
* unsigned integer.
|
|
2125
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2126
|
+
*/
|
|
660
2127
|
replaceSourceObjects(replaceMap: { [key: string]: number }): void;
|
|
2128
|
+
/**
|
|
2129
|
+
* Returns the stream the source PDF is read from.
|
|
2130
|
+
* @returns The positioned byte reader.
|
|
2131
|
+
* @throws {TypeError} If the copying context has ended.
|
|
2132
|
+
*/
|
|
661
2133
|
getSourceDocumentStream(): ByteReaderWithPosition;
|
|
662
2134
|
}
|
|
663
2135
|
|
|
664
2136
|
export interface DocumentContext {
|
|
2137
|
+
/**
|
|
2138
|
+
* Returns the document information dictionary written with the PDF.
|
|
2139
|
+
* @returns The info dictionary.
|
|
2140
|
+
* @throws {TypeError} If the context was not created by a writer.
|
|
2141
|
+
*/
|
|
665
2142
|
getInfoDictionary(): InfoDictionary;
|
|
666
2143
|
}
|
|
667
2144
|
|
|
668
2145
|
export interface DictionaryContext {
|
|
2146
|
+
/**
|
|
2147
|
+
* Writes a dictionary key.
|
|
2148
|
+
* @param key - The key, without a leading slash.
|
|
2149
|
+
* @returns This dictionary context.
|
|
2150
|
+
* @throws {TypeError} If key is not a single string.
|
|
2151
|
+
*/
|
|
669
2152
|
writeKey(key: string): DictionaryContext;
|
|
2153
|
+
/**
|
|
2154
|
+
* Writes a name as the value of the last key.
|
|
2155
|
+
* @param nameValue - The name, without a leading slash.
|
|
2156
|
+
* @returns This dictionary context.
|
|
2157
|
+
* @throws {TypeError} If nameValue is not a single string.
|
|
2158
|
+
*/
|
|
670
2159
|
writeNameValue(nameValue: string): this;
|
|
2160
|
+
/**
|
|
2161
|
+
* Writes a rectangle array as the value of the last key.
|
|
2162
|
+
* @param values - The rectangle [left, bottom, right, top].
|
|
2163
|
+
* @returns This dictionary context.
|
|
2164
|
+
* @throws {TypeError} If the arguments are not an array of 4 numbers or 4 numbers.
|
|
2165
|
+
*/
|
|
671
2166
|
writeRectangleValue(values: Array<number>): this;
|
|
672
2167
|
writeRectangleValue(a: number, b: number, c: number, d: number): this;
|
|
2168
|
+
/**
|
|
2169
|
+
* Writes a literal string as the value of the last key.
|
|
2170
|
+
* @param literal - The text, or its byte values.
|
|
2171
|
+
* @returns This dictionary context.
|
|
2172
|
+
* @throws {TypeError} If literal is not a single string or array.
|
|
2173
|
+
*/
|
|
673
2174
|
writeLiteralStringValue(literal: Array<number> | string): this;
|
|
2175
|
+
/**
|
|
2176
|
+
* Writes a boolean as the value of the last key.
|
|
2177
|
+
* @param boolValue - The value.
|
|
2178
|
+
* @returns This dictionary context.
|
|
2179
|
+
* @throws {TypeError} If boolValue is not a single boolean.
|
|
2180
|
+
*/
|
|
674
2181
|
writeBooleanValue(boolValue: boolean): this;
|
|
2182
|
+
/**
|
|
2183
|
+
* Writes a number as the value of the last key.
|
|
2184
|
+
* @param value - The number.
|
|
2185
|
+
* @returns This dictionary context.
|
|
2186
|
+
* @throws {TypeError} If value is not a single number.
|
|
2187
|
+
*/
|
|
675
2188
|
writeNumberValue(value: number): this;
|
|
2189
|
+
/**
|
|
2190
|
+
* Writes an indirect object reference as the value of the last key.
|
|
2191
|
+
* @param objectId - The object ID.
|
|
2192
|
+
* @returns This dictionary context.
|
|
2193
|
+
* @throws {TypeError} If objectId is not a single number.
|
|
2194
|
+
*/
|
|
676
2195
|
writeObjectReferenceValue(objectId: number): this;
|
|
677
2196
|
}
|
|
678
2197
|
|
|
679
2198
|
export interface ByteWriterWithPosition {
|
|
680
|
-
|
|
2199
|
+
/**
|
|
2200
|
+
* Writes bytes at the current position.
|
|
2201
|
+
* @param bytes - The bytes to write.
|
|
2202
|
+
* @returns The number of bytes written.
|
|
2203
|
+
* @throws {TypeError} If bytes is not a single Uint8Array or byte array.
|
|
2204
|
+
*/
|
|
2205
|
+
write(bytes: Uint8Array | number[]): number;
|
|
2206
|
+
/**
|
|
2207
|
+
* Returns the current position.
|
|
2208
|
+
* @returns The byte offset.
|
|
2209
|
+
*/
|
|
681
2210
|
getCurrentPosition(): number;
|
|
682
2211
|
}
|
|
683
2212
|
|
|
@@ -698,51 +2227,247 @@ declare namespace muhammara {
|
|
|
698
2227
|
export const eXrefEntryUndefined = 3;
|
|
699
2228
|
|
|
700
2229
|
export interface ObjectsContext {
|
|
2230
|
+
/**
|
|
2231
|
+
* Reserves a new object ID, for a forward reference or a later object.
|
|
2232
|
+
* @returns The object ID.
|
|
2233
|
+
*/
|
|
701
2234
|
allocateNewObjectID(): FormXObjectId;
|
|
2235
|
+
/**
|
|
2236
|
+
* Writes the start of a dictionary. End it with endDictionary().
|
|
2237
|
+
* @returns The dictionary context for writing keys and values.
|
|
2238
|
+
*/
|
|
702
2239
|
startDictionary(): DictionaryContext;
|
|
2240
|
+
/**
|
|
2241
|
+
* Writes the start of an array. End it with endArray().
|
|
2242
|
+
* @returns This context.
|
|
2243
|
+
*/
|
|
703
2244
|
startArray(): this;
|
|
2245
|
+
/**
|
|
2246
|
+
* Writes a number, as an integer when it has no fraction.
|
|
2247
|
+
* @param value - The number.
|
|
2248
|
+
* @returns This context.
|
|
2249
|
+
* @throws {TypeError} If value is not a single number.
|
|
2250
|
+
*/
|
|
704
2251
|
writeNumber(value: number): this;
|
|
2252
|
+
/**
|
|
2253
|
+
* Writes the end of an array.
|
|
2254
|
+
* @param endType - The separator after the array; a space when omitted.
|
|
2255
|
+
* @returns This context.
|
|
2256
|
+
* @throws {TypeError} If endType is given and is not a number.
|
|
2257
|
+
*/
|
|
705
2258
|
endArray(endType?: ETokenSeparator): this;
|
|
2259
|
+
/**
|
|
2260
|
+
* Writes a line break.
|
|
2261
|
+
* @returns This context.
|
|
2262
|
+
*/
|
|
706
2263
|
endLine(): this;
|
|
2264
|
+
/**
|
|
2265
|
+
* Writes the end of a dictionary.
|
|
2266
|
+
* @param dictionary - The dictionary started last.
|
|
2267
|
+
* @returns This context.
|
|
2268
|
+
* @throws {TypeError} If dictionary is not a dictionary context or not the one started last.
|
|
2269
|
+
*/
|
|
707
2270
|
endDictionary(dictionary: DictionaryContext): this;
|
|
2271
|
+
/**
|
|
2272
|
+
* Writes the end of the current indirect object.
|
|
2273
|
+
* @returns This context.
|
|
2274
|
+
*/
|
|
708
2275
|
endIndirectObject(): this;
|
|
2276
|
+
/**
|
|
2277
|
+
* Writes a reference to an indirect object.
|
|
2278
|
+
* @param objectId - The object ID.
|
|
2279
|
+
* @param generationNumber - The generation number; 0 when omitted.
|
|
2280
|
+
* @returns This context.
|
|
2281
|
+
* @throws {TypeError} If the arguments are not one or two numbers.
|
|
2282
|
+
*/
|
|
709
2283
|
writeIndirectObjectReference(
|
|
710
2284
|
objectId: FormXObjectId,
|
|
711
2285
|
generationNumber?: number,
|
|
712
2286
|
): this;
|
|
2287
|
+
/**
|
|
2288
|
+
* Starts an indirect object. Without an ID, allocates one and returns it;
|
|
2289
|
+
* with an ID reserved by allocateNewObjectID(), returns this context.
|
|
2290
|
+
* @param objectId - A reserved object ID.
|
|
2291
|
+
* @returns The new object ID, or this context when objectId is given.
|
|
2292
|
+
* @throws {TypeError} If objectId is given and is not a number.
|
|
2293
|
+
*/
|
|
713
2294
|
startNewIndirectObject(objectId: FormXObjectId): this;
|
|
714
2295
|
startNewIndirectObject(): FormXObjectId;
|
|
2296
|
+
/**
|
|
2297
|
+
* Starts a new version of an existing object of the PDF being modified.
|
|
2298
|
+
* @param objectId - The object ID to replace.
|
|
2299
|
+
* @returns This context.
|
|
2300
|
+
* @throws {TypeError} If objectId is not a single number.
|
|
2301
|
+
*/
|
|
715
2302
|
startModifiedIndirectObject(objectId: FormXObjectId): this;
|
|
2303
|
+
/**
|
|
2304
|
+
* Marks an object as free in the cross-reference table.
|
|
2305
|
+
* @param objectId - The object ID.
|
|
2306
|
+
* @returns This context.
|
|
2307
|
+
* @throws {TypeError} If objectId is not a single number.
|
|
2308
|
+
*/
|
|
716
2309
|
deleteObject(objectId: FormXObjectId): this;
|
|
2310
|
+
/**
|
|
2311
|
+
* Writes a name object, escaping it as needed.
|
|
2312
|
+
* @param name - The name, without a leading slash.
|
|
2313
|
+
* @returns This context.
|
|
2314
|
+
* @throws {TypeError} If name is not a single string.
|
|
2315
|
+
*/
|
|
717
2316
|
writeName(name: string): this;
|
|
2317
|
+
/**
|
|
2318
|
+
* Writes a literal string, escaping it as needed.
|
|
2319
|
+
* @param literal - The text, or its byte values.
|
|
2320
|
+
* @returns This context.
|
|
2321
|
+
* @throws {TypeError} If literal is not a single string or array.
|
|
2322
|
+
*/
|
|
718
2323
|
writeLiteralString(literal: string | number[]): this;
|
|
2324
|
+
/**
|
|
2325
|
+
* Writes a hexadecimal string.
|
|
2326
|
+
* @param hex - The bytes as a string of hex digits, or their byte values.
|
|
2327
|
+
* @returns This context.
|
|
2328
|
+
* @throws {TypeError} If hex is not a single string or array.
|
|
2329
|
+
*/
|
|
719
2330
|
writeHexString(hex: string | number[]): this;
|
|
2331
|
+
/**
|
|
2332
|
+
* Writes a boolean.
|
|
2333
|
+
* @param bool - The value.
|
|
2334
|
+
* @returns This context.
|
|
2335
|
+
* @throws {TypeError} If bool is not a single boolean.
|
|
2336
|
+
*/
|
|
720
2337
|
writeBoolean(bool: boolean): this;
|
|
2338
|
+
/**
|
|
2339
|
+
* Writes a keyword, such as a content-stream operator, unescaped.
|
|
2340
|
+
* @param keyword - The keyword.
|
|
2341
|
+
* @returns This context.
|
|
2342
|
+
* @throws {TypeError} If keyword is not a single string.
|
|
2343
|
+
*/
|
|
721
2344
|
writeKeyword(keyword: string): this;
|
|
2345
|
+
/**
|
|
2346
|
+
* Writes a comment line.
|
|
2347
|
+
* @param comment - The comment, without the percent sign.
|
|
2348
|
+
* @returns This context.
|
|
2349
|
+
* @throws {TypeError} If comment is not a single string.
|
|
2350
|
+
*/
|
|
722
2351
|
writeComment(comment: string): this;
|
|
2352
|
+
/**
|
|
2353
|
+
* Sets whether later streams are Flate compressed.
|
|
2354
|
+
* @param compress - True to compress.
|
|
2355
|
+
* @returns This context.
|
|
2356
|
+
* @throws {TypeError} If compress is not a single boolean.
|
|
2357
|
+
*/
|
|
723
2358
|
setCompressStreams(compress: boolean): this;
|
|
724
|
-
|
|
725
|
-
|
|
2359
|
+
/**
|
|
2360
|
+
* Starts a stream that is compressed when compression is on.
|
|
2361
|
+
* @param dictionaryContext - A started stream dictionary to add Length and
|
|
2362
|
+
* Filter to; a new one when omitted.
|
|
2363
|
+
* @returns The stream; write to its write stream, then call endPDFStream().
|
|
2364
|
+
* @throws {TypeError} If dictionaryContext is given and is not a dictionary context.
|
|
2365
|
+
*/
|
|
2366
|
+
startPDFStream(dictionaryContext?: DictionaryContext): PDFStream;
|
|
2367
|
+
/**
|
|
2368
|
+
* Starts a stream written as given, never compressed.
|
|
2369
|
+
* @param dictionaryContext - A started stream dictionary to add Length to;
|
|
2370
|
+
* a new one when omitted.
|
|
2371
|
+
* @returns The stream; write to its write stream, then call endPDFStream().
|
|
2372
|
+
* @throws {TypeError} If dictionaryContext is given and is not a dictionary context.
|
|
2373
|
+
*/
|
|
2374
|
+
startUnfilteredPDFStream(dictionaryContext?: DictionaryContext): PDFStream;
|
|
2375
|
+
/**
|
|
2376
|
+
* Ends a stream and writes its length.
|
|
2377
|
+
* @param stream - The stream started last.
|
|
2378
|
+
* @returns This context.
|
|
2379
|
+
* @throws {TypeError} If stream is not a stream.
|
|
2380
|
+
*/
|
|
726
2381
|
endPDFStream(stream: PDFStream): this;
|
|
2382
|
+
/**
|
|
2383
|
+
* Gives direct access to the output, for bytes the other methods cannot
|
|
2384
|
+
* write. End it with endFreeContext().
|
|
2385
|
+
* @returns A writer at the current output position.
|
|
2386
|
+
*/
|
|
727
2387
|
startFreeContext(): ByteWriterWithPosition;
|
|
2388
|
+
/**
|
|
2389
|
+
* Ends direct output access.
|
|
2390
|
+
* @returns This context.
|
|
2391
|
+
*/
|
|
728
2392
|
endFreeContext(): this;
|
|
729
2393
|
}
|
|
730
2394
|
|
|
731
2395
|
export interface PDFObject {
|
|
2396
|
+
/**
|
|
2397
|
+
* Returns the object type.
|
|
2398
|
+
* @returns The type, one of the ePDFObject* constants.
|
|
2399
|
+
*/
|
|
732
2400
|
getType(): PDFObjectType;
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
2401
|
+
/**
|
|
2402
|
+
* Returns this object typed as an indirect object reference.
|
|
2403
|
+
* @returns This object; undefined when it is not an indirect object reference.
|
|
2404
|
+
*/
|
|
2405
|
+
toPDFIndirectObjectReference(): PDFIndirectObjectReference | undefined;
|
|
2406
|
+
/**
|
|
2407
|
+
* Returns this object typed as an array.
|
|
2408
|
+
* @returns This object; undefined when it is not an array.
|
|
2409
|
+
*/
|
|
2410
|
+
toPDFArray(): PDFArray | undefined;
|
|
2411
|
+
/**
|
|
2412
|
+
* Returns this object typed as a dictionary.
|
|
2413
|
+
* @returns This object; undefined when it is not a dictionary.
|
|
2414
|
+
*/
|
|
2415
|
+
toPDFDictionary(): PDFDictionary | undefined;
|
|
2416
|
+
/**
|
|
2417
|
+
* Returns this object typed as a stream.
|
|
2418
|
+
* @returns This object; undefined when it is not a stream.
|
|
2419
|
+
*/
|
|
2420
|
+
toPDFStream(): PDFStream | undefined;
|
|
2421
|
+
/**
|
|
2422
|
+
* Returns this object typed as a boolean.
|
|
2423
|
+
* @returns This object; undefined when it is not a boolean.
|
|
2424
|
+
*/
|
|
2425
|
+
toPDFBoolean(): PDFBoolean | undefined;
|
|
2426
|
+
/**
|
|
2427
|
+
* Returns this object typed as a literal string.
|
|
2428
|
+
* @returns This object; undefined when it is not a literal string.
|
|
2429
|
+
*/
|
|
2430
|
+
toPDFLiteralString(): PDFLiteralString | undefined;
|
|
2431
|
+
/**
|
|
2432
|
+
* Returns this object typed as a hex string.
|
|
2433
|
+
* @returns This object; undefined when it is not a hex string.
|
|
2434
|
+
*/
|
|
2435
|
+
toPDFHexString(): PDFHexString | undefined;
|
|
2436
|
+
/**
|
|
2437
|
+
* Returns this object typed as the null object.
|
|
2438
|
+
* @returns This object; undefined when it is not the null object.
|
|
2439
|
+
*/
|
|
2440
|
+
toPDFNull(): PDFNull | undefined;
|
|
2441
|
+
/**
|
|
2442
|
+
* Returns this object typed as a name.
|
|
2443
|
+
* @returns This object; undefined when it is not a name.
|
|
2444
|
+
*/
|
|
2445
|
+
toPDFName(): PDFName | undefined;
|
|
2446
|
+
/**
|
|
2447
|
+
* Returns this object typed as an integer.
|
|
2448
|
+
* @returns This object; undefined when it is not an integer.
|
|
2449
|
+
*/
|
|
2450
|
+
toPDFInteger(): PDFInteger | undefined;
|
|
2451
|
+
/**
|
|
2452
|
+
* Returns this object typed as a real number.
|
|
2453
|
+
* @returns This object; undefined when it is not a real number.
|
|
2454
|
+
*/
|
|
2455
|
+
toPDFReal(): PDFReal | undefined;
|
|
2456
|
+
/**
|
|
2457
|
+
* Returns this object typed as a symbol.
|
|
2458
|
+
* @returns This object; undefined when it is not a symbol.
|
|
2459
|
+
*/
|
|
2460
|
+
toPDFSymbol(): PDFSymbol | undefined;
|
|
2461
|
+
/**
|
|
2462
|
+
* Returns the value of an integer or real number.
|
|
2463
|
+
* @returns The number; undefined for other types.
|
|
2464
|
+
*/
|
|
2465
|
+
toNumber(): number | undefined;
|
|
2466
|
+
/**
|
|
2467
|
+
* Returns the value as text: the name, string, number, symbol or
|
|
2468
|
+
* boolean; the type label for other types.
|
|
2469
|
+
* @returns The text.
|
|
2470
|
+
*/
|
|
746
2471
|
toString(): string;
|
|
747
2472
|
}
|
|
748
2473
|
|
|
@@ -755,18 +2480,48 @@ declare namespace muhammara {
|
|
|
755
2480
|
}
|
|
756
2481
|
|
|
757
2482
|
export interface PDFStreamInput extends PDFObject {
|
|
2483
|
+
/**
|
|
2484
|
+
* Returns the stream dictionary.
|
|
2485
|
+
* @returns The dictionary.
|
|
2486
|
+
*/
|
|
758
2487
|
getDictionary(): PDFDictionary;
|
|
2488
|
+
/**
|
|
2489
|
+
* Returns the byte position where the stream contents start.
|
|
2490
|
+
* @returns The byte position in the source file.
|
|
2491
|
+
*/
|
|
759
2492
|
getStreamContentStart(): number;
|
|
760
2493
|
}
|
|
761
2494
|
|
|
762
2495
|
export interface PDFTextString {
|
|
2496
|
+
/**
|
|
2497
|
+
* Returns the encoded bytes, PDFDocEncoding or UTF-16BE with a byte
|
|
2498
|
+
* order mark.
|
|
2499
|
+
* @returns The byte values.
|
|
2500
|
+
*/
|
|
763
2501
|
toBytesArray(): Array<number>;
|
|
2502
|
+
/**
|
|
2503
|
+
* Returns the text.
|
|
2504
|
+
* @returns The decoded text.
|
|
2505
|
+
*/
|
|
764
2506
|
toString(): string;
|
|
765
|
-
|
|
2507
|
+
/**
|
|
2508
|
+
* Sets the text; a value that is not a string is ignored.
|
|
2509
|
+
* @param value - The text.
|
|
2510
|
+
* @returns This text string.
|
|
2511
|
+
*/
|
|
2512
|
+
fromString(value: string): this;
|
|
766
2513
|
}
|
|
767
2514
|
|
|
768
2515
|
export interface PageContentContext extends AbstractContentContext {
|
|
2516
|
+
/**
|
|
2517
|
+
* Returns the content stream being written.
|
|
2518
|
+
* @returns The stream.
|
|
2519
|
+
*/
|
|
769
2520
|
getCurrentPageContentStream(): PDFStream;
|
|
2521
|
+
/**
|
|
2522
|
+
* Returns the page this context draws on.
|
|
2523
|
+
* @returns The page.
|
|
2524
|
+
*/
|
|
770
2525
|
getAssociatedPage(): PDFPage;
|
|
771
2526
|
}
|
|
772
2527
|
|
|
@@ -794,6 +2549,30 @@ declare namespace muhammara {
|
|
|
794
2549
|
upperRightY: number,
|
|
795
2550
|
];
|
|
796
2551
|
|
|
2552
|
+
/** RGB (3 numbers) or CMYK (4 numbers) color components, 0 to 255. */
|
|
2553
|
+
export type TIFFColor =
|
|
2554
|
+
| [r: number, g: number, b: number]
|
|
2555
|
+
| [c: number, m: number, y: number, k: number];
|
|
2556
|
+
|
|
2557
|
+
/** Options for `createFormXObjectFromTIFF()`. */
|
|
2558
|
+
export interface TIFFUsageOptions {
|
|
2559
|
+
/** The zero-based page of a multi-page TIFF. */
|
|
2560
|
+
pageIndex?: number;
|
|
2561
|
+
/** How black-and-white images are drawn. */
|
|
2562
|
+
bwTreatment?: {
|
|
2563
|
+
/** Draw the image as a stencil mask in oneColor. */
|
|
2564
|
+
asImageMask?: boolean;
|
|
2565
|
+
oneColor?: TIFFColor;
|
|
2566
|
+
};
|
|
2567
|
+
/** How grayscale images are drawn. */
|
|
2568
|
+
grayscaleTreatment?: {
|
|
2569
|
+
/** Map gray values between zeroColor and oneColor. */
|
|
2570
|
+
asColorMap?: boolean;
|
|
2571
|
+
oneColor?: TIFFColor;
|
|
2572
|
+
zeroColor?: TIFFColor;
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
|
|
797
2576
|
export interface MergeOptions {
|
|
798
2577
|
password?: string;
|
|
799
2578
|
type?: eRangeType;
|
|
@@ -802,13 +2581,19 @@ declare namespace muhammara {
|
|
|
802
2581
|
|
|
803
2582
|
export interface AppendOptions extends MergeOptions {}
|
|
804
2583
|
|
|
805
|
-
export type inInterPagesCallback = () =>
|
|
2584
|
+
export type inInterPagesCallback = (this: typeof globalThis) => void;
|
|
806
2585
|
|
|
807
2586
|
/** Stateful methods require an active writer and throw Error("PDF writer has ended") after cleanup. */
|
|
808
2587
|
export interface PDFWriter {
|
|
809
2588
|
/**
|
|
810
2589
|
* Replace direct references to an object in a page dictionary.
|
|
811
2590
|
* Available only when modifying an existing PDF.
|
|
2591
|
+
* @param pageIndex - The zero-based page index; ignored for the global scope.
|
|
2592
|
+
* @param sourceObjectId - The object ID to stop referencing.
|
|
2593
|
+
* @param replacementObjectId - The object ID to reference instead.
|
|
2594
|
+
* @param options - `scope: ObjectReplacementScope.GLOBAL` replaces on every page.
|
|
2595
|
+
* @returns This writer.
|
|
2596
|
+
* @throws {Error} If the writer does not modify a PDF or the page does not exist.
|
|
812
2597
|
*/
|
|
813
2598
|
replaceObject(
|
|
814
2599
|
pageIndex: number,
|
|
@@ -816,32 +2601,126 @@ declare namespace muhammara {
|
|
|
816
2601
|
replacementObjectId: number,
|
|
817
2602
|
options?: ObjectReplacementOptions,
|
|
818
2603
|
): this;
|
|
819
|
-
/**
|
|
2604
|
+
/**
|
|
2605
|
+
* Finalizes the PDF once; repeated calls return this writer. A failed
|
|
2606
|
+
* finalization also ends the writer.
|
|
2607
|
+
* @returns This writer.
|
|
2608
|
+
* @throws {Error} If a dictionary started with `startDictionary()` is still
|
|
2609
|
+
* open; the writer stays usable, so end the dictionary and call `end()`
|
|
2610
|
+
* again.
|
|
2611
|
+
* @throws {TypeError} If the PDF cannot be finalized.
|
|
2612
|
+
*/
|
|
820
2613
|
end(): PDFWriter;
|
|
2614
|
+
/**
|
|
2615
|
+
* Creates a page, optionally with its media box. Write it with writePage().
|
|
2616
|
+
* @param x - The media box left edge.
|
|
2617
|
+
* @param y - The media box bottom edge.
|
|
2618
|
+
* @param width - The media box width.
|
|
2619
|
+
* @param height - The media box height.
|
|
2620
|
+
* @returns The new page.
|
|
2621
|
+
* @throws {Error} If the writer has ended.
|
|
2622
|
+
*/
|
|
821
2623
|
createPage(x: PosX, y: PosY, width: Width, height: Height): PDFPage;
|
|
822
2624
|
createPage(): PDFPage;
|
|
2625
|
+
/**
|
|
2626
|
+
* Writes a page and ends its content context.
|
|
2627
|
+
* @param page - The page to write.
|
|
2628
|
+
* @returns This writer.
|
|
2629
|
+
* @throws {TypeError} If page is not a page or the page cannot be written.
|
|
2630
|
+
* @throws {Error} If the writer has ended.
|
|
2631
|
+
*/
|
|
823
2632
|
writePage(page: PDFPage): this;
|
|
2633
|
+
/**
|
|
2634
|
+
* Writes a page and ends its content context.
|
|
2635
|
+
* @param page - The page to write.
|
|
2636
|
+
* @returns The page object ID.
|
|
2637
|
+
* @throws {TypeError} If page is not a page or the page cannot be written.
|
|
2638
|
+
* @throws {Error} If the writer has ended.
|
|
2639
|
+
*/
|
|
824
2640
|
writePageAndReturnID(page: PDFPage): number;
|
|
2641
|
+
/**
|
|
2642
|
+
* Starts, or returns the already started, content context of a page.
|
|
2643
|
+
* @param page - The page to draw on.
|
|
2644
|
+
* @returns The page content context.
|
|
2645
|
+
* @throws {TypeError} If page is not a page.
|
|
2646
|
+
* @throws {Error} If the writer has ended.
|
|
2647
|
+
*/
|
|
825
2648
|
startPageContentContext(page: PDFPage): PageContentContext;
|
|
2649
|
+
/**
|
|
2650
|
+
* Ends the current content stream of a page so other objects can be
|
|
2651
|
+
* written; later drawing starts a new stream on the same page.
|
|
2652
|
+
* @param pageContextContext - The content context to pause.
|
|
2653
|
+
* @returns This writer.
|
|
2654
|
+
* @throws {TypeError} If the argument is not a started page content context.
|
|
2655
|
+
* @throws {Error} If the writer has ended.
|
|
2656
|
+
*/
|
|
826
2657
|
pausePageContentContext(pageContextContext: PageContentContext): this;
|
|
2658
|
+
/**
|
|
2659
|
+
* Starts a form XObject. Draw on its content context, then call
|
|
2660
|
+
* endFormXObject().
|
|
2661
|
+
* @param left - The bounding box left edge.
|
|
2662
|
+
* @param bottom - The bounding box bottom edge.
|
|
2663
|
+
* @param right - The bounding box right edge.
|
|
2664
|
+
* @param top - The bounding box top edge.
|
|
2665
|
+
* @param objectId - A forward-reference object ID reserved earlier.
|
|
2666
|
+
* @returns The form.
|
|
2667
|
+
* @throws {TypeError} If the arguments are not four or five numbers.
|
|
2668
|
+
* @throws {Error} If the writer has ended.
|
|
2669
|
+
*/
|
|
827
2670
|
createFormXObject(
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
2671
|
+
left: number,
|
|
2672
|
+
bottom: number,
|
|
2673
|
+
right: number,
|
|
2674
|
+
top: number,
|
|
832
2675
|
objectId?: FormXObjectId,
|
|
833
2676
|
): FormXObject;
|
|
2677
|
+
/**
|
|
2678
|
+
* Ends and writes a form XObject.
|
|
2679
|
+
* @param formXObject - The form to end.
|
|
2680
|
+
* @returns This writer.
|
|
2681
|
+
* @throws {TypeError} If formXObject is not a form or cannot be written.
|
|
2682
|
+
* @throws {Error} If the writer has ended.
|
|
2683
|
+
*/
|
|
834
2684
|
endFormXObject(formXObject: FormXObject): this;
|
|
2685
|
+
/**
|
|
2686
|
+
* Creates a form XObject showing a JPEG image.
|
|
2687
|
+
* @param file - The image path or a read stream.
|
|
2688
|
+
* @param objectId - A forward-reference object ID reserved earlier.
|
|
2689
|
+
* @returns The form.
|
|
2690
|
+
* @throws {TypeError} If the arguments are wrong or the image cannot be read.
|
|
2691
|
+
* @throws {Error} If the writer has ended.
|
|
2692
|
+
*/
|
|
835
2693
|
createFormXObjectFromJPG(
|
|
836
|
-
file: FilePath |
|
|
2694
|
+
file: FilePath | ReadStream,
|
|
837
2695
|
objectId?: FormXObjectId,
|
|
838
2696
|
): FormXObject;
|
|
2697
|
+
/**
|
|
2698
|
+
* Loads a font file for text drawing.
|
|
2699
|
+
* @param inFontFilePath - The font file path.
|
|
2700
|
+
* @param inOptionalMetricsFile - The metrics file of a Type 1 font.
|
|
2701
|
+
* @param index - The font index in a collection such as TTC or DFont.
|
|
2702
|
+
* @returns The font.
|
|
2703
|
+
* @throws {TypeError} If the arguments are wrong or the font cannot be loaded.
|
|
2704
|
+
* @throws {Error} If the writer has ended.
|
|
2705
|
+
*/
|
|
839
2706
|
getFontForFile(inFontFilePath: FilePath, index?: number): UsedFont;
|
|
840
2707
|
getFontForFile(
|
|
841
2708
|
inFontFilePath: FilePath,
|
|
842
2709
|
inOptionalMetricsFile?: string,
|
|
843
2710
|
index?: number,
|
|
844
2711
|
): UsedFont;
|
|
2712
|
+
/**
|
|
2713
|
+
* Adds a link annotation to the page written next.
|
|
2714
|
+
* @param url - The ASCII link target.
|
|
2715
|
+
* @param left - The clickable area left edge.
|
|
2716
|
+
* @param bottom - The clickable area bottom edge.
|
|
2717
|
+
* @param right - The clickable area right edge.
|
|
2718
|
+
* @param top - The clickable area top edge.
|
|
2719
|
+
* @returns This writer.
|
|
2720
|
+
* @throws {TypeError} If the arguments are not a string and four numbers, or
|
|
2721
|
+
* the URL cannot be encoded as ASCII.
|
|
2722
|
+
* @throws {Error} If the writer has ended.
|
|
2723
|
+
*/
|
|
845
2724
|
attachURLLinktoCurrentPage(
|
|
846
2725
|
url: string,
|
|
847
2726
|
left: PosX,
|
|
@@ -849,42 +2728,136 @@ declare namespace muhammara {
|
|
|
849
2728
|
right: PosX,
|
|
850
2729
|
top: PosY,
|
|
851
2730
|
): this;
|
|
852
|
-
/**
|
|
2731
|
+
/**
|
|
2732
|
+
* Saves the continuation state for createWriterToContinue() and retires
|
|
2733
|
+
* this writer, including when saving fails.
|
|
2734
|
+
* @param outputFilePath - The state file path.
|
|
2735
|
+
* @returns This writer.
|
|
2736
|
+
* @throws {TypeError} If the path is missing or the state cannot be saved.
|
|
2737
|
+
* @throws {Error} If the writer has ended.
|
|
2738
|
+
*/
|
|
853
2739
|
shutdown(outputFilePath: FilePath): this;
|
|
2740
|
+
/**
|
|
2741
|
+
* Creates a form XObject showing a TIFF image.
|
|
2742
|
+
* @param filePath - The image path or a read stream.
|
|
2743
|
+
* @param objectId - A forward-reference object ID, or TIFF options.
|
|
2744
|
+
* @returns The form.
|
|
2745
|
+
* @throws {TypeError} If the arguments are wrong, a color is not 3 or 4
|
|
2746
|
+
* numbers, or the image cannot be read.
|
|
2747
|
+
* @throws {Error} If the writer has ended.
|
|
2748
|
+
*/
|
|
854
2749
|
createFormXObjectFromTIFF(
|
|
855
|
-
filePath: FilePath |
|
|
856
|
-
objectId?: FormXObjectId,
|
|
2750
|
+
filePath: FilePath | ReadStream,
|
|
2751
|
+
objectId?: FormXObjectId | TIFFUsageOptions,
|
|
857
2752
|
): FormXObject;
|
|
2753
|
+
/**
|
|
2754
|
+
* Creates an image XObject from a JPEG image.
|
|
2755
|
+
* @param filePath - The image path or a read stream.
|
|
2756
|
+
* @param objectId - A forward-reference object ID reserved earlier.
|
|
2757
|
+
* @returns The image.
|
|
2758
|
+
* @throws {TypeError} If the arguments are wrong or the image cannot be read.
|
|
2759
|
+
* @throws {Error} If the writer has ended.
|
|
2760
|
+
*/
|
|
858
2761
|
createImageXObjectFromJPG(
|
|
859
|
-
filePath: FilePath |
|
|
2762
|
+
filePath: FilePath | ReadStream,
|
|
860
2763
|
objectId?: FormXObjectId,
|
|
861
2764
|
): ImageXObject;
|
|
2765
|
+
/**
|
|
2766
|
+
* Creates a form XObject showing a PNG image.
|
|
2767
|
+
* @param filePath - The image path or a read stream.
|
|
2768
|
+
* @param objectId - A forward-reference object ID reserved earlier.
|
|
2769
|
+
* @returns The form.
|
|
2770
|
+
* @throws {TypeError} If the arguments are wrong or the image cannot be read.
|
|
2771
|
+
* @throws {Error} If the writer has ended.
|
|
2772
|
+
*/
|
|
862
2773
|
createFormXObjectFromPNG(
|
|
863
|
-
filePath: FilePath |
|
|
2774
|
+
filePath: FilePath | ReadStream,
|
|
864
2775
|
objectId?: FormXObjectId,
|
|
865
2776
|
): FormXObject;
|
|
2777
|
+
/**
|
|
2778
|
+
* Reads the header information of a JPEG file.
|
|
2779
|
+
* @param filePath - The image path.
|
|
2780
|
+
* @returns The image information.
|
|
2781
|
+
* @throws {TypeError} If the argument is wrong or the file cannot be read.
|
|
2782
|
+
* @throws {Error} If the writer has ended.
|
|
2783
|
+
*/
|
|
866
2784
|
retrieveJPGImageInformation(filePath: FilePath): JPEGInformation;
|
|
2785
|
+
/**
|
|
2786
|
+
* Returns the context for writing PDF objects directly.
|
|
2787
|
+
* @returns The objects context.
|
|
2788
|
+
* @throws {Error} If the writer has ended.
|
|
2789
|
+
*/
|
|
867
2790
|
getObjectsContext(): ObjectsContext;
|
|
2791
|
+
/**
|
|
2792
|
+
* Returns the document context, for extensions and the info dictionary.
|
|
2793
|
+
* @returns The document context.
|
|
2794
|
+
* @throws {Error} If the writer has ended.
|
|
2795
|
+
*/
|
|
868
2796
|
getDocumentContext(): DocumentContext;
|
|
2797
|
+
/**
|
|
2798
|
+
* Appends pages of another PDF as new pages.
|
|
2799
|
+
* @param source - The PDF path or a read stream.
|
|
2800
|
+
* @param options - The page range and the source password.
|
|
2801
|
+
* @returns The object IDs of the appended pages.
|
|
2802
|
+
* @throws {TypeError} If the arguments are wrong or the pages cannot be
|
|
2803
|
+
* appended; the writer is aborted then.
|
|
2804
|
+
* @throws {RangeError} If the page range is invalid.
|
|
2805
|
+
* @throws {Error} If the writer has ended.
|
|
2806
|
+
*/
|
|
869
2807
|
appendPDFPagesFromPDF(
|
|
870
2808
|
source: FilePath | ReadStream,
|
|
871
2809
|
options?: AppendOptions,
|
|
872
2810
|
): number[];
|
|
873
|
-
/**
|
|
2811
|
+
/**
|
|
2812
|
+
* Draws pages of another PDF onto a page. The optional callback runs
|
|
2813
|
+
* between pages, with no arguments and globalThis as its receiver.
|
|
2814
|
+
* @param page - The target page.
|
|
2815
|
+
* @param file - The PDF path or a read stream.
|
|
2816
|
+
* @param options - The page range and the source password.
|
|
2817
|
+
* @param callback - Called between merged pages.
|
|
2818
|
+
* @returns This writer.
|
|
2819
|
+
* @throws {TypeError} If page is not a page, file is neither a path nor a
|
|
2820
|
+
* stream, or the pages cannot be merged.
|
|
2821
|
+
* @throws {RangeError} If the page range is invalid.
|
|
2822
|
+
* @throws {Error} If the writer has ended.
|
|
2823
|
+
*/
|
|
874
2824
|
mergePDFPagesToPage(
|
|
875
2825
|
page: PDFPage,
|
|
876
|
-
file: FilePath |
|
|
2826
|
+
file: FilePath | ReadStream,
|
|
877
2827
|
options?: MergeOptions,
|
|
878
2828
|
callback?: inInterPagesCallback,
|
|
879
2829
|
): this;
|
|
880
2830
|
mergePDFPagesToPage(
|
|
881
2831
|
page: PDFPage,
|
|
882
|
-
file: FilePath |
|
|
2832
|
+
file: FilePath | ReadStream,
|
|
883
2833
|
callback?: inInterPagesCallback,
|
|
884
2834
|
): this;
|
|
2835
|
+
/**
|
|
2836
|
+
* Opens a PDF for copying objects and pages into this document.
|
|
2837
|
+
* @param source - The PDF path, a read stream, or an open reader.
|
|
2838
|
+
* @param options - The source password.
|
|
2839
|
+
* @returns The copying context; call end() on it when done.
|
|
2840
|
+
* @throws {TypeError} If the arguments are wrong, the reader has ended, or the
|
|
2841
|
+
* PDF cannot be read.
|
|
2842
|
+
* @throws {Error} If the writer has ended.
|
|
2843
|
+
*/
|
|
885
2844
|
createPDFCopyingContext(
|
|
886
|
-
source: FilePath | ReadStream,
|
|
2845
|
+
source: FilePath | ReadStream | PDFReader,
|
|
2846
|
+
options?: PDFReaderOptions,
|
|
887
2847
|
): DocumentCopyingContext;
|
|
2848
|
+
/**
|
|
2849
|
+
* Creates one form XObject per page of another PDF.
|
|
2850
|
+
* @param file - The PDF path.
|
|
2851
|
+
* @param box - The page box to use, or an explicit [left, bottom, right, top].
|
|
2852
|
+
* @param options - The page range and the source password.
|
|
2853
|
+
* @param transformation - The form matrix.
|
|
2854
|
+
* @param objectIds - Further source object IDs to copy.
|
|
2855
|
+
* @returns The form object IDs, one per page.
|
|
2856
|
+
* @throws {TypeError} If the arguments are wrong or the forms cannot be
|
|
2857
|
+
* created.
|
|
2858
|
+
* @throws {RangeError} If the page range is invalid.
|
|
2859
|
+
* @throws {Error} If the writer has ended.
|
|
2860
|
+
*/
|
|
888
2861
|
createFormXObjectsFromPDF(
|
|
889
2862
|
file: FilePath,
|
|
890
2863
|
box?: PDFBox | PDFPageBoxType,
|
|
@@ -892,33 +2865,141 @@ declare namespace muhammara {
|
|
|
892
2865
|
transformation?: TransformationMatrix,
|
|
893
2866
|
objectIds?: FormXObjectId[],
|
|
894
2867
|
): FormXObjectId[];
|
|
2868
|
+
/**
|
|
2869
|
+
* Opens the PDF being modified for copying its objects.
|
|
2870
|
+
* @returns The copying context; call end() on it when done.
|
|
2871
|
+
* @throws {TypeError} If the writer does not modify a PDF.
|
|
2872
|
+
* @throws {Error} If the writer has ended.
|
|
2873
|
+
*/
|
|
895
2874
|
createPDFCopyingContextForModifiedFile(): DocumentCopyingContext;
|
|
896
|
-
|
|
2875
|
+
/**
|
|
2876
|
+
* Creates a PDF text string, encoded as PDFDocEncoding or UTF-16 as needed.
|
|
2877
|
+
* Works after the writer has ended.
|
|
2878
|
+
* @param value - The text, or its UTF-16 code units.
|
|
2879
|
+
* @returns The text string.
|
|
2880
|
+
*/
|
|
2881
|
+
createPDFTextString(value?: string | number[]): PDFTextString;
|
|
2882
|
+
/**
|
|
2883
|
+
* Creates a PDF date. Works after the writer has ended.
|
|
2884
|
+
* @param value - The date, or a PDF date string; now when omitted.
|
|
2885
|
+
* @returns The date.
|
|
2886
|
+
*/
|
|
897
2887
|
createPDFDate(value?: string | Date): PDFDate;
|
|
2888
|
+
/**
|
|
2889
|
+
* Returns the size of an image in points.
|
|
2890
|
+
* @param imagePath - The image path or a read stream.
|
|
2891
|
+
* @param imageIndex - The image or page index of a multi-image file.
|
|
2892
|
+
* @param options - The password of a PDF source.
|
|
2893
|
+
* @returns The width and height.
|
|
2894
|
+
* @throws {TypeError} If the arguments are wrong.
|
|
2895
|
+
* @throws {Error} If the writer has ended.
|
|
2896
|
+
*/
|
|
898
2897
|
getImageDimensions(
|
|
899
|
-
|
|
2898
|
+
imagePath: FilePath | ReadStream,
|
|
2899
|
+
imageIndex?: number,
|
|
2900
|
+
options?: PDFReaderOptions,
|
|
900
2901
|
): RectangleDimension;
|
|
2902
|
+
/**
|
|
2903
|
+
* Returns the number of pages or images in an image file.
|
|
2904
|
+
* @param imagePath - The image path.
|
|
2905
|
+
* @param options - The password of a PDF source.
|
|
2906
|
+
* @returns The page count.
|
|
2907
|
+
* @throws {TypeError} If the arguments are wrong.
|
|
2908
|
+
* @throws {Error} If the writer has ended.
|
|
2909
|
+
*/
|
|
901
2910
|
getImagePagesCount(
|
|
902
2911
|
imagePath: FilePath,
|
|
903
2912
|
options?: { password?: string },
|
|
904
2913
|
): number;
|
|
2914
|
+
/**
|
|
2915
|
+
* Detects the type of an image file.
|
|
2916
|
+
* @param imagePath - The image path.
|
|
2917
|
+
* @returns The type; undefined when it is not a supported image.
|
|
2918
|
+
* @throws {TypeError} If imagePath is not a single argument.
|
|
2919
|
+
* @throws {Error} If the writer has ended.
|
|
2920
|
+
*/
|
|
905
2921
|
getImageType(imagePath: FilePath): PDFImageType | undefined;
|
|
2922
|
+
/**
|
|
2923
|
+
* Returns a reader of the PDF being modified.
|
|
2924
|
+
* @returns The reader.
|
|
2925
|
+
* @throws {TypeError} If the writer does not modify a PDF.
|
|
2926
|
+
* @throws {Error} If the writer has ended.
|
|
2927
|
+
*/
|
|
906
2928
|
getModifiedFileParser(): PDFReader;
|
|
2929
|
+
/**
|
|
2930
|
+
* Returns the input file of the PDF being modified.
|
|
2931
|
+
* @returns The input file.
|
|
2932
|
+
* @throws {TypeError} If the writer does not modify a PDF.
|
|
2933
|
+
* @throws {Error} If the writer has ended.
|
|
2934
|
+
*/
|
|
907
2935
|
getModifiedInputFile(): InputFile;
|
|
2936
|
+
/**
|
|
2937
|
+
* Returns the output file.
|
|
2938
|
+
* @returns The output file.
|
|
2939
|
+
* @throws {TypeError} If the output is not a file.
|
|
2940
|
+
* @throws {Error} If the writer has ended.
|
|
2941
|
+
*/
|
|
908
2942
|
getOutputFile(): OutputFile;
|
|
2943
|
+
/**
|
|
2944
|
+
* Adds an annotation to the Annots array of the page written next.
|
|
2945
|
+
* @param annotationId - The annotation object ID.
|
|
2946
|
+
* @returns This writer.
|
|
2947
|
+
* @throws {TypeError} If annotationId is not a number.
|
|
2948
|
+
* @throws {Error} If the writer has ended.
|
|
2949
|
+
*/
|
|
909
2950
|
registerAnnotationReferenceForNextPageWrite(annotationId: number): this;
|
|
2951
|
+
/**
|
|
2952
|
+
* Makes a modified PDF write a new catalog when it ends, so catalog
|
|
2953
|
+
* changes from extensions are kept.
|
|
2954
|
+
* @throws {Error} If the writer has ended.
|
|
2955
|
+
*/
|
|
910
2956
|
requireCatalogUpdate(): void;
|
|
911
2957
|
|
|
912
2958
|
/* Js Extensions (in muhammara.js) */
|
|
2959
|
+
/**
|
|
2960
|
+
* Returns the writer's event emitter, created on first use.
|
|
2961
|
+
* @returns The emitter for writer events.
|
|
2962
|
+
*/
|
|
913
2963
|
getEvents(): EventEmitter;
|
|
2964
|
+
/**
|
|
2965
|
+
* Emits an event on the writer's emitter after setting `eventParams.writer`
|
|
2966
|
+
* to this writer.
|
|
2967
|
+
* @param eventName - The event name.
|
|
2968
|
+
* @param eventParams - The event parameters; gains a `writer` key.
|
|
2969
|
+
* @throws {TypeError} If eventParams is not an object.
|
|
2970
|
+
*/
|
|
914
2971
|
triggerDocumentExtensionEvent(
|
|
915
2972
|
eventName: string | symbol,
|
|
916
2973
|
eventParams: any,
|
|
917
2974
|
): void;
|
|
918
2975
|
}
|
|
919
2976
|
|
|
2977
|
+
/** Scopes for the `replaceObject()` scope option. */
|
|
2978
|
+
export const ObjectReplacementScope: {
|
|
2979
|
+
/** Replace the reference on every page. */
|
|
2980
|
+
readonly GLOBAL: "global";
|
|
2981
|
+
};
|
|
2982
|
+
export type ObjectReplacementScope =
|
|
2983
|
+
(typeof ObjectReplacementScope)[keyof typeof ObjectReplacementScope];
|
|
2984
|
+
|
|
920
2985
|
export interface ObjectReplacementOptions {
|
|
921
|
-
scope?:
|
|
2986
|
+
scope?: ObjectReplacementScope;
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
export interface RemoveTextOptions {
|
|
2990
|
+
/** Also remove text from the Form XObjects the page paints, including nested forms. Defaults to `false`. */
|
|
2991
|
+
forms?: boolean;
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
export interface DeletePageOptions {
|
|
2995
|
+
/**
|
|
2996
|
+
* Remove references to the deleted pages from retained structures -
|
|
2997
|
+
* outlines, link annotations, named destinations, form widgets,
|
|
2998
|
+
* tagged-PDF structure elements and the open action - instead of
|
|
2999
|
+
* refusing the deletion. Defaults to `false`. Once enabled, it applies to
|
|
3000
|
+
* every queued deletion.
|
|
3001
|
+
*/
|
|
3002
|
+
pruneReferences?: boolean;
|
|
922
3003
|
}
|
|
923
3004
|
|
|
924
3005
|
export interface RecipePageInfo {
|
|
@@ -970,32 +3051,22 @@ declare namespace muhammara {
|
|
|
970
3051
|
* Passes a colorspace argument through when it is valid, and otherwise
|
|
971
3052
|
* resolves to the accepted set so the compiler names the valid values
|
|
972
3053
|
* instead of reporting the bare `never` the optional parameter would
|
|
973
|
-
* collapse to.
|
|
3054
|
+
* collapse to.
|
|
974
3055
|
*/
|
|
975
3056
|
type ValidColorspace<Value extends string | undefined> = [Value] extends [
|
|
976
3057
|
undefined,
|
|
977
3058
|
]
|
|
978
3059
|
? Value
|
|
979
|
-
:
|
|
3060
|
+
: Exclude<Value, undefined> extends Colorspace | ""
|
|
980
3061
|
? Value
|
|
981
|
-
:
|
|
982
|
-
? Value
|
|
983
|
-
: Colorspace | "";
|
|
3062
|
+
: Colorspace | "";
|
|
984
3063
|
type ExtensionCallback<
|
|
985
3064
|
Arguments extends unknown[] = never[],
|
|
986
3065
|
Result = unknown,
|
|
987
3066
|
> = (this: Recipe, ...args: Arguments) => Result;
|
|
988
3067
|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
| "hidden"
|
|
992
|
-
| "print"
|
|
993
|
-
| "nozoom"
|
|
994
|
-
| "norotate"
|
|
995
|
-
| "noview"
|
|
996
|
-
| "readonly"
|
|
997
|
-
| "locked"
|
|
998
|
-
| "togglenoview";
|
|
3068
|
+
/** @deprecated Use `AnnotFlag`; comments accept the same flags. */
|
|
3069
|
+
type CommentOptionsFlag = AnnotOptionsFlag;
|
|
999
3070
|
|
|
1000
3071
|
type AnnotSubtype =
|
|
1001
3072
|
| "Text"
|
|
@@ -1050,16 +3121,121 @@ declare namespace muhammara {
|
|
|
1050
3121
|
|
|
1051
3122
|
type RecipeCoordinate = number | "center";
|
|
1052
3123
|
|
|
3124
|
+
/** Named page sizes, with string compatibility for other names. */
|
|
3125
|
+
type PageSize =
|
|
3126
|
+
| "executive"
|
|
3127
|
+
| "folio"
|
|
3128
|
+
| "legal"
|
|
3129
|
+
| "letter"
|
|
3130
|
+
| "ledger"
|
|
3131
|
+
| "tabloid"
|
|
3132
|
+
| "a0"
|
|
3133
|
+
| "a1"
|
|
3134
|
+
| "a2"
|
|
3135
|
+
| "a3"
|
|
3136
|
+
| "a4"
|
|
3137
|
+
| "a5"
|
|
3138
|
+
| "a6"
|
|
3139
|
+
| "a7"
|
|
3140
|
+
| "a8"
|
|
3141
|
+
| "a9"
|
|
3142
|
+
| "a10"
|
|
3143
|
+
| "b0"
|
|
3144
|
+
| "b1"
|
|
3145
|
+
| "b2"
|
|
3146
|
+
| "b3"
|
|
3147
|
+
| "b4"
|
|
3148
|
+
| "b5"
|
|
3149
|
+
| "b6"
|
|
3150
|
+
| "b7"
|
|
3151
|
+
| "b8"
|
|
3152
|
+
| "b9"
|
|
3153
|
+
| "b10"
|
|
3154
|
+
| "c0"
|
|
3155
|
+
| "c1"
|
|
3156
|
+
| "c2"
|
|
3157
|
+
| "c3"
|
|
3158
|
+
| "c4"
|
|
3159
|
+
| "c5"
|
|
3160
|
+
| "c6"
|
|
3161
|
+
| "c7"
|
|
3162
|
+
| "c8"
|
|
3163
|
+
| "c9"
|
|
3164
|
+
| "c10"
|
|
3165
|
+
| "ra0"
|
|
3166
|
+
| "ra1"
|
|
3167
|
+
| "ra2"
|
|
3168
|
+
| "ra3"
|
|
3169
|
+
| "ra4"
|
|
3170
|
+
| "sra0"
|
|
3171
|
+
| "sra1"
|
|
3172
|
+
| "sra2"
|
|
3173
|
+
| "sra3"
|
|
3174
|
+
| "sra4"
|
|
3175
|
+
| (string & {});
|
|
3176
|
+
|
|
3177
|
+
/** A `Recipe.TextWrap` value. */
|
|
3178
|
+
type TextWrap = "auto" | "clip" | "trim" | "ellipsis";
|
|
3179
|
+
/** A `Recipe.TableRowNth` value. */
|
|
3180
|
+
type TableRowNth = "even" | "odd";
|
|
3181
|
+
/** A `Recipe.LineCap` value. */
|
|
3182
|
+
type LineCap = "butt" | "round" | "square";
|
|
3183
|
+
/** A `Recipe.LineJoin` value. */
|
|
3184
|
+
type LineJoin = "miter" | "round" | "bevel";
|
|
3185
|
+
/** A `Recipe.ArrowAt` value. */
|
|
3186
|
+
type ArrowAt = "head" | "tail";
|
|
3187
|
+
/** A `Recipe.ArrowType` value. */
|
|
3188
|
+
type ArrowType = "triangle" | "dart" | "kite";
|
|
3189
|
+
/** A `Recipe.PageLayout` value. */
|
|
3190
|
+
type PageLayout = "portrait" | "landscape";
|
|
3191
|
+
/** A `Recipe.FontStyle` value. */
|
|
3192
|
+
type FontStyle = "regular" | "bold" | "italic" | "bold-italic";
|
|
3193
|
+
/** A `Recipe.Permission` value. */
|
|
3194
|
+
type Permission = PermissionName;
|
|
3195
|
+
/** A `Recipe.Coordinate` value. */
|
|
3196
|
+
type Coordinate = "center";
|
|
3197
|
+
/** A `Recipe.AnnotFlag` value. */
|
|
3198
|
+
type AnnotFlag = AnnotOptionsFlag;
|
|
3199
|
+
/** A `Recipe.AnnotIcon` value. */
|
|
3200
|
+
type AnnotIcon = AnnotOptionsIcon;
|
|
3201
|
+
/** A `Recipe.ChromaCommand` value. */
|
|
3202
|
+
type ChromaCommand = "!load";
|
|
3203
|
+
/** A `Recipe.Source` value. */
|
|
3204
|
+
type Source = "new";
|
|
3205
|
+
/** The low-level `DeviceColorSpace` values; same as `DeviceColorspace`. */
|
|
3206
|
+
type DeviceColorSpace = DeviceColorspace;
|
|
3207
|
+
type HorizontalAlign = "left" | "center" | "right";
|
|
3208
|
+
type VerticalAlign = "top" | "center" | "bottom";
|
|
3209
|
+
type TextAlign = "left" | "center" | "right" | "justify";
|
|
3210
|
+
/** Known text-box alignments, with string compatibility for computed values. */
|
|
3211
|
+
type TextBoxAlign =
|
|
3212
|
+
TextAlign | `${TextAlign} ${VerticalAlign}` | (string & {});
|
|
3213
|
+
/** Known alignments, with string compatibility for computed values. */
|
|
3214
|
+
type ImageAlign =
|
|
3215
|
+
HorizontalAlign | `${HorizontalAlign} ${VerticalAlign}` | (string & {});
|
|
3216
|
+
|
|
1053
3217
|
type RecipeFontStyle =
|
|
1054
3218
|
"regular" | "bold" | "italic" | "bold-italic" | "r" | "b" | "i" | "bi";
|
|
1055
3219
|
|
|
1056
3220
|
interface RecipeOptions {
|
|
3221
|
+
/** PDF version of a new PDF: 1.0 through 1.7 or 2.0; other values use 1.7. */
|
|
1057
3222
|
version?: number;
|
|
1058
3223
|
author?: string;
|
|
1059
3224
|
title?: string;
|
|
1060
3225
|
subject?: string;
|
|
1061
3226
|
keywords?: string[];
|
|
3227
|
+
/** Default colorspace; see `Recipe.Colorspace`. */
|
|
1062
3228
|
colorspace?: Colorspace;
|
|
3229
|
+
/** Owner password; also opens a protected source PDF. */
|
|
3230
|
+
password?: string;
|
|
3231
|
+
/** The 'view' password; also enables encryption. */
|
|
3232
|
+
userPassword?: string;
|
|
3233
|
+
/** The 'edit' password. */
|
|
3234
|
+
ownerPassword?: string;
|
|
3235
|
+
/** Encryption permission flags, see `Recipe#permission()`. */
|
|
3236
|
+
userProtectionFlag?: number;
|
|
3237
|
+
/** Directory location(s) of additional fonts. */
|
|
3238
|
+
fontSrcPath?: string | string[];
|
|
1063
3239
|
}
|
|
1064
3240
|
|
|
1065
3241
|
interface RecipeMargins {
|
|
@@ -1069,39 +3245,75 @@ declare namespace muhammara {
|
|
|
1069
3245
|
bottom?: number;
|
|
1070
3246
|
}
|
|
1071
3247
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
/** Replies linked to this comment annotation. */
|
|
1079
|
-
replies?: readonly AnnotReply[];
|
|
1080
|
-
}
|
|
3248
|
+
/**
|
|
3249
|
+
* `comment()` options: the `annot()` options except `text`, which is
|
|
3250
|
+
* `comment()`'s first argument. `width` and `height` size the rectangle
|
|
3251
|
+
* down from (x, y), as for `annot()`.
|
|
3252
|
+
*/
|
|
3253
|
+
interface CommentOptions extends Omit<AnnotOptions, "text"> {}
|
|
1081
3254
|
|
|
1082
3255
|
interface AnnotOptions {
|
|
3256
|
+
/** The annotation content. */
|
|
3257
|
+
text?: string;
|
|
3258
|
+
/** The annotation content when `text` is empty, as in `@muhammara/wasm`. */
|
|
3259
|
+
contents?: string;
|
|
1083
3260
|
title?: string;
|
|
1084
3261
|
open?: boolean;
|
|
1085
3262
|
richText?: boolean;
|
|
1086
|
-
flag?: AnnotOptionsFlag;
|
|
3263
|
+
flag?: AnnotOptionsFlag | number;
|
|
3264
|
+
/** Flag bits when `flag` is omitted. */
|
|
3265
|
+
flags?: number;
|
|
1087
3266
|
icon?: AnnotOptionsIcon;
|
|
3267
|
+
/** The `/Name` icon when `icon` is omitted. */
|
|
3268
|
+
name?: string;
|
|
3269
|
+
/** A finite width of at least zero; other values throw a `TypeError`. */
|
|
1088
3270
|
width?: number;
|
|
3271
|
+
/** A finite height of at least zero; other values throw a `TypeError`. */
|
|
1089
3272
|
height?: number;
|
|
1090
|
-
/** Annotation opacity from 0 (transparent) to 1 (opaque). Defaults to 1
|
|
3273
|
+
/** Annotation opacity from 0 (transparent) to 1 (opaque). Defaults to 1; other values throw a `TypeError`. */
|
|
1091
3274
|
opacity?: number;
|
|
1092
|
-
date
|
|
3275
|
+
/** The `/M` modification date; omitted writes no `/M`, and text that is not a date is written as given. */
|
|
3276
|
+
date?: string | Date;
|
|
1093
3277
|
subject?: string;
|
|
1094
3278
|
replies?: readonly AnnotReply[];
|
|
3279
|
+
/**
|
|
3280
|
+
* The border width, or its `width` and `dash` pattern. A negative width
|
|
3281
|
+
* writes no `/Border`. Text markup annotations default to 0.
|
|
3282
|
+
*/
|
|
3283
|
+
border?: number | { width?: number; dash?: readonly number[] };
|
|
3284
|
+
/** The border width; overrides `border.width`. */
|
|
3285
|
+
borderWidth?: number;
|
|
3286
|
+
/** The border dash pattern; overrides `border.dash`. */
|
|
3287
|
+
borderDash?: readonly number[];
|
|
3288
|
+
/** Quad points, eight numbers per quadrilateral, written as given. */
|
|
3289
|
+
quadPoints?: readonly number[];
|
|
3290
|
+
/** `#rrggbb`, `%r,g,b`, a color registered with `chroma()`, a CSS color name, or one (gray), three (RGB), or four (CMYK) numbers from 0 to 255. Other values throw a `TypeError`. */
|
|
3291
|
+
color?: Color;
|
|
3292
|
+
/** Keep the annotation unrotated on a rotated source page. */
|
|
3293
|
+
followOriginalPageRotation?: boolean;
|
|
1095
3294
|
}
|
|
1096
3295
|
|
|
1097
3296
|
interface AnnotReply {
|
|
3297
|
+
/** Ignored: a reply uses the subtype of the annotation it answers. */
|
|
1098
3298
|
subtype?: AnnotSubtype;
|
|
1099
|
-
text
|
|
3299
|
+
text?: string;
|
|
3300
|
+
/** The reply content when `text` is empty. */
|
|
3301
|
+
contents?: string;
|
|
1100
3302
|
title?: string;
|
|
1101
3303
|
richText?: boolean;
|
|
1102
|
-
flag?: AnnotOptionsFlag;
|
|
3304
|
+
flag?: AnnotOptionsFlag | number;
|
|
3305
|
+
/** Flag bits when `flag` is omitted. */
|
|
3306
|
+
flags?: number;
|
|
3307
|
+
/** Whether the reply opens; defaults to the parent's `open`. */
|
|
3308
|
+
open?: boolean;
|
|
3309
|
+
/** The reply icon; defaults to the parent's icon. */
|
|
3310
|
+
icon?: AnnotOptionsIcon;
|
|
3311
|
+
/** The `/Name` icon when `icon` is omitted. */
|
|
3312
|
+
name?: string;
|
|
3313
|
+
/** Opacity from 0 to 1; defaults to 1. Other values throw a `TypeError`. */
|
|
1103
3314
|
opacity?: number;
|
|
1104
|
-
date
|
|
3315
|
+
/** The reply's `/M` date; defaults to the parent's `date`. */
|
|
3316
|
+
date?: string | Date;
|
|
1105
3317
|
subject?: string;
|
|
1106
3318
|
}
|
|
1107
3319
|
|
|
@@ -1120,19 +3332,30 @@ declare namespace muhammara {
|
|
|
1120
3332
|
userProtectionFlag?: number;
|
|
1121
3333
|
}
|
|
1122
3334
|
|
|
1123
|
-
|
|
3335
|
+
/**
|
|
3336
|
+
* Options of `image()`. `fill`, `stroke`, or `color` frame the drawn image
|
|
3337
|
+
* box: the fill beneath the image, the outline above it and inside the
|
|
3338
|
+
* box, as a `rectangle()` stroke. The line options style that outline.
|
|
3339
|
+
*/
|
|
3340
|
+
interface ImageOptions extends PathOptions, TransformOptions {
|
|
1124
3341
|
/** Make the rendered image open this URL. */
|
|
1125
3342
|
link?: string;
|
|
3343
|
+
/** The drawn image width. `lineWidth` sets the frame outline width. */
|
|
1126
3344
|
width?: number;
|
|
1127
3345
|
height?: number;
|
|
3346
|
+
/** Scale the source size; wins over `width` and `height`. */
|
|
1128
3347
|
scale?: number;
|
|
1129
3348
|
keepAspectRatio?: boolean;
|
|
3349
|
+
/** The opacity of the image and its frame. */
|
|
1130
3350
|
opacity?: number;
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
3351
|
+
/** `Recipe.HorizontalAlign`, optionally followed by a space and `Recipe.VerticalAlign`. */
|
|
3352
|
+
align?: ImageAlign;
|
|
3353
|
+
/** The one-based page of a PDF source, or image of a multi-image TIFF, as in `overlay()`; defaults to 1. */
|
|
3354
|
+
page?: number;
|
|
3355
|
+
/** Paint the image box beneath the image. */
|
|
3356
|
+
fill?: Color;
|
|
3357
|
+
/** Outline the image box in green and mark the placement point in red. */
|
|
3358
|
+
debug?: boolean | number;
|
|
1136
3359
|
}
|
|
1137
3360
|
|
|
1138
3361
|
interface InfoOptions {
|
|
@@ -1156,7 +3379,7 @@ declare namespace muhammara {
|
|
|
1156
3379
|
interface MetadataPage {
|
|
1157
3380
|
pageNumber: number;
|
|
1158
3381
|
mediaBox: number[];
|
|
1159
|
-
layout:
|
|
3382
|
+
layout: PageLayout;
|
|
1160
3383
|
rotate: number;
|
|
1161
3384
|
width: number;
|
|
1162
3385
|
height: number;
|
|
@@ -1213,8 +3436,9 @@ declare namespace muhammara {
|
|
|
1213
3436
|
minHeight?: number;
|
|
1214
3437
|
padding?: number | readonly number[];
|
|
1215
3438
|
lineHeight?: number;
|
|
1216
|
-
wrap?: boolean |
|
|
1217
|
-
|
|
3439
|
+
wrap?: boolean | TextWrap;
|
|
3440
|
+
/** `Recipe.TextAlign`, optionally followed by a space and `Recipe.VerticalAlign`. */
|
|
3441
|
+
textAlign?: TextBoxAlign;
|
|
1218
3442
|
clipIfExceedsBox?: boolean;
|
|
1219
3443
|
onClip?: (recipe: Recipe, result: TextBoxClipResult) => void;
|
|
1220
3444
|
style?: TextBoxStyle;
|
|
@@ -1237,6 +3461,8 @@ declare namespace muhammara {
|
|
|
1237
3461
|
/** Text fill color: `#gg`, `#rrggbb`, `#ccmmyykk`, `%r,g,b` percentages, a 0-255 component array, or a name registered with `chroma()`. Missing or unknown colors use `#1777d1`. */
|
|
1238
3462
|
color?: Color;
|
|
1239
3463
|
colorspace?: Colorspace;
|
|
3464
|
+
/** The Separation ink name of a `"separation"` color given by value. */
|
|
3465
|
+
colorName?: string;
|
|
1240
3466
|
flow?: boolean;
|
|
1241
3467
|
overflow?: TextOverflowCallback;
|
|
1242
3468
|
layout?: number | string;
|
|
@@ -1244,13 +3470,14 @@ declare namespace muhammara {
|
|
|
1244
3470
|
rotation?: number;
|
|
1245
3471
|
rotationOrigin?: readonly [number, number];
|
|
1246
3472
|
font?: string;
|
|
1247
|
-
/** Font size in points for text() and textDimensions(); defaults to 14 when both fontSize and size are omitted. A size that is not greater than zero throws RangeError. */
|
|
3473
|
+
/** Font size in points for text() and textDimensions(); defaults to 14 when both fontSize and size are omitted. A size that is not a finite number greater than zero throws RangeError. */
|
|
1248
3474
|
fontSize?: number;
|
|
1249
|
-
/** Font size in points for text() and textDimensions(); defaults to 14. A size that is not greater than zero throws RangeError. */
|
|
3475
|
+
/** Font size in points for text() and textDimensions(); defaults to 14. A size that is not a finite number greater than zero throws RangeError. */
|
|
1250
3476
|
size?: number;
|
|
1251
3477
|
bold?: boolean;
|
|
1252
3478
|
italic?: boolean;
|
|
1253
|
-
|
|
3479
|
+
/** `Recipe.HorizontalAlign`, optionally followed by a space and `Recipe.VerticalAlign`. */
|
|
3480
|
+
align?: ImageAlign;
|
|
1254
3481
|
highlight?: boolean | TextMarkupOptions;
|
|
1255
3482
|
underline?: boolean | TextMarkupOptions;
|
|
1256
3483
|
strikeOut?: boolean | TextMarkupOptions;
|
|
@@ -1266,7 +3493,7 @@ declare namespace muhammara {
|
|
|
1266
3493
|
title?: string;
|
|
1267
3494
|
open?: boolean;
|
|
1268
3495
|
richText?: boolean;
|
|
1269
|
-
flag?: AnnotOptionsFlag;
|
|
3496
|
+
flag?: AnnotOptionsFlag | number;
|
|
1270
3497
|
icon?: AnnotOptionsIcon;
|
|
1271
3498
|
date?: string;
|
|
1272
3499
|
subject?: string;
|
|
@@ -1362,7 +3589,7 @@ declare namespace muhammara {
|
|
|
1362
3589
|
header?:
|
|
1363
3590
|
boolean | (TextOptions & { alignToData?: boolean; cell?: TextBox });
|
|
1364
3591
|
border?: boolean | PolygonOptions;
|
|
1365
|
-
row?: TextOptions & { nth?:
|
|
3592
|
+
row?: TextOptions & { nth?: TableRowNth; cell?: TextBox };
|
|
1366
3593
|
/** Called once per overflow. A continuing destination must fit the row and repeated header or table() throws RangeError; ending the page without starting another throws Error. */
|
|
1367
3594
|
overflow?: (
|
|
1368
3595
|
this: Recipe,
|
|
@@ -1395,6 +3622,8 @@ declare namespace muhammara {
|
|
|
1395
3622
|
color?: Color;
|
|
1396
3623
|
stroke?: Color;
|
|
1397
3624
|
colorspace?: Colorspace;
|
|
3625
|
+
/** The Separation ink name of a `"separation"` color given by value. */
|
|
3626
|
+
colorName?: string;
|
|
1398
3627
|
lineWidth?: number;
|
|
1399
3628
|
width?: number;
|
|
1400
3629
|
opacity?: number;
|
|
@@ -1403,8 +3632,8 @@ declare namespace muhammara {
|
|
|
1403
3632
|
}
|
|
1404
3633
|
|
|
1405
3634
|
interface PathOptions extends DrawingOptions {
|
|
1406
|
-
lineCap?:
|
|
1407
|
-
lineJoin?:
|
|
3635
|
+
lineCap?: LineCap;
|
|
3636
|
+
lineJoin?: LineJoin;
|
|
1408
3637
|
miterLimit?: number;
|
|
1409
3638
|
}
|
|
1410
3639
|
|
|
@@ -1447,8 +3676,8 @@ declare namespace muhammara {
|
|
|
1447
3676
|
| readonly [number, number, number];
|
|
1448
3677
|
shaft?: number | readonly [number] | readonly [number, number];
|
|
1449
3678
|
double?: boolean;
|
|
1450
|
-
type?: 0 | 1 | 2 |
|
|
1451
|
-
at?:
|
|
3679
|
+
type?: 0 | 1 | 2 | ArrowType;
|
|
3680
|
+
at?: ArrowAt;
|
|
1452
3681
|
}
|
|
1453
3682
|
|
|
1454
3683
|
interface TriangleBaseOptions extends ShapeOptions {
|
|
@@ -1498,6 +3727,8 @@ declare namespace muhammara {
|
|
|
1498
3727
|
interface RectangleOptions
|
|
1499
3728
|
extends DrawingOptions, TransformOptions, LinkFillOptions {
|
|
1500
3729
|
borderRadius?: BorderRadius;
|
|
3730
|
+
/** Take `x` and `y` as PDF coordinates of the bottom-left corner instead of Recipe top-left coordinates. */
|
|
3731
|
+
useGivenCoords?: boolean;
|
|
1501
3732
|
}
|
|
1502
3733
|
|
|
1503
3734
|
interface LineStyleOptions {
|
|
@@ -1516,16 +3747,276 @@ declare namespace muhammara {
|
|
|
1516
3747
|
}
|
|
1517
3748
|
|
|
1518
3749
|
export class Recipe {
|
|
3750
|
+
/**
|
|
3751
|
+
* @param src - `Recipe.Source.NEW` ("new", or `Buffer.from("new")`) for a new PDF,
|
|
3752
|
+
* otherwise the path or Buffer of the PDF to edit.
|
|
3753
|
+
* @param output - The output path. For a path source it defaults to
|
|
3754
|
+
* the source path; for a Buffer source the result is only returned by
|
|
3755
|
+
* `endPDF()` unless an output path is given.
|
|
3756
|
+
* @param options - The options for pdfDoc
|
|
3757
|
+
* @param options.version - The PDF version of a new PDF: 1.0 through
|
|
3758
|
+
* 1.7 or 2.0. Other values fall back to 1.7.
|
|
3759
|
+
* @param options.author - The author
|
|
3760
|
+
* @param options.title - The title
|
|
3761
|
+
* @param options.subject - The subject
|
|
3762
|
+
* @param options.keywords - The array of keywords
|
|
3763
|
+
* @param options.colorspace - The default colorspace, one
|
|
3764
|
+
* of the `Recipe.Colorspace` values.
|
|
3765
|
+
* @param options.password - Owner password; also opens a protected source.
|
|
3766
|
+
* @param options.userPassword - The 'view' password; also enables encryption.
|
|
3767
|
+
* @param options.ownerPassword - The 'edit' password.
|
|
3768
|
+
* @param options.userProtectionFlag - Encryption permission flags, see `permission()`.
|
|
3769
|
+
* @param options.fontSrcPath - Directory location(s) of additional fonts.
|
|
3770
|
+
* @throws {Error} If an existing source PDF cannot be read or opened for editing.
|
|
3771
|
+
*/
|
|
1519
3772
|
constructor(
|
|
1520
3773
|
src: string,
|
|
1521
3774
|
output?: string | null,
|
|
1522
3775
|
options?: Recipe.RecipeOptions,
|
|
1523
3776
|
);
|
|
1524
3777
|
|
|
3778
|
+
/** Special Recipe sources, such as `Recipe.Source.NEW` for a new PDF. */
|
|
3779
|
+
static readonly Source: {
|
|
3780
|
+
readonly NEW: "new";
|
|
3781
|
+
};
|
|
3782
|
+
/** How text that does not fit a text-box line is handled. */
|
|
3783
|
+
static readonly TextWrap: {
|
|
3784
|
+
readonly AUTO: "auto";
|
|
3785
|
+
readonly CLIP: "clip";
|
|
3786
|
+
readonly TRIM: "trim";
|
|
3787
|
+
readonly ELLIPSIS: "ellipsis";
|
|
3788
|
+
};
|
|
3789
|
+
/** Horizontal alignments of text inside a text box. */
|
|
3790
|
+
static readonly TextAlign: {
|
|
3791
|
+
readonly LEFT: "left";
|
|
3792
|
+
readonly CENTER: "center";
|
|
3793
|
+
readonly RIGHT: "right";
|
|
3794
|
+
readonly JUSTIFY: "justify";
|
|
3795
|
+
};
|
|
3796
|
+
/** Which table rows the `row` options apply to. */
|
|
3797
|
+
static readonly TableRowNth: {
|
|
3798
|
+
readonly EVEN: "even";
|
|
3799
|
+
readonly ODD: "odd";
|
|
3800
|
+
};
|
|
3801
|
+
/** Line cap styles for the `lineCap` options. */
|
|
3802
|
+
static readonly LineCap: {
|
|
3803
|
+
readonly BUTT: "butt";
|
|
3804
|
+
readonly ROUND: "round";
|
|
3805
|
+
readonly SQUARE: "square";
|
|
3806
|
+
};
|
|
3807
|
+
/** Line join styles for the `lineJoin` options. */
|
|
3808
|
+
static readonly LineJoin: {
|
|
3809
|
+
readonly MITER: "miter";
|
|
3810
|
+
readonly ROUND: "round";
|
|
3811
|
+
readonly BEVEL: "bevel";
|
|
3812
|
+
};
|
|
3813
|
+
/** The arrow point placed at the `arrow()` coordinates. */
|
|
3814
|
+
static readonly ArrowAt: {
|
|
3815
|
+
readonly HEAD: "head";
|
|
3816
|
+
readonly TAIL: "tail";
|
|
3817
|
+
};
|
|
3818
|
+
/** Arrow head shapes for the `arrow()` type option. */
|
|
3819
|
+
static readonly ArrowType: {
|
|
3820
|
+
readonly TRIANGLE: "triangle";
|
|
3821
|
+
readonly DART: "dart";
|
|
3822
|
+
readonly KITE: "kite";
|
|
3823
|
+
};
|
|
3824
|
+
/** How `triangle()` traits define the triangle. */
|
|
3825
|
+
static readonly TriangleTrait: {
|
|
3826
|
+
readonly SSS: "sss";
|
|
3827
|
+
readonly SAS: "sas";
|
|
3828
|
+
readonly ASA: "asa";
|
|
3829
|
+
readonly VTX: "vtx";
|
|
3830
|
+
};
|
|
3831
|
+
/** The triangle point placed at the `triangle()` coordinates. */
|
|
3832
|
+
static readonly TrianglePosition: {
|
|
3833
|
+
readonly A: "a";
|
|
3834
|
+
readonly B: "b";
|
|
3835
|
+
readonly C: "c";
|
|
3836
|
+
readonly CENTROID: "centroid";
|
|
3837
|
+
readonly CIRCUMCENTER: "circumcenter";
|
|
3838
|
+
readonly INCENTER: "incenter";
|
|
3839
|
+
};
|
|
3840
|
+
/** Page orientations reported in page metadata. */
|
|
3841
|
+
static readonly PageLayout: {
|
|
3842
|
+
readonly PORTRAIT: "portrait";
|
|
3843
|
+
readonly LANDSCAPE: "landscape";
|
|
3844
|
+
};
|
|
3845
|
+
/** Named page sizes for `createPage()`. */
|
|
3846
|
+
static readonly PageSize: {
|
|
3847
|
+
readonly EXECUTIVE: "executive";
|
|
3848
|
+
readonly FOLIO: "folio";
|
|
3849
|
+
readonly LEGAL: "legal";
|
|
3850
|
+
readonly LETTER: "letter";
|
|
3851
|
+
readonly LEDGER: "ledger";
|
|
3852
|
+
readonly TABLOID: "tabloid";
|
|
3853
|
+
readonly A0: "a0";
|
|
3854
|
+
readonly A1: "a1";
|
|
3855
|
+
readonly A2: "a2";
|
|
3856
|
+
readonly A3: "a3";
|
|
3857
|
+
readonly A4: "a4";
|
|
3858
|
+
readonly A5: "a5";
|
|
3859
|
+
readonly A6: "a6";
|
|
3860
|
+
readonly A7: "a7";
|
|
3861
|
+
readonly A8: "a8";
|
|
3862
|
+
readonly A9: "a9";
|
|
3863
|
+
readonly A10: "a10";
|
|
3864
|
+
readonly B0: "b0";
|
|
3865
|
+
readonly B1: "b1";
|
|
3866
|
+
readonly B2: "b2";
|
|
3867
|
+
readonly B3: "b3";
|
|
3868
|
+
readonly B4: "b4";
|
|
3869
|
+
readonly B5: "b5";
|
|
3870
|
+
readonly B6: "b6";
|
|
3871
|
+
readonly B7: "b7";
|
|
3872
|
+
readonly B8: "b8";
|
|
3873
|
+
readonly B9: "b9";
|
|
3874
|
+
readonly B10: "b10";
|
|
3875
|
+
readonly C0: "c0";
|
|
3876
|
+
readonly C1: "c1";
|
|
3877
|
+
readonly C2: "c2";
|
|
3878
|
+
readonly C3: "c3";
|
|
3879
|
+
readonly C4: "c4";
|
|
3880
|
+
readonly C5: "c5";
|
|
3881
|
+
readonly C6: "c6";
|
|
3882
|
+
readonly C7: "c7";
|
|
3883
|
+
readonly C8: "c8";
|
|
3884
|
+
readonly C9: "c9";
|
|
3885
|
+
readonly C10: "c10";
|
|
3886
|
+
readonly RA0: "ra0";
|
|
3887
|
+
readonly RA1: "ra1";
|
|
3888
|
+
readonly RA2: "ra2";
|
|
3889
|
+
readonly RA3: "ra3";
|
|
3890
|
+
readonly RA4: "ra4";
|
|
3891
|
+
readonly SRA0: "sra0";
|
|
3892
|
+
readonly SRA1: "sra1";
|
|
3893
|
+
readonly SRA2: "sra2";
|
|
3894
|
+
readonly SRA3: "sra3";
|
|
3895
|
+
readonly SRA4: "sra4";
|
|
3896
|
+
};
|
|
3897
|
+
/** Horizontal alignments. */
|
|
3898
|
+
static readonly HorizontalAlign: {
|
|
3899
|
+
readonly LEFT: "left";
|
|
3900
|
+
readonly CENTER: "center";
|
|
3901
|
+
readonly RIGHT: "right";
|
|
3902
|
+
};
|
|
3903
|
+
/** Vertical alignments. */
|
|
3904
|
+
static readonly VerticalAlign: {
|
|
3905
|
+
readonly TOP: "top";
|
|
3906
|
+
readonly CENTER: "center";
|
|
3907
|
+
readonly BOTTOM: "bottom";
|
|
3908
|
+
};
|
|
3909
|
+
/** Font styles for `registerFont()`. */
|
|
3910
|
+
static readonly FontStyle: {
|
|
3911
|
+
readonly REGULAR: "regular";
|
|
3912
|
+
readonly BOLD: "bold";
|
|
3913
|
+
readonly ITALIC: "italic";
|
|
3914
|
+
readonly BOLD_ITALIC: "bold-italic";
|
|
3915
|
+
};
|
|
3916
|
+
/** User access permission names for `permission()`. */
|
|
3917
|
+
static readonly Permission: {
|
|
3918
|
+
readonly PRINT: "print";
|
|
3919
|
+
readonly MODIFY: "modify";
|
|
3920
|
+
readonly COPY: "copy";
|
|
3921
|
+
readonly EDIT: "edit";
|
|
3922
|
+
readonly FILL_FORM: "fillform";
|
|
3923
|
+
readonly EXTRACT: "extract";
|
|
3924
|
+
readonly ASSEMBLE: "assemble";
|
|
3925
|
+
readonly PRINT_BEST: "printbest";
|
|
3926
|
+
};
|
|
3927
|
+
/** Named coordinates, accepted wherever a `RecipeCoordinate` is. */
|
|
3928
|
+
static readonly Coordinate: {
|
|
3929
|
+
readonly CENTER: "center";
|
|
3930
|
+
};
|
|
3931
|
+
/** Colorspaces accepted by the `colorspace` options. */
|
|
3932
|
+
static readonly Colorspace: {
|
|
3933
|
+
readonly RGB: "rgb";
|
|
3934
|
+
readonly CMYK: "cmyk";
|
|
3935
|
+
readonly GRAY: "gray";
|
|
3936
|
+
readonly SEPARATION: "separation";
|
|
3937
|
+
};
|
|
3938
|
+
/** Annotation subtypes for `annot()`. */
|
|
3939
|
+
static readonly AnnotSubtype: {
|
|
3940
|
+
readonly TEXT: "Text";
|
|
3941
|
+
readonly LINK: "Link";
|
|
3942
|
+
readonly FREE_TEXT: "FreeText";
|
|
3943
|
+
readonly LINE: "Line";
|
|
3944
|
+
readonly SQUARE: "Square";
|
|
3945
|
+
readonly CIRCLE: "Circle";
|
|
3946
|
+
readonly POLYGON: "Polygon";
|
|
3947
|
+
readonly POLY_LINE: "PolyLine";
|
|
3948
|
+
readonly HIGHLIGHT: "Highlight";
|
|
3949
|
+
readonly UNDERLINE: "Underline";
|
|
3950
|
+
readonly SQUIGGLY: "Squiggly";
|
|
3951
|
+
readonly STRIKE_OUT: "StrikeOut";
|
|
3952
|
+
readonly CARET: "Caret";
|
|
3953
|
+
readonly STAMP: "Stamp";
|
|
3954
|
+
readonly INK: "Ink";
|
|
3955
|
+
readonly POPUP: "Popup";
|
|
3956
|
+
readonly FILE_ATTACHMENT: "FileAttachment";
|
|
3957
|
+
readonly SOUND: "Sound";
|
|
3958
|
+
readonly MOVIE: "Movie";
|
|
3959
|
+
readonly SCREEN: "Screen";
|
|
3960
|
+
readonly WIDGET: "Widget";
|
|
3961
|
+
readonly PRINTER_MARK: "PrinterMark";
|
|
3962
|
+
readonly TRAP_NET: "TrapNet";
|
|
3963
|
+
readonly WATERMARK: "Watermark";
|
|
3964
|
+
readonly THREE_D: "3D";
|
|
3965
|
+
readonly REDACT: "Redact";
|
|
3966
|
+
readonly PROJECTION: "Projection";
|
|
3967
|
+
readonly RICH_MEDIA: "RichMedia";
|
|
3968
|
+
};
|
|
3969
|
+
/** Annotation flag names for the `flag` options. */
|
|
3970
|
+
static readonly AnnotFlag: {
|
|
3971
|
+
readonly INVISIBLE: "invisible";
|
|
3972
|
+
readonly HIDDEN: "hidden";
|
|
3973
|
+
readonly PRINT: "print";
|
|
3974
|
+
readonly NO_ZOOM: "nozoom";
|
|
3975
|
+
readonly NO_ROTATE: "norotate";
|
|
3976
|
+
readonly NO_VIEW: "noview";
|
|
3977
|
+
readonly READ_ONLY: "readonly";
|
|
3978
|
+
readonly LOCKED: "locked";
|
|
3979
|
+
readonly TOGGLE_NO_VIEW: "togglenoview";
|
|
3980
|
+
readonly LOCKED_CONTENTS: "lockedcontents";
|
|
3981
|
+
};
|
|
3982
|
+
/** Special `chroma()` names that run a command instead of naming a color. */
|
|
3983
|
+
static readonly ChromaCommand: {
|
|
3984
|
+
readonly LOAD: "!load";
|
|
3985
|
+
};
|
|
3986
|
+
/** Text annotation icons for the `icon` option. */
|
|
3987
|
+
static readonly AnnotIcon: {
|
|
3988
|
+
readonly COMMENT: "Comment";
|
|
3989
|
+
readonly KEY: "Key";
|
|
3990
|
+
readonly NOTE: "Note";
|
|
3991
|
+
readonly HELP: "Help";
|
|
3992
|
+
readonly NEW_PARAGRAPH: "NewParagraph";
|
|
3993
|
+
readonly PARAGRAPH: "Paragraph";
|
|
3994
|
+
readonly INSERT: "Insert";
|
|
3995
|
+
};
|
|
3996
|
+
|
|
1525
3997
|
readonly position: { x: number; y: number };
|
|
1526
3998
|
/** Current document metadata, keyed by one-based page number. */
|
|
1527
3999
|
readonly metadata: Recipe.Metadata;
|
|
4000
|
+
/**
|
|
4001
|
+
* Read PDF metadata: the page count and, keyed by one-based page number,
|
|
4002
|
+
* each page's media box, rotation, layout and size.
|
|
4003
|
+
* @param inSrc - A PDF path or Buffer to read instead of
|
|
4004
|
+
* the recipe source. Reading another PDF does not change the recipe state.
|
|
4005
|
+
* @returns The PDF metadata.
|
|
4006
|
+
* @throws {Error} If the PDF cannot be read or has no pages.
|
|
4007
|
+
*/
|
|
1528
4008
|
read(inSrc?: string | Buffer): Recipe.ReadMetadata;
|
|
4009
|
+
/**
|
|
4010
|
+
* Register a callback procedure with MuhammaraJS.
|
|
4011
|
+
* @param key - Name assigned to the callback. When a named function is
|
|
4012
|
+
* registered, and its given name is what is to be used to access it, the key is unnecessary.
|
|
4013
|
+
* @param callback - Callback procedure that can be accessed through MuhammaraJS.
|
|
4014
|
+
* It is added to the shared Recipe prototype, so every Recipe instance gets it.
|
|
4015
|
+
* @throws {string} If the callback function is unnamed when no key is provided.
|
|
4016
|
+
* @throws {string} If the key conflicts with an existing Recipe prototype member.
|
|
4017
|
+
* @throws {string} If the callback is not a function.
|
|
4018
|
+
* @returns The recipe instance.
|
|
4019
|
+
*/
|
|
1529
4020
|
register<Arguments extends unknown[], Result>(
|
|
1530
4021
|
key: string,
|
|
1531
4022
|
callback: Recipe.ExtensionCallback<Arguments, Result>,
|
|
@@ -1540,41 +4031,167 @@ declare namespace muhammara {
|
|
|
1540
4031
|
options?: Recipe.RecipeOptions,
|
|
1541
4032
|
);
|
|
1542
4033
|
|
|
4034
|
+
/**
|
|
4035
|
+
* Create a comment annotation: a Text annotation with the Comment icon. It is
|
|
4036
|
+
* written when the PDF ends.
|
|
4037
|
+
* @param text - The text content; defaults to ''.
|
|
4038
|
+
* @param x - The coordinate x
|
|
4039
|
+
* @param y - The top coordinate y; (x, y) is the top-left corner, as for `annot()`.
|
|
4040
|
+
* @param options - The options
|
|
4041
|
+
* @param options.title - The title.
|
|
4042
|
+
* @param options.date - The date.
|
|
4043
|
+
* @param options.width - The rectangle width, as for `annot()`.
|
|
4044
|
+
* @param options.height - The rectangle height, extending down from y.
|
|
4045
|
+
* @param options.open - Open the annotation by default?; defaults to false.
|
|
4046
|
+
* @param options.richText - Display with rich text format, text will be transformed automatically, or you may pass in your own rich text starts with "<?xml..."
|
|
4047
|
+
* @param options.replies - Array of annotation replies, each with text and optional title, date, subject, richText, and flag.
|
|
4048
|
+
* @param options.flag - The flag property, one of the `Recipe.AnnotFlag` values.
|
|
4049
|
+
* @returns The recipe instance.
|
|
4050
|
+
*/
|
|
1543
4051
|
comment(
|
|
1544
4052
|
text: string,
|
|
1545
|
-
x:
|
|
1546
|
-
y:
|
|
4053
|
+
x: Recipe.RecipeCoordinate,
|
|
4054
|
+
y: Recipe.RecipeCoordinate,
|
|
1547
4055
|
options?: Recipe.CommentOptions,
|
|
1548
4056
|
): Recipe;
|
|
1549
4057
|
|
|
4058
|
+
/**
|
|
4059
|
+
* Add a clickable URL link to the current page.
|
|
4060
|
+
* @param url - The URL to open.
|
|
4061
|
+
* @param x - The top-left x coordinate.
|
|
4062
|
+
* @param y - The top-left y coordinate.
|
|
4063
|
+
* @param width - The link width.
|
|
4064
|
+
* @param height - The link height.
|
|
4065
|
+
* @returns The recipe instance.
|
|
4066
|
+
* @throws {TypeError} If no page is active.
|
|
4067
|
+
*/
|
|
1550
4068
|
link(
|
|
1551
4069
|
url: string,
|
|
1552
|
-
x:
|
|
1553
|
-
y:
|
|
4070
|
+
x: Recipe.RecipeCoordinate,
|
|
4071
|
+
y: Recipe.RecipeCoordinate,
|
|
1554
4072
|
width: number,
|
|
1555
4073
|
height: number,
|
|
1556
4074
|
): Recipe;
|
|
1557
4075
|
|
|
4076
|
+
/**
|
|
4077
|
+
* Create an annotation. It is written when the PDF ends.
|
|
4078
|
+
* @todo support for rich text RC
|
|
4079
|
+
* @param x - The left edge of the annotation rectangle.
|
|
4080
|
+
* @param y - The top edge of the annotation rectangle. Like
|
|
4081
|
+
* `rectangle()` and `link()`, (x, y) is the rectangle's top-left corner, and
|
|
4082
|
+
* the rectangle extends `options.height` down from it.
|
|
4083
|
+
* @param subtype - The annotation subtype, one of the
|
|
4084
|
+
* `Recipe.AnnotSubtype` values.
|
|
4085
|
+
* @param options - The options
|
|
4086
|
+
* @param options.text - The annotation content; defaults to ''.
|
|
4087
|
+
* @param options.title - The title.
|
|
4088
|
+
* @param options.open - Open the annotation. Annotation will be closed by default. Specific to text annotations; subtype='Text'; defaults to false.
|
|
4089
|
+
* @param options.richText - Rich text
|
|
4090
|
+
* @param options.flag - The flag property, one of the `Recipe.AnnotFlag` values.
|
|
4091
|
+
* @param options.icon - The icon of a Text annotation, one
|
|
4092
|
+
* of the `Recipe.AnnotIcon` values. Viewers show 'Note' when it is omitted.
|
|
4093
|
+
* @param options.width - Width
|
|
4094
|
+
* @param options.height - Height
|
|
4095
|
+
* @param options.date - Date of annotation
|
|
4096
|
+
* @param options.subject - The subject.
|
|
4097
|
+
* @param options.replies - Array of annotation replies
|
|
4098
|
+
* @param options.border - The border width.
|
|
4099
|
+
* @param options.color - The annotation color, as HexColor,
|
|
4100
|
+
* PercentColor or DecimalColor.
|
|
4101
|
+
* @param options.opacity - Annotation opacity from 0 (transparent) to 1 (opaque); defaults to 1.
|
|
4102
|
+
* @param options.followOriginalPageRotation - Preserve the original page rotation when positioning the annotation; defaults to false.
|
|
4103
|
+
* @returns The recipe instance.
|
|
4104
|
+
*/
|
|
1558
4105
|
annot(
|
|
1559
|
-
x:
|
|
1560
|
-
y:
|
|
4106
|
+
x: Recipe.RecipeCoordinate,
|
|
4107
|
+
y: Recipe.RecipeCoordinate,
|
|
1561
4108
|
subtype: Recipe.AnnotSubtype,
|
|
1562
4109
|
options?: Recipe.AnnotOptions,
|
|
1563
4110
|
): Recipe;
|
|
1564
4111
|
|
|
4112
|
+
/**
|
|
4113
|
+
* Append pages from the other pdf to the current pdf. An active page is
|
|
4114
|
+
* finished first, so appended pages follow it in the output.
|
|
4115
|
+
* @param pdfSrc - The path for the other pdf.
|
|
4116
|
+
* @param pages - ] - A one-based page; defaults to [.
|
|
4117
|
+
* number or array of page numbers and inclusive ranges. Omitting it appends all
|
|
4118
|
+
* pages; endpoints beyond the source are clamped to its final page.
|
|
4119
|
+
* @returns The recipe instance.
|
|
4120
|
+
* @throws {RangeError} If a selection is not a positive integer or a two-value
|
|
4121
|
+
* range in ascending order.
|
|
4122
|
+
* @throws {Error} If pages were deleted with deletePage() on this Recipe.
|
|
4123
|
+
* @throws {Error} If the source PDF cannot be read.
|
|
4124
|
+
*/
|
|
1565
4125
|
appendPage(
|
|
1566
4126
|
pdfSrc: string,
|
|
1567
4127
|
pages?: number | (number | [number, number])[],
|
|
1568
4128
|
): Recipe;
|
|
1569
4129
|
|
|
4130
|
+
/**
|
|
4131
|
+
* Encrypt the pdf
|
|
4132
|
+
* @param options - The options
|
|
4133
|
+
* @param options.password - The permission password.
|
|
4134
|
+
* @param options.ownerPassword - The password for editing.
|
|
4135
|
+
* @param options.userPassword - The password for viewing & encryption.
|
|
4136
|
+
* @param options.userProtectionFlag - The flag for the security level, see `permission()`.
|
|
4137
|
+
* @returns The recipe instance. The file is encrypted by `endPDF()`;
|
|
4138
|
+
* Buffer sources are not encrypted.
|
|
4139
|
+
*/
|
|
1570
4140
|
encrypt(options?: Recipe.EncryptOptions): Recipe;
|
|
1571
4141
|
|
|
4142
|
+
/**
|
|
4143
|
+
* Register a custom font
|
|
4144
|
+
* @param fontName - The font name used in text, matched case-insensitively; defaults to ''.
|
|
4145
|
+
* @param fontSrcPath - The path to the font file; defaults to ''.
|
|
4146
|
+
* @param type - The style this file provides,; defaults to 'regular'.
|
|
4147
|
+
* one of the `Recipe.FontStyle` values or its short form r, b, i or bi.
|
|
4148
|
+
* Any other value registers the regular style.
|
|
4149
|
+
* @returns The recipe instance.
|
|
4150
|
+
*/
|
|
1572
4151
|
registerFont(
|
|
1573
4152
|
fontName: string,
|
|
1574
4153
|
fontSrcPath: string,
|
|
1575
4154
|
type?: Recipe.RecipeFontStyle,
|
|
1576
4155
|
): Recipe;
|
|
1577
4156
|
|
|
4157
|
+
/**
|
|
4158
|
+
* Place images to pdf
|
|
4159
|
+
* @param imgSrc - The path for the image. [JPEG, PNG, TIFF, PDF]
|
|
4160
|
+
* @param x - The coordinate x of the top-left corner
|
|
4161
|
+
* @param y - The coordinate y of the top-left corner
|
|
4162
|
+
* @param options - The options
|
|
4163
|
+
* @returns The recipe instance.
|
|
4164
|
+
* @param options.page - The one-based page of a PDF source, or image of a
|
|
4165
|
+
* multi-image TIFF, as in `overlay()`; defaults to 1.
|
|
4166
|
+
* @param options.width - The new width. The frame outline width is
|
|
4167
|
+
* `options.lineWidth`.
|
|
4168
|
+
* @param options.height - The new height
|
|
4169
|
+
* @param options.scale - Scale the image from the original width and height.
|
|
4170
|
+
* @param options.keepAspectRatio - Keep the aspect ratio; defaults to true.
|
|
4171
|
+
* @param options.opacity - The opacity of the image and its frame.
|
|
4172
|
+
* @param options.align - A `Recipe.HorizontalAlign` value, optionally
|
|
4173
|
+
* followed by a space and a `Recipe.VerticalAlign` value, for example
|
|
4174
|
+
* "center center". Horizontal center moves the image left by half its width
|
|
4175
|
+
* and right moves it right by half; vertical center moves it up by half its
|
|
4176
|
+
* height and bottom moves it down by half from its top-left placement.
|
|
4177
|
+
* @param options.rotation - Rotate the image, in degrees.
|
|
4178
|
+
* @param options.rotationOrigin - [x, y] of the rotation origin; the
|
|
4179
|
+
* bottom-left corner of the drawn image when omitted.
|
|
4180
|
+
* @param options.fill - Paint the image box beneath the image.
|
|
4181
|
+
* @param options.stroke - Outline the image box above the image.
|
|
4182
|
+
* @param options.color - Outline color when `stroke` is not given.
|
|
4183
|
+
* @param options.lineWidth - The outline width; the outline lies inside
|
|
4184
|
+
* the image box, as a `rectangle()` stroke does.
|
|
4185
|
+
* @param options.debug - Outline the image box in green and mark the
|
|
4186
|
+
* placement point in red.
|
|
4187
|
+
* @param options.link - Make the image open this URL.
|
|
4188
|
+
* @throws {TypeError} If no page is active.
|
|
4189
|
+
* @throws {RangeError} If `page` is not an integer from 1 to 4294967296,
|
|
4190
|
+
* a size is not a finite number, or `miterLimit` is not a number of at
|
|
4191
|
+
* least 1.
|
|
4192
|
+
* @throws {TypeError} If `rotation` is not a finite number.
|
|
4193
|
+
* @throws {Error} If the image, or the PDF page `page` selects, cannot be read.
|
|
4194
|
+
*/
|
|
1578
4195
|
image(
|
|
1579
4196
|
imgSrc: string,
|
|
1580
4197
|
x: Recipe.RecipeCoordinate,
|
|
@@ -1582,16 +4199,65 @@ declare namespace muhammara {
|
|
|
1582
4199
|
options?: Recipe.ImageOptions,
|
|
1583
4200
|
): Recipe;
|
|
1584
4201
|
|
|
1585
|
-
|
|
4202
|
+
/**
|
|
4203
|
+
* @param options - The options (when missing obtains existing PDF information)
|
|
4204
|
+
* @param options.author - The author
|
|
4205
|
+
* @param options.title - The title
|
|
4206
|
+
* @param options.subject - The subject
|
|
4207
|
+
* @param options.keywords - The array of keywords
|
|
4208
|
+
* @returns The existing information dictionary when options are omitted, otherwise the recipe instance.
|
|
4209
|
+
* A new PDF has no existing information, so the call without options returns undefined.
|
|
4210
|
+
* @throws {Error} If the source information cannot be read.
|
|
4211
|
+
*/
|
|
4212
|
+
info(options: Recipe.InfoOptions): Recipe;
|
|
4213
|
+
/**
|
|
4214
|
+
* Read the existing information dictionary of the source PDF.
|
|
4215
|
+
* @returns The information keyed by lower-cased entry name, or undefined
|
|
4216
|
+
* for a new PDF or a source without an Info dictionary.
|
|
4217
|
+
* @throws {Error} If the source information cannot be read.
|
|
4218
|
+
*/
|
|
4219
|
+
info(): Record<string, string> | undefined;
|
|
1586
4220
|
|
|
4221
|
+
/**
|
|
4222
|
+
* @param key - The key
|
|
4223
|
+
* @param value - The value; other values are converted with toString().
|
|
4224
|
+
* @returns The recipe instance.
|
|
4225
|
+
* @throws {TypeError} If the key or value is null or undefined.
|
|
4226
|
+
*/
|
|
1587
4227
|
custom(key: string, value: string): Recipe;
|
|
1588
4228
|
|
|
4229
|
+
/**
|
|
4230
|
+
* Insert a page from the other pdf
|
|
4231
|
+
* @param afterPageNumber - The one-based page number to insert after; 0 inserts before the first page.
|
|
4232
|
+
* @param pdfSrc - The path for the other pdf
|
|
4233
|
+
* @param srcPageNumber - The one-based page number to be inserted from the other pdf.
|
|
4234
|
+
* @returns The recipe instance. Pages are inserted by `endPDF()`;
|
|
4235
|
+
* Buffer sources do not support insertion.
|
|
4236
|
+
* @throws {Error} If pages were deleted with deletePage() on this Recipe.
|
|
4237
|
+
* @throws {Error} If afterPageNumber is not a number.
|
|
4238
|
+
* @throws {TypeError} If pdfSrc or srcPageNumber is missing.
|
|
4239
|
+
*/
|
|
1589
4240
|
insertPage(
|
|
1590
4241
|
afterPageNumber: number,
|
|
1591
4242
|
pdfSrc: string,
|
|
1592
4243
|
srcPageNumber: number,
|
|
1593
4244
|
): Recipe;
|
|
1594
4245
|
|
|
4246
|
+
/**
|
|
4247
|
+
* Overlay a pdf to the current pdf
|
|
4248
|
+
* @param pdfSrc - The path for the overlay pdf
|
|
4249
|
+
* @param x - The PDF x offset from the left edge, or options when using the two-argument form; defaults to 0.
|
|
4250
|
+
* @param y - The offset from the top edge; defaults to 0.
|
|
4251
|
+
* @param options - The options.
|
|
4252
|
+
* @param options.scale - Scale the overlay pdf, default is 1
|
|
4253
|
+
* @param options.page - Page of the overlay pdf, default is 1
|
|
4254
|
+
* @param options.keepAspectRatio - To keep the aspect ratio when scaling, default is true
|
|
4255
|
+
* @param options.fitWidth - To set the width to 100% (use with keepAspectRatio=true)
|
|
4256
|
+
* @param options.fitHeight - To set the height to 100% (use with keepAspectRatio=true)
|
|
4257
|
+
* @returns The recipe instance.
|
|
4258
|
+
* @throws {TypeError} If no page is active.
|
|
4259
|
+
* @throws {Error} If the overlay PDF cannot be read.
|
|
4260
|
+
*/
|
|
1595
4261
|
overlay(pdfSrc: string, options?: Recipe.OverlayOptions): Recipe;
|
|
1596
4262
|
overlay(
|
|
1597
4263
|
pdfSrc: string,
|
|
@@ -1600,34 +4266,147 @@ declare namespace muhammara {
|
|
|
1600
4266
|
options?: Recipe.OverlayOptions,
|
|
1601
4267
|
): Recipe;
|
|
1602
4268
|
|
|
4269
|
+
/**
|
|
4270
|
+
* Create a new page, specifying either actual width and height, or the name
|
|
4271
|
+
* of a supported page size (eg. 'letter', 'letter-size')
|
|
4272
|
+
* '-size' will be removed from string but is discouraged to use.
|
|
4273
|
+
* @param pageWidth - The page width, or a `Recipe.PageSize` name.
|
|
4274
|
+
* Known named medium sizes: executive, folio, legal, letter, ledger, tabloid, a0-a10, b0-b10, c0-c10, ra0-ra4, sra0-sra4.
|
|
4275
|
+
* Unknown names use the default letter size.
|
|
4276
|
+
* @param pageHeight - The page height, or rotation (90) when page size name given.
|
|
4277
|
+
* @param margins - page margin definitions.
|
|
4278
|
+
* @param margins.left - Left margin.
|
|
4279
|
+
* @param margins.right - Right margin.
|
|
4280
|
+
* @param margins.top - Top margin.
|
|
4281
|
+
* @param margins.bottom - Bottom margin.
|
|
4282
|
+
* @returns The recipe instance.
|
|
4283
|
+
* @throws {Error} If pages were deleted with deletePage() on this Recipe.
|
|
4284
|
+
*/
|
|
1603
4285
|
createPage(
|
|
1604
4286
|
pageWidth?: number,
|
|
1605
4287
|
pageHeight?: number,
|
|
1606
4288
|
margins?: Recipe.RecipeMargins,
|
|
1607
4289
|
): Recipe;
|
|
1608
4290
|
createPage(
|
|
1609
|
-
pageType:
|
|
4291
|
+
pageType: Recipe.PageSize,
|
|
1610
4292
|
rotation?: number,
|
|
1611
4293
|
margins?: Recipe.RecipeMargins,
|
|
1612
4294
|
): Recipe;
|
|
4295
|
+
/**
|
|
4296
|
+
* Set the rotation of the current page.
|
|
4297
|
+
* @param rotation - The page rotation in degrees, a multiple of 90.
|
|
4298
|
+
* @returns The recipe instance.
|
|
4299
|
+
* @throws {TypeError} If no page is active.
|
|
4300
|
+
*/
|
|
1613
4301
|
rotate(rotation: number): Recipe;
|
|
4302
|
+
/**
|
|
4303
|
+
* Finish a page. Without an active page this does nothing.
|
|
4304
|
+
* @returns The recipe instance.
|
|
4305
|
+
* @throws {Error} If the page cannot be written.
|
|
4306
|
+
*/
|
|
1614
4307
|
endPage(): Recipe;
|
|
4308
|
+
/**
|
|
4309
|
+
* Set a page box on the active new page.
|
|
4310
|
+
* @param box - An `ePDFPageBox*` constant or a `PageBox` name.
|
|
4311
|
+
* @param left - The PDF left coordinate.
|
|
4312
|
+
* @param bottom - The PDF bottom coordinate.
|
|
4313
|
+
* @param right - The PDF right coordinate.
|
|
4314
|
+
* @param top - The PDF top coordinate.
|
|
4315
|
+
* @returns The recipe instance.
|
|
4316
|
+
* @throws {RangeError} If the page box is unknown.
|
|
4317
|
+
* @throws {TypeError} If no page is active or a coordinate is a BigInt.
|
|
4318
|
+
*/
|
|
1615
4319
|
setPageBox(
|
|
1616
|
-
box: PDFPageBoxType,
|
|
4320
|
+
box: PDFPageBoxType | PageBox,
|
|
1617
4321
|
left: number,
|
|
1618
4322
|
bottom: number,
|
|
1619
4323
|
right: number,
|
|
1620
4324
|
top: number,
|
|
1621
4325
|
): Recipe;
|
|
1622
4326
|
|
|
4327
|
+
/**
|
|
4328
|
+
* Start editing a page
|
|
4329
|
+
* @param pageNumber - The one-based page number to be edited.
|
|
4330
|
+
* @returns The recipe instance.
|
|
4331
|
+
* @throws {Error} If the page does not exist in the source PDF.
|
|
4332
|
+
*/
|
|
1623
4333
|
editPage(pageNumber: number): Recipe;
|
|
1624
|
-
|
|
4334
|
+
/**
|
|
4335
|
+
* Delete one or more pages from an existing PDF.
|
|
4336
|
+
* Page numbers are one-based and refer to the original source document.
|
|
4337
|
+
* @param pageNumbers - Page number or page numbers to delete.
|
|
4338
|
+
* @param options - Deletion options.
|
|
4339
|
+
* @returns The recipe instance.
|
|
4340
|
+
* @throws {TypeError} If options is not an object or pruneReferences is
|
|
4341
|
+
* not a boolean.
|
|
4342
|
+
* @throws {RangeError} If a page number does not identify an original page.
|
|
4343
|
+
* @throws {Error} If the Recipe has no existing source, has ended, would delete
|
|
4344
|
+
* every page, combines deletion with page composition, or the page tree,
|
|
4345
|
+
* page labels or retained references cannot be rewritten. A failed call
|
|
4346
|
+
* leaves the queued deletions unchanged.
|
|
4347
|
+
*/
|
|
4348
|
+
deletePage(
|
|
4349
|
+
pageNumbers: number | number[],
|
|
4350
|
+
options?: DeletePageOptions,
|
|
4351
|
+
): Recipe;
|
|
1625
4352
|
|
|
4353
|
+
/**
|
|
4354
|
+
* Replace text shown with `Tj` in a page's single content stream. Each
|
|
4355
|
+
* operand is decoded through the font selected by `Tf` and compared with
|
|
4356
|
+
* `text`; a match is rewritten with `replacement`, encoded through the same
|
|
4357
|
+
* font in the operand's original literal or hex form. `TJ`, `'`, and `"`
|
|
4358
|
+
* operands and text split across operators are not replaced.
|
|
4359
|
+
*
|
|
4360
|
+
* @param text - Text to replace, as any Unicode string.
|
|
4361
|
+
* @param replacement - Replacement text. It can only use glyphs the font
|
|
4362
|
+
* already has; embedded subset fonts usually carry just their original
|
|
4363
|
+
* text's glyphs.
|
|
4364
|
+
* @param pageNumber - One-based page number.
|
|
4365
|
+
* @returns The Recipe instance.
|
|
4366
|
+
* @throws {TypeError} If text or replacement is not a string, or if the
|
|
4367
|
+
* page number is not a positive integer.
|
|
4368
|
+
* @throws {RangeError} If the source document has no such page.
|
|
4369
|
+
* @throws {Error} If the page does not have one indirect content stream, or
|
|
4370
|
+
* the matched font cannot be read, has a malformed `/Widths` array, or has
|
|
4371
|
+
* no glyph for a replacement character.
|
|
4372
|
+
*/
|
|
1626
4373
|
replaceText(text: string, replacement: string, pageNumber: number): Recipe;
|
|
4374
|
+
/**
|
|
4375
|
+
* Removes shown text from an existing page's content streams, and
|
|
4376
|
+
* optionally its Form XObjects.
|
|
4377
|
+
* @param pageNumber - One-based page number.
|
|
4378
|
+
* @param options - Removal options.
|
|
4379
|
+
* @returns The Recipe instance.
|
|
4380
|
+
* @throws {TypeError} If the page number is not a positive integer, or the
|
|
4381
|
+
* options are not an object.
|
|
4382
|
+
* @throws {RangeError} If the source document has no such page.
|
|
4383
|
+
* @throws {Error} If the page's Contents holds a direct stream.
|
|
4384
|
+
*/
|
|
4385
|
+
removeText(pageNumber: number, options?: RemoveTextOptions): Recipe;
|
|
1627
4386
|
|
|
4387
|
+
/**
|
|
4388
|
+
* Get page information
|
|
4389
|
+
* @param pageNumber - The one-based page number.
|
|
4390
|
+
* @returns The page information.
|
|
4391
|
+
* @throws {TypeError} If the page is unknown.
|
|
4392
|
+
*/
|
|
1628
4393
|
pageInfo(pageNumber: number): RecipePageInfo;
|
|
4394
|
+
/**
|
|
4395
|
+
* Get information about the current page.
|
|
4396
|
+
* @returns The current page information, or null when no page has been created or edited.
|
|
4397
|
+
*/
|
|
1629
4398
|
getCurrentPageInfo(): RecipePageInfo | null;
|
|
1630
4399
|
|
|
4400
|
+
/**
|
|
4401
|
+
* Set/Get current page margins.
|
|
4402
|
+
* @param left - Left margin width or an object holding margin properties to be set.
|
|
4403
|
+
* Valid margin property names are: left, right, top, bottom.
|
|
4404
|
+
* @param right - Right margin width.
|
|
4405
|
+
* @param top - Top margin height.
|
|
4406
|
+
* @param bottom - Bottom margin height.
|
|
4407
|
+
* @returns When parameters are given, the value returned is the recipe handle. When no
|
|
4408
|
+
* parameters given, the return value is the current page margin object.
|
|
4409
|
+
*/
|
|
1631
4410
|
margins(): Required<Recipe.RecipeMargins>;
|
|
1632
4411
|
margins(margins: Recipe.RecipeMargins): Recipe;
|
|
1633
4412
|
margins(
|
|
@@ -1636,12 +4415,114 @@ declare namespace muhammara {
|
|
|
1636
4415
|
top?: number,
|
|
1637
4416
|
bottom?: number,
|
|
1638
4417
|
): Recipe;
|
|
4418
|
+
/**
|
|
4419
|
+
* Get the document information dictionary.
|
|
4420
|
+
* @returns The document information dictionary.
|
|
4421
|
+
*/
|
|
1639
4422
|
getPageInfo(): InfoDictionary;
|
|
4423
|
+
/**
|
|
4424
|
+
* Pause the current page content context.
|
|
4425
|
+
* @returns The recipe instance.
|
|
4426
|
+
* @throws {Error} If there is no active page content context.
|
|
4427
|
+
*/
|
|
1640
4428
|
pauseContext(): Recipe;
|
|
4429
|
+
/**
|
|
4430
|
+
* Resume the current page content context after it has been paused.
|
|
4431
|
+
* @returns The recipe instance.
|
|
4432
|
+
* @throws {Error} If there is no paused page content context.
|
|
4433
|
+
*/
|
|
1641
4434
|
resumeContext(): Recipe;
|
|
1642
|
-
|
|
4435
|
+
/**
|
|
4436
|
+
* Rotate subsequent content around a point in Recipe coordinates.
|
|
4437
|
+
* @param degrees - Clockwise rotation in degrees.
|
|
4438
|
+
* @param x - Rotation origin x coordinate; defaults to 0.
|
|
4439
|
+
* @param y - Rotation origin y coordinate; defaults to 0.
|
|
4440
|
+
* @returns The recipe instance.
|
|
4441
|
+
* @throws {TypeError} If no page is active.
|
|
4442
|
+
*/
|
|
4443
|
+
rotateContent(
|
|
4444
|
+
degrees: number,
|
|
4445
|
+
x?: Recipe.RecipeCoordinate,
|
|
4446
|
+
y?: Recipe.RecipeCoordinate,
|
|
4447
|
+
): Recipe;
|
|
4448
|
+
/**
|
|
4449
|
+
* Split the pdf
|
|
4450
|
+
* @param outputDir - The path for the output PDFs; defaults to ''.
|
|
4451
|
+
* @param prefix - The output filename prefix. Defaults to the
|
|
4452
|
+
* source filename; pass one for a Buffer source, which has no filename.
|
|
4453
|
+
* @returns The recipe instance. Each page is written to
|
|
4454
|
+
* `<outputDir>/<prefix>-<pageNumber>.pdf`.
|
|
4455
|
+
* @throws {Error} If the source reader was released by endPDF(), or an output
|
|
4456
|
+
* file cannot be written.
|
|
4457
|
+
*/
|
|
1643
4458
|
split(outputDir?: string, prefix?: string): Recipe;
|
|
1644
4459
|
|
|
4460
|
+
/**
|
|
4461
|
+
* Write text elements
|
|
4462
|
+
* @todo support break words
|
|
4463
|
+
* @param text - The text content; defaults to ''.
|
|
4464
|
+
* @param x - The coordinate x, or the options to continue at the current position
|
|
4465
|
+
* @param y - The coordinate y
|
|
4466
|
+
* @param options - The options
|
|
4467
|
+
* @param options.color - Text color (HexColor, PercentColor or DecimalColor)
|
|
4468
|
+
* @param options.opacity - opacity; defaults to 1.
|
|
4469
|
+
* @param options.rotation - Accept: +/- 0 through 360; defaults to 0.
|
|
4470
|
+
* @param options.rotationOrigin - ] - [originX, originY]; defaults to [x,y.
|
|
4471
|
+
* @param options.font - The font. 'Arial', 'Helvetica'; defaults to Helvetica.
|
|
4472
|
+
* @param options.size - The font size; defaults to 14.
|
|
4473
|
+
* @param options.charSpace - space to be added between characters, units in points; defaults to 0.
|
|
4474
|
+
* @param options.align - This is the alignment of the text in relationship to its position; defaults to 'left top'.
|
|
4475
|
+
* coordinates, specified as 'horizontal vertical': a `Recipe.HorizontalAlign` value, optionally followed by a
|
|
4476
|
+
* space and a `Recipe.VerticalAlign` value.
|
|
4477
|
+
* @param options.highlight - Text markup annotation.
|
|
4478
|
+
* @param options.underline - Text markup annotation.
|
|
4479
|
+
* @param options.strikeOut - Text markup annotation.
|
|
4480
|
+
* @param options.html - Interpret text as html
|
|
4481
|
+
* @param options.flow - Used to activate/deactivate text flow which is the; defaults to false.
|
|
4482
|
+
* ability to use multiple calls to 'text' to create an overall text box.
|
|
4483
|
+
* @param options.layout - An identifier of the layout to be associated with given text.
|
|
4484
|
+
* @param options.overflow - Called when the text is going to exceed the area
|
|
4485
|
+
* of the given text object. Intended for column layouts. Its parameter is (self) where 'self' is the recipe handle so
|
|
4486
|
+
* that other recipe interfaces can be called. The return value can be 'true' which indicates that text processing
|
|
4487
|
+
* should stop, or 'false' which indicates that the text should continue being processed with the original [x,y]
|
|
4488
|
+
* coordinates, or it can be an object containing a 'column' property indicating either a layout column index
|
|
4489
|
+
* or a set of [x,y] coordinates where the next set of layout columns should be positioned for the remaining text.
|
|
4490
|
+
* @param options.hilite - Used to hilite given text; defaults to false.
|
|
4491
|
+
* @param options.hilite.color - text hilite color (HexColor, PercentColor or DecimalColor); defaults to yellow.
|
|
4492
|
+
* @param options.hilite.opacity - text hilite color opacity; defaults to .5.
|
|
4493
|
+
* @param options.textBox - Text Box to fit in.
|
|
4494
|
+
* @param options.textBox.width - Text Box width; defaults to 100.
|
|
4495
|
+
* @param options.textBox.height - Text Box fixed height
|
|
4496
|
+
* @param options.textBox.minHeight - Text Box minimum height; defaults to 0.
|
|
4497
|
+
* @param options.textBox.padding - Text Box padding, [top, right, bottom, left]; defaults to 0.
|
|
4498
|
+
* @param options.textBox.lineHeight - Text Box line height; defaults to 0.
|
|
4499
|
+
* @param options.textBox.wrap - Text wrapping mechanism, may be true, false,; defaults to 'auto'.
|
|
4500
|
+
* or a `Recipe.TextWrap` value: 'auto', 'clip', 'trim', 'ellipsis'. All the option values that are not equivalent to 'auto' dictate
|
|
4501
|
+
* how the text which does not fit on a line is to be truncated. True is equivalent to 'auto'. False is equivalent to 'ellipsis'.
|
|
4502
|
+
* @param options.textBox.textAlign - Alignment inside text box, specified as 'horizontal vertical',; defaults to 'left top'.
|
|
4503
|
+
* where horizontal is a `Recipe.TextAlign` value and vertical a `Recipe.VerticalAlign` value.
|
|
4504
|
+
* @param options.textBox.clipIfExceedsBox - Render only complete lines that fit within the text box height; defaults to false.
|
|
4505
|
+
* @param options.textBox.onClip - Called as onClip(recipe, result) when clipping leaves text unrendered.
|
|
4506
|
+
* Do not call endPage() or endPDF() in this callback because the text operation is still active.
|
|
4507
|
+
* @param options.textBox.style - Text Box styles
|
|
4508
|
+
* @param options.textBox.style.lineWidth - Text Box border width; defaults to 2.
|
|
4509
|
+
* @param options.textBox.style.stroke - Text Box border color (HexColor, PercentColor or DecimalColor)
|
|
4510
|
+
* @param options.textBox.style.dash - ] - Text Box border border dash style [number, number]; defaults to [.
|
|
4511
|
+
* @param options.textBox.style.fill - Text Box border background color (HexColor, PercentColor or DecimalColor)
|
|
4512
|
+
* @param options.textBox.style.opacity - Text Box border background opacity; defaults to 1.
|
|
4513
|
+
* @param options.textBox.style.borderRadius - Border radius to apply to get rounded corners; defaults to 0.
|
|
4514
|
+
* @param options.title - Title of annotation
|
|
4515
|
+
* @param options.open - Open the annotation. Annotation will be closed by default. Specific to text annotations; subtype='Text'; defaults to false.
|
|
4516
|
+
* @param options.richText - Rich text in annotation
|
|
4517
|
+
* @param options.flag - The annotation flag, a `Recipe.AnnotFlag` value.
|
|
4518
|
+
* @param options.icon - The icon of annotation, a `Recipe.AnnotIcon` value. Specific to text annotations; defaults to 'Note'.
|
|
4519
|
+
* @param options.date - Date of text to show up on annotation
|
|
4520
|
+
* @param options.subject - Subject of annotation.
|
|
4521
|
+
* @param options.link - Make the text open this URL.
|
|
4522
|
+
* @returns The recipe instance. Without an active page nothing is drawn.
|
|
4523
|
+
* @throws {TypeError} If `options.charSpace` is not a finite number; nothing is drawn.
|
|
4524
|
+
* @throws {Error} If an overflow callback names an undefined layout, or a font cannot be loaded.
|
|
4525
|
+
*/
|
|
1645
4526
|
text(text: string, options?: Recipe.TextOptions): Recipe;
|
|
1646
4527
|
text(
|
|
1647
4528
|
text: string,
|
|
@@ -1649,10 +4530,43 @@ declare namespace muhammara {
|
|
|
1649
4530
|
y: Recipe.RecipeCoordinate,
|
|
1650
4531
|
options?: Recipe.TextOptions,
|
|
1651
4532
|
): Recipe;
|
|
4533
|
+
/**
|
|
4534
|
+
* Get text dimensions
|
|
4535
|
+
* @param text - text to be measured
|
|
4536
|
+
* @param options - The options
|
|
4537
|
+
* @param options.font - name of font from which measurements are to be taken; defaults to 'helvetica'.
|
|
4538
|
+
* @param options.size - size of font to be used in taking measurements; defaults to 14.
|
|
4539
|
+
* @param options.charSpace - character spacing being applied to the given text; defaults to 0.
|
|
4540
|
+
* @param options.bold - Measure with the bold style of the font.
|
|
4541
|
+
* @param options.italic - Measure with the italic style of the font.
|
|
4542
|
+
* @returns measurement components of given text: width, height, xMin, xMax, yMin, yMax
|
|
4543
|
+
* @throws {Error} If the font file cannot be loaded.
|
|
4544
|
+
*/
|
|
1652
4545
|
textDimensions(text: string, options?: Recipe.TextOptions): TextDimension;
|
|
4546
|
+
/**
|
|
4547
|
+
* Move text positioning down N lines in text box
|
|
4548
|
+
* @param lines - the number of lines to reposition x and y coordinates; defaults to 1.
|
|
4549
|
+
* @param returnCoords - indicate whether or not to return [x,y] coordinates; defaults to false.
|
|
4550
|
+
* @returns - when returnCoord false, the recipe object, when true, the new [x,y] coordinates.
|
|
4551
|
+
*/
|
|
1653
4552
|
movedown(lines?: number, returnCoords?: false): Recipe;
|
|
1654
4553
|
movedown(lines: number, returnCoords: true): number[];
|
|
1655
4554
|
movedown(lines?: number, returnCoords?: boolean): Recipe | number[];
|
|
4555
|
+
/**
|
|
4556
|
+
* Define text column layout
|
|
4557
|
+
* @param id - The identifier to be associated with the layout. (See 'text' layout option)
|
|
4558
|
+
* @param x - The coordinate x used to position text columns on page. When zero or omitted, left margin used.
|
|
4559
|
+
* @param y - The coordinate y used to position text columns on page. When zero or omitted, top margin used.
|
|
4560
|
+
* @param width - The width of a text column. When zero or omitted, space between left and right margin used.
|
|
4561
|
+
* @param height - The height of a text column. When zero or omitted, space between top and bottom margin used.
|
|
4562
|
+
* @param options - The options.
|
|
4563
|
+
* @param options.columns - Represents the number of columns in which to divide the given width.
|
|
4564
|
+
* @param options.gap - Defines the separation between layout columns, units in points; defaults to 18.
|
|
4565
|
+
* @param options.reset - True indicates that the a new layout should be produced for the given
|
|
4566
|
+
* layout id, so any previous layout associated with the given id will be lost.
|
|
4567
|
+
* @returns The recipe instance.
|
|
4568
|
+
* @throws {TypeError} If width or height is omitted while no page is active.
|
|
4569
|
+
*/
|
|
1656
4570
|
layout(
|
|
1657
4571
|
id: string | number,
|
|
1658
4572
|
x?: number,
|
|
@@ -1661,6 +4575,63 @@ declare namespace muhammara {
|
|
|
1661
4575
|
height?: number,
|
|
1662
4576
|
options?: Recipe.LayoutOptions,
|
|
1663
4577
|
): Recipe;
|
|
4578
|
+
/**
|
|
4579
|
+
* Display text data in tabular form
|
|
4580
|
+
* Rows and headers use their rendered text-box heights, including padding,
|
|
4581
|
+
* minimum heights, fixed heights, and HTML layout. Empty contents or no selected
|
|
4582
|
+
* columns leave the Recipe unchanged. Array-form order preserves exact keys.
|
|
4583
|
+
* Header text styles are independent of body styles: column header options
|
|
4584
|
+
* (or defaults) are overridden by table header options, then alignToData
|
|
4585
|
+
* and column hcell box overrides are applied.
|
|
4586
|
+
* @param x - The coordinate x used to position table on page
|
|
4587
|
+
* @param y - The coordinate y used to position table on page
|
|
4588
|
+
* @param contents - the data to be placed into the table
|
|
4589
|
+
* @param options - The options
|
|
4590
|
+
* @param options.height - The height designation of the table
|
|
4591
|
+
* @param options.order - Defines the order of the named columns in the table.
|
|
4592
|
+
* It can also be used to choose a subset of the actual data found in the given contents.
|
|
4593
|
+
* @param options.columns - Holds the defining options for columns in the table.
|
|
4594
|
+
* @param options.columns - [].name] - The name of the content data field to be associated with the column.
|
|
4595
|
+
* This field is mandatory when supplying column options.
|
|
4596
|
+
* @param options.columns - [].text] - The title to be applied to the column header.
|
|
4597
|
+
* When missing, the data field name is used.
|
|
4598
|
+
* @param options.columns - [].width=100] - The width of table column.
|
|
4599
|
+
* @param options.columns - [].cell] - Holds the options to be applied to a column table cell.
|
|
4600
|
+
* All textBox options from the 'text' interface can be used here.
|
|
4601
|
+
* @param options.columns - [].color] - Text color (HexColor, PercentColor or DecimalColor)
|
|
4602
|
+
* @param options.columns - [].opacity=1] - opacity
|
|
4603
|
+
* @param options.columns - [].font=Helvetica] - The font. 'Arial', 'Helvetica'...
|
|
4604
|
+
* @param options.columns - [].size=14] - The font size
|
|
4605
|
+
* @param options.columns - [].renderer] - function to be called which can be used to modify the text options for a particular
|
|
4606
|
+
* table cell. The function is called with `(text, data, field, row)`, where `text` is the text to be written in the cell,
|
|
4607
|
+
* `data` holds the text elements in the table row, `field` is the column field, and `row` is the one-based row number. The function returns an object with the text attributes that
|
|
4608
|
+
* are to be modified for the table cell.
|
|
4609
|
+
* @param options.header - When true, the column name associated with a column will; defaults to false.
|
|
4610
|
+
* appear at the top of the column. When presented as an object it is the set of unique options to be applied to column headers.
|
|
4611
|
+
* All 'text' interface options can be used.
|
|
4612
|
+
* @param options.header.cell - All textBox options from the 'text' interface can be used here.
|
|
4613
|
+
* @param options.border - Used to define table and cell border characteristics
|
|
4614
|
+
* @param options.border.width - Thickness of lines used in the border; defaults to .5.
|
|
4615
|
+
* @param options.border.stroke - line color (HexColor, PercentColor or DecimalColor)
|
|
4616
|
+
* @param options.overflow - Called when the next table entry is going to expand the table
|
|
4617
|
+
* beyond the given height or page boundary. Its parameters are (self, row) where 'self' is the recipe handle so
|
|
4618
|
+
* that other recipe interfaces can be called, and the row number of the data which caused the data overflow.
|
|
4619
|
+
* The callback's `this` is also the Recipe instance.
|
|
4620
|
+
* The return value can be 'true' which indicates that data processing should stop, or 'false' which indicates that
|
|
4621
|
+
* the data should continue being processed with the original [x,y] coordinates, or it can be an object containing
|
|
4622
|
+
* a 'position' property indicating the [x,y] coordinates where the next table for the remaining data should start.
|
|
4623
|
+
* @param options.row - text properties to be applied to all cells in a table row.
|
|
4624
|
+
* @param options.row.cell - All textBox options from the 'text' interface can be used here.
|
|
4625
|
+
* @param options.row.nth - A `Recipe.TableRowNth` value, indicating that the
|
|
4626
|
+
* properties should be applied only to 'even' or 'odd' rows.
|
|
4627
|
+
* @returns The recipe instance.
|
|
4628
|
+
* @throws {TypeError} If no page is active.
|
|
4629
|
+
* @throws {RangeError} If the overflow callback continues into an area too small
|
|
4630
|
+
* for the pending row and its repeated header. Return true to stop, or provide
|
|
4631
|
+
* enough space; rows are not split and the callback is called once per overflow.
|
|
4632
|
+
* @throws {Error} If the overflow callback continues after ending the page
|
|
4633
|
+
* without starting another one.
|
|
4634
|
+
*/
|
|
1664
4635
|
table<RecordType extends object>(
|
|
1665
4636
|
x: number,
|
|
1666
4637
|
y: number,
|
|
@@ -1668,59 +4639,282 @@ declare namespace muhammara {
|
|
|
1668
4639
|
options?: Recipe.TableOptions<RecordType>,
|
|
1669
4640
|
): Recipe;
|
|
1670
4641
|
|
|
4642
|
+
/**
|
|
4643
|
+
* move the current position to target position
|
|
4644
|
+
* @param x - The coordinate x
|
|
4645
|
+
* @param y - The coordinate y
|
|
4646
|
+
* @returns The recipe instance.
|
|
4647
|
+
* @throws {TypeError} If no page is active.
|
|
4648
|
+
*/
|
|
1671
4649
|
moveTo(x: number, y: number): Recipe;
|
|
1672
4650
|
|
|
4651
|
+
/**
|
|
4652
|
+
* Draw a line from current position
|
|
4653
|
+
* @param x - The coordinate x
|
|
4654
|
+
* @param y - The coordinate y
|
|
4655
|
+
* @param options - The options
|
|
4656
|
+
* @returns The recipe instance.
|
|
4657
|
+
* @throws {TypeError} If no page is active.
|
|
4658
|
+
* @param options.color - HexColor, PercentColor or DecimalColor
|
|
4659
|
+
* @param options.stroke - HexColor, PercentColor or DecimalColor
|
|
4660
|
+
* @param options.lineWidth - The line width
|
|
4661
|
+
* @param options.opacity - how transparent should line be, from 0: invisible to 1: opaque
|
|
4662
|
+
* @param options.dash - The dash pattern [dashSize, gapSize] or [dashAndGapSize]
|
|
4663
|
+
* @param options.dashPhase - distance into dash pattern at which to start dash (default: 0, immediately)
|
|
4664
|
+
* @param options.lineCap - open line end style, a `Recipe.LineCap` value (default: 'round')
|
|
4665
|
+
* @param options.lineJoin - joined line end style, a `Recipe.LineJoin` value (default: 'round')
|
|
4666
|
+
* @param options.miterLimit - limit at which 'miter' joins are forced to 'bevel' (default: 1.414)
|
|
4667
|
+
*/
|
|
1673
4668
|
lineTo(x: number, y: number, options?: Recipe.LineToOptions): Recipe;
|
|
1674
4669
|
|
|
4670
|
+
/**
|
|
4671
|
+
* Draw a line through coordinate pairs, or from (startX, startY) to
|
|
4672
|
+
* (endX, endY) when called as `line(startX, startY, endX, endY, options?)`.
|
|
4673
|
+
* @param coordinates - The array of coordinate [[x,y], [m,n]], or the start x
|
|
4674
|
+
* @param options - The options, or the start y in the four-number form
|
|
4675
|
+
* @returns The recipe instance.
|
|
4676
|
+
* @param options.color - HexColor, PercentColor or DecimalColor
|
|
4677
|
+
* @param options.stroke - HexColor, PercentColor or DecimalColor
|
|
4678
|
+
* @param options.lineWidth - The line width
|
|
4679
|
+
* @param options.opacity - how transparent should line be, from 0: invisible to 1: opaque
|
|
4680
|
+
* @param options.dash - The dash pattern [dashSize, gapSize] or [dashAndGapSize]
|
|
4681
|
+
* @param options.dashPhase - distance into dash pattern at which to start dash (default: 0, immediately)
|
|
4682
|
+
* @param options.lineCap - open line end style, a `Recipe.LineCap` value (default: 'round')
|
|
4683
|
+
* @param options.lineJoin - joined line end style, a `Recipe.LineJoin` value (default: 'round')
|
|
4684
|
+
* @param options.miterLimit - limit at which 'miter' joins are forced to 'bevel' (default: 1.414)
|
|
4685
|
+
* @throws {TypeError} If no page is active.
|
|
4686
|
+
*/
|
|
1675
4687
|
line(coordinates: number[][], options?: Recipe.LineOptions): Recipe;
|
|
4688
|
+
line(
|
|
4689
|
+
startX: number,
|
|
4690
|
+
startY: number,
|
|
4691
|
+
endX: number,
|
|
4692
|
+
endY: number,
|
|
4693
|
+
options?: Recipe.LineOptions,
|
|
4694
|
+
): Recipe;
|
|
1676
4695
|
|
|
4696
|
+
/**
|
|
4697
|
+
* Draw a polygon
|
|
4698
|
+
* @param coordinates - The array of coordinate [[x,y], ... [m,n]]
|
|
4699
|
+
* @param options - The options
|
|
4700
|
+
* @returns The recipe instance.
|
|
4701
|
+
* @param options.color - HexColor, PercentColor or DecimalColor
|
|
4702
|
+
* @param options.stroke - HexColor, PercentColor or DecimalColor
|
|
4703
|
+
* @param options.fill - HexColor, PercentColor or DecimalColor
|
|
4704
|
+
* @param options.lineWidth - The line width
|
|
4705
|
+
* @param options.opacity - The opacity
|
|
4706
|
+
* @param options.dash - The dash pattern [dashSize, gapSize] or [dashAndGapSize]
|
|
4707
|
+
* @param options.dashPhase - distance into dash pattern at which to start dash (default: 0, immediately)
|
|
4708
|
+
* @param options.rotation - Accept: +/- 0 through 360. Default: 0
|
|
4709
|
+
* @param options.rotationOrigin - [originX, originY] Default: x, y
|
|
4710
|
+
* @param options.lineCap - open line end style, a `Recipe.LineCap` value (default: 'round')
|
|
4711
|
+
* @param options.lineJoin - joined line end style, a `Recipe.LineJoin` value (default: 'round')
|
|
4712
|
+
* @param options.miterLimit - limit at which 'miter' joins are forced to 'bevel' (default: 1.414)
|
|
4713
|
+
* @param options.link - Make the polygon's bounding box open this URL.
|
|
4714
|
+
* @throws {TypeError} If no page is active or there are no coordinates.
|
|
4715
|
+
*/
|
|
1677
4716
|
polygon(coordinates: number[][], options?: Recipe.PolygonOptions): Recipe;
|
|
1678
4717
|
|
|
4718
|
+
/**
|
|
4719
|
+
* Draw a circle
|
|
4720
|
+
* @param x - The coordinate x of the center
|
|
4721
|
+
* @param y - The coordinate y of the center
|
|
4722
|
+
* @param radius - The radius
|
|
4723
|
+
* @param options - The options
|
|
4724
|
+
* @param options.color - HexColor, PercentColor or DecimalColor
|
|
4725
|
+
* @param options.stroke - HexColor, PercentColor or DecimalColor
|
|
4726
|
+
* @param options.fill - HexColor, PercentColor or DecimalColor
|
|
4727
|
+
* @param options.lineWidth - The line width
|
|
4728
|
+
* @param options.opacity - The opacity
|
|
4729
|
+
* @param options.dash - The dash style [number, number]
|
|
4730
|
+
* @param options.link - Make the circle's bounding square open this URL.
|
|
4731
|
+
* @returns The recipe instance.
|
|
4732
|
+
* @throws {TypeError} If no page is active.
|
|
4733
|
+
*/
|
|
1679
4734
|
circle(
|
|
1680
|
-
x:
|
|
1681
|
-
y:
|
|
4735
|
+
x: Recipe.RecipeCoordinate,
|
|
4736
|
+
y: Recipe.RecipeCoordinate,
|
|
1682
4737
|
radius: number,
|
|
1683
4738
|
options?: Recipe.CircleOptions,
|
|
1684
4739
|
): Recipe;
|
|
1685
4740
|
|
|
4741
|
+
/**
|
|
4742
|
+
* Draw a rectangle
|
|
4743
|
+
* @param x - The coordinate x of the top-left corner
|
|
4744
|
+
* @param y - The coordinate y of the top-left corner
|
|
4745
|
+
* @param width - The width
|
|
4746
|
+
* @param height - The height
|
|
4747
|
+
* @param options - The options
|
|
4748
|
+
* @param options.color - HexColor, PercentColor or DecimalColor
|
|
4749
|
+
* @param options.stroke - HexColor, PercentColor or DecimalColor
|
|
4750
|
+
* @param options.fill - HexColor, PercentColor or DecimalColor
|
|
4751
|
+
* @param options.lineWidth - The line width
|
|
4752
|
+
* @param options.opacity - The opacity
|
|
4753
|
+
* @param options.dash - The dash style [number, number]
|
|
4754
|
+
* @param options.rotation - Accept: +/- 0 through 360. Default: 0
|
|
4755
|
+
* @param options.rotationOrigin - [originX, originY] Default: x, y
|
|
4756
|
+
* @param options.borderRadius - Radius size for rounded corners.
|
|
4757
|
+
* When a one to four number array can be used to give specific sizees to each corner.
|
|
4758
|
+
* The numbering starts from the top, left corner, and goes clockwise around the text box.
|
|
4759
|
+
* Missing values in the array are filled in by opposite corner values.
|
|
4760
|
+
* @param options.link - Make the rectangle open this URL.
|
|
4761
|
+
* @param options.useGivenCoords - Take x and y as PDF coordinates of the bottom-left corner.
|
|
4762
|
+
* @returns The recipe instance.
|
|
4763
|
+
* @throws {TypeError} If no page is active.
|
|
4764
|
+
*/
|
|
1686
4765
|
rectangle(
|
|
1687
|
-
x:
|
|
1688
|
-
y:
|
|
4766
|
+
x: Recipe.RecipeCoordinate,
|
|
4767
|
+
y: Recipe.RecipeCoordinate,
|
|
1689
4768
|
width: number,
|
|
1690
4769
|
height: number,
|
|
1691
4770
|
options?: Recipe.RectangleOptions,
|
|
1692
4771
|
): Recipe;
|
|
1693
4772
|
|
|
4773
|
+
/**
|
|
4774
|
+
* Draw an ellipse
|
|
4775
|
+
* @param cx - x-coordinate of center point of ellipse
|
|
4776
|
+
* @param cy - y-coordinate of center point of ellipse
|
|
4777
|
+
* @param rx - radius length from the center point along x-axis
|
|
4778
|
+
* @param ry - radius length from the center point along y-axis
|
|
4779
|
+
* @param options -
|
|
4780
|
+
* @param options.color - HexColor, PercentColor or DecimalColor
|
|
4781
|
+
* @param options.stroke - HexColor, PercentColor or DecimalColor
|
|
4782
|
+
* @param {string|number[]}[ options.fill] - HexColor, PercentColor or DecimalColor
|
|
4783
|
+
* @param options.lineWidth - The line width
|
|
4784
|
+
* @param options.opacity - The opacity
|
|
4785
|
+
* @param options.dash - The dash style [number, number]
|
|
4786
|
+
* @param options.rotation - Accept: +/- 0 through 360. Default: 0
|
|
4787
|
+
* @param options.rotationOrigin - [originX, originY] Default: x, y
|
|
4788
|
+
* @returns The recipe instance.
|
|
4789
|
+
* @throws {TypeError} If no page is active.
|
|
4790
|
+
*/
|
|
1694
4791
|
ellipse(
|
|
1695
|
-
cx:
|
|
1696
|
-
cy:
|
|
4792
|
+
cx: Recipe.RecipeCoordinate,
|
|
4793
|
+
cy: Recipe.RecipeCoordinate,
|
|
1697
4794
|
rx: number,
|
|
1698
4795
|
ry: number,
|
|
1699
4796
|
options?: Recipe.EllipseOptions,
|
|
1700
4797
|
): Recipe;
|
|
4798
|
+
/**
|
|
4799
|
+
* Draw an arc of a circle.
|
|
4800
|
+
* @param x - the x coordinate of the arc center point
|
|
4801
|
+
* @param y - the y coordinate of the arc center point
|
|
4802
|
+
* @param radius - the distance from the given x,y coordinates from which to produce the arc
|
|
4803
|
+
* @param startAngle - the start of the arc in degree units +/- 0 through 360. Positive values go clockwise, Negative values, counterclockwise; defaults to 0.
|
|
4804
|
+
* @param endAngle - the end of the arc in degree units +/- 0 through 360. Positive values go clockwise, Negative values, counterclockwise; defaults to 360.
|
|
4805
|
+
* @param options -
|
|
4806
|
+
* @param options.color - HexColor, PercentColor or DecimalColor
|
|
4807
|
+
* @param options.stroke - HexColor, PercentColor or DecimalColor
|
|
4808
|
+
* @param {string|number[]}[ options.fill] - HexColor, PercentColor or DecimalColor
|
|
4809
|
+
* @param options.lineWidth - The line width
|
|
4810
|
+
* @param options.opacity - The opacity
|
|
4811
|
+
* @param options.dash - The dash style [number, number]
|
|
4812
|
+
* @param options.rotation - Accept: +/- 0 through 360; defaults to 0.
|
|
4813
|
+
* @param options.rotationOrigin - [originX, originY] Default: x, y
|
|
4814
|
+
* @returns The recipe instance.
|
|
4815
|
+
* @throws {TypeError} If no page is active.
|
|
4816
|
+
*/
|
|
1701
4817
|
arc(
|
|
1702
|
-
x:
|
|
1703
|
-
y:
|
|
4818
|
+
x: Recipe.RecipeCoordinate,
|
|
4819
|
+
y: Recipe.RecipeCoordinate,
|
|
1704
4820
|
radius: number,
|
|
1705
4821
|
startAngle?: number,
|
|
1706
4822
|
endAngle?: number,
|
|
1707
4823
|
options?: Recipe.EllipseOptions,
|
|
1708
4824
|
): Recipe;
|
|
4825
|
+
/**
|
|
4826
|
+
* Draw a closed sector of a circle.
|
|
4827
|
+
* @param x - the x coordinate of the pie center point
|
|
4828
|
+
* @param y - the y coordinate of the pie center point
|
|
4829
|
+
* @param radius - the distance from the center point to the arc
|
|
4830
|
+
* @param startAngle - the start of the arc in degree units; defaults to 0.
|
|
4831
|
+
* @param endAngle - the end of the arc in degree units; defaults to 360.
|
|
4832
|
+
* @param options - The path options.
|
|
4833
|
+
* @returns The recipe instance.
|
|
4834
|
+
* @throws {TypeError} If no page is active.
|
|
4835
|
+
*/
|
|
1709
4836
|
pie(
|
|
1710
|
-
x:
|
|
1711
|
-
y:
|
|
4837
|
+
x: Recipe.RecipeCoordinate,
|
|
4838
|
+
y: Recipe.RecipeCoordinate,
|
|
1712
4839
|
radius: number,
|
|
1713
4840
|
startAngle?: number,
|
|
1714
4841
|
endAngle?: number,
|
|
1715
4842
|
options?: Recipe.EllipseOptions,
|
|
1716
4843
|
): Recipe;
|
|
4844
|
+
/**
|
|
4845
|
+
* Set the line style for the current page content context.
|
|
4846
|
+
* @param options - The line style options.
|
|
4847
|
+
* @param options.width - The line width.
|
|
4848
|
+
* @param options.lineWidth - Alias for width.
|
|
4849
|
+
* @param options.cap - The PDF line cap style, a `LineCapStyle` value.
|
|
4850
|
+
* @param options.join - The PDF line join style: 0 miter, 1 round, 2 bevel.
|
|
4851
|
+
* @param options.miterLimit - The miter limit.
|
|
4852
|
+
* @param options.dash - The dash pattern.
|
|
4853
|
+
* @param options.dashPhase - The dash pattern phase.
|
|
4854
|
+
* @returns The recipe instance.
|
|
4855
|
+
* @throws {TypeError} If no page is active.
|
|
4856
|
+
*/
|
|
1717
4857
|
lineStyle(options?: Recipe.LineStyleOptions): Recipe;
|
|
4858
|
+
/**
|
|
4859
|
+
* Set the line width.
|
|
4860
|
+
*
|
|
4861
|
+
* @param width - The line width.
|
|
4862
|
+
* @returns The recipe instance.
|
|
4863
|
+
* @throws {TypeError} If no page is active.
|
|
4864
|
+
*/
|
|
1718
4865
|
lineWidth(width: number): Recipe;
|
|
1719
|
-
/**
|
|
4866
|
+
/**
|
|
4867
|
+
* Sets fill and stroke opacity.
|
|
4868
|
+
* @param opacity - From 0 (transparent) to 1 (opaque).
|
|
4869
|
+
* @returns The Recipe instance.
|
|
4870
|
+
* @throws {RangeError} If opacity is not a finite number from 0 to 1.
|
|
4871
|
+
*/
|
|
1720
4872
|
opacity(opacity: number): Recipe;
|
|
4873
|
+
/**
|
|
4874
|
+
* Fill the current path.
|
|
4875
|
+
*
|
|
4876
|
+
* This compatibility method currently has no effect.
|
|
4877
|
+
* @returns The recipe instance.
|
|
4878
|
+
*/
|
|
1721
4879
|
fill(): Recipe;
|
|
4880
|
+
/**
|
|
4881
|
+
* Stroke the current path.
|
|
4882
|
+
*
|
|
4883
|
+
* This compatibility method currently has no effect.
|
|
4884
|
+
* @returns The recipe instance.
|
|
4885
|
+
*/
|
|
1722
4886
|
stroke(): Recipe;
|
|
4887
|
+
/**
|
|
4888
|
+
* Fill and stroke the current path.
|
|
4889
|
+
*
|
|
4890
|
+
* This compatibility method currently has no effect.
|
|
4891
|
+
* @returns The recipe instance.
|
|
4892
|
+
*/
|
|
1723
4893
|
fillAndStroke(): Recipe;
|
|
4894
|
+
/**
|
|
4895
|
+
* Draw an N-sided regular polygon
|
|
4896
|
+
* @param cx - x-coordinate of center point of regular polygon
|
|
4897
|
+
* @param cy - y-coordinate of center point of regular polygon
|
|
4898
|
+
* @param radius - The radius, distance from the center of the polygon to a vertice.
|
|
4899
|
+
* @param sides - the number of sides of the regular polygon, at least 3;; defaults to 3.
|
|
4900
|
+
* or the options when the side count is omitted.
|
|
4901
|
+
* @param options - The options
|
|
4902
|
+
* @param options.color - HexColor or DecimalColor
|
|
4903
|
+
* @param options.stroke - HexColor or DecimalColor
|
|
4904
|
+
* @param options.fill - HexColor or DecimalColor
|
|
4905
|
+
* @param options.lineWidth - The line width
|
|
4906
|
+
* @param options.opacity - The opacity
|
|
4907
|
+
* @param options.dash - The dash style [number, number]
|
|
4908
|
+
* @param options.rotation - Accept: +/- 0 through 360; defaults to 0.
|
|
4909
|
+
* @param options.rotationOrigin - ] - [originX, originY]; defaults to [cx,cy.
|
|
4910
|
+
* @param options.rotationVertice - the number of the vertice to be used as rotation origin
|
|
4911
|
+
* @param options.skewX - the angle skew off the x-axis
|
|
4912
|
+
* @param options.skewY - the angle skew off the y-axis.
|
|
4913
|
+
* @param options.link - Make the polygon's bounding square open this URL.
|
|
4914
|
+
* @param options.debug - Also draw the circumscribed circle and center.
|
|
4915
|
+
* @returns The recipe instance.
|
|
4916
|
+
* @throws {TypeError} If no page is active.
|
|
4917
|
+
*/
|
|
1724
4918
|
n_gon(
|
|
1725
4919
|
cx: number,
|
|
1726
4920
|
cy: number,
|
|
@@ -1728,6 +4922,29 @@ declare namespace muhammara {
|
|
|
1728
4922
|
sides?: number | Recipe.NGonOptions,
|
|
1729
4923
|
options?: Recipe.NGonOptions,
|
|
1730
4924
|
): Recipe;
|
|
4925
|
+
/**
|
|
4926
|
+
* Draw an N pointed star
|
|
4927
|
+
* @param cx - x-coordinate of center point of regular polygon
|
|
4928
|
+
* @param cy - y-coordinate of center point of regular polygon
|
|
4929
|
+
* @param radius - The radius, distance from the center to a star point.
|
|
4930
|
+
* @param points - number of points on star, at least 5; or; defaults to 5.
|
|
4931
|
+
* the options when the point count is omitted.
|
|
4932
|
+
* @param options - The options
|
|
4933
|
+
* @param options.color - HexColor or DecimalColor
|
|
4934
|
+
* @param options.stroke - HexColor or DecimalColor
|
|
4935
|
+
* @param options.fill - HexColor or DecimalColor
|
|
4936
|
+
* @param options.lineWidth - The line width
|
|
4937
|
+
* @param options.opacity - The opacity
|
|
4938
|
+
* @param options.dash - The dash style [number, number]
|
|
4939
|
+
* @param options.rotation - Accept: +/- 0 through 360. Default: 0
|
|
4940
|
+
* @param options.rotationOrigin - [originX, originY] Default: x, y
|
|
4941
|
+
* @param options.skewX - the angle skew off the x-axis
|
|
4942
|
+
* @param options.skewY - the angle skew off the y-axis.
|
|
4943
|
+
* @param options.link - Make the star's bounding square open this URL.
|
|
4944
|
+
* @param options.debug - Also draw the circumscribed circle and center.
|
|
4945
|
+
* @returns The recipe instance.
|
|
4946
|
+
* @throws {TypeError} If no page is active.
|
|
4947
|
+
*/
|
|
1731
4948
|
star(
|
|
1732
4949
|
cx: number,
|
|
1733
4950
|
cy: number,
|
|
@@ -1735,6 +4952,38 @@ declare namespace muhammara {
|
|
|
1735
4952
|
points?: number | Recipe.ShapeOptions,
|
|
1736
4953
|
options?: Recipe.ShapeOptions,
|
|
1737
4954
|
): Recipe;
|
|
4955
|
+
/**
|
|
4956
|
+
* Draw a triangle, by specifying three side lengths, two side lengths and one inclusive angle, one side length and two adjacent angles, or with a set of vertices.
|
|
4957
|
+
* @param x - x-coordinate used to position triangle, by default associated with left vertex of triangle base.
|
|
4958
|
+
* @param y - y-coordinate used to position triangle, by default associated with left vertex of triangle base.
|
|
4959
|
+
* @param traits - the data defining the triangle. Angles are specified as degrees, sides in units of points (1/72 in.).
|
|
4960
|
+
* @param options - The options
|
|
4961
|
+
* @param options.traitID - indicates what type of data is being passed in the traits parameter,; defaults to 'sss'.
|
|
4962
|
+
* one of the `Recipe.TriangleTrait` values:
|
|
4963
|
+
* ('sss'- three side lengths, 'sas' - side-angle-side (sideA, <C, sideB), 'asa' - angle-side-angle (<B, sideC, <A),
|
|
4964
|
+
* or 'vtx' - three vertex points [x,y])
|
|
4965
|
+
* @param options.position - the position of the triangle to be set at the given x,y coordinates,; defaults to 'b'.
|
|
4966
|
+
* one of the `Recipe.TrianglePosition` values.
|
|
4967
|
+
* The values can be one of: 'A' - the A vertex (right vertex of triangle base), 'B' - the B vertex (left vertex of triangle base),
|
|
4968
|
+
* 'C' - the C vertex (apex of triangle), 'centroid', 'circumcenter', or 'incenter' of the triangle.
|
|
4969
|
+
* @param options.flipX - flip triangle up to down through rotation point; defaults to false.
|
|
4970
|
+
* @param options.flipY - flip triangle right to left through rotation point; defaults to false.
|
|
4971
|
+
* @param options.color - HexColor or DecimalColor
|
|
4972
|
+
* @param options.stroke - HexColor or DecimalColor
|
|
4973
|
+
* @param options.fill - HexColor or DecimalColor
|
|
4974
|
+
* @param options.lineWidth - The line width
|
|
4975
|
+
* @param options.opacity - The opacity
|
|
4976
|
+
* @param options.dash - The dash style [number, number]
|
|
4977
|
+
* @param options.rotation - Accept: +/- 0 through 360. Default: 0
|
|
4978
|
+
* @param options.rotationOrigin - [originX, originY] Default: x, y
|
|
4979
|
+
* @param options.skewX - the angle skew off the x-axis
|
|
4980
|
+
* @param options.skewY - the angle skew off the y-axis.
|
|
4981
|
+
* @returns The recipe instance.
|
|
4982
|
+
* @param options.link - Make the triangle's bounding box open this URL.
|
|
4983
|
+
* @param options.debug - Also draw the reference points and labels.
|
|
4984
|
+
* @throws {Error} If traits does not contain three values or does not define a valid triangle.
|
|
4985
|
+
* @throws {TypeError} If no page is active.
|
|
4986
|
+
*/
|
|
1738
4987
|
triangle(
|
|
1739
4988
|
x: number,
|
|
1740
4989
|
y: number,
|
|
@@ -1753,21 +5002,113 @@ declare namespace muhammara {
|
|
|
1753
5002
|
traits: Recipe.MutableTriangleVertices,
|
|
1754
5003
|
options: Recipe.TriangleVertexOptions,
|
|
1755
5004
|
): Recipe;
|
|
5005
|
+
/**
|
|
5006
|
+
* Draw an arrow
|
|
5007
|
+
* @param x - x-coordinate position
|
|
5008
|
+
* @param y - y-coordinate position
|
|
5009
|
+
* @param options - arrow and polygon options
|
|
5010
|
+
* @param options.type - indicates the type of arrow head to produce,; defaults to 0.
|
|
5011
|
+
* a `Recipe.ArrowType` value or its number (0-'triangle', 1-'dart', 2-'kite').
|
|
5012
|
+
* Note, that the value of base offset in head option overrides this value.
|
|
5013
|
+
* @param options.head - ] defines the length, width and base offset of arrow head; defaults to [10,20,0.
|
|
5014
|
+
* A single number can be used to assign both the length and width of arrow, giving the base offset value as zero.
|
|
5015
|
+
* @param options.shaft - ] defines the length and width of the arrow shaft; defaults to [10,10.
|
|
5016
|
+
* @param options.double - indicate double headed arrow production; defaults to false.
|
|
5017
|
+
* @param options.at - position and/or rotate at the `Recipe.ArrowAt` head or tail of arrow instead of at center.
|
|
5018
|
+
* @param options.debug - Draw the drop point; 2 also labels the reference points.
|
|
5019
|
+
* @returns The recipe instance.
|
|
5020
|
+
* @throws {TypeError} If no page is active.
|
|
5021
|
+
*/
|
|
1756
5022
|
arrow(x: number, y: number, options?: Recipe.ArrowOptions): Recipe;
|
|
5023
|
+
/**
|
|
5024
|
+
* Associate color values to names
|
|
5025
|
+
*
|
|
5026
|
+
* The colorspace parameter is optional. When it is missing, the colorspace
|
|
5027
|
+
* is automatically determined by the given color value. Note that the special
|
|
5028
|
+
* PDF color space called 'separation' may also be used. The color value is then
|
|
5029
|
+
* treated as the alternative color when the named 'separation' color is unavailable.
|
|
5030
|
+
*
|
|
5031
|
+
* If the 'name' parameter is `Recipe.ChromaCommand.LOAD` ('!load'), the second parameter is the name of a JSON
|
|
5032
|
+
* formatted file containing a formatted list of defined colors associated with the
|
|
5033
|
+
* color spaces rgb, cmyk, gray, or separation (think PANTONE color definitions).
|
|
5034
|
+
* This file will be merged with existing set of known colors. The color values
|
|
5035
|
+
* must be specified as hex values.
|
|
5036
|
+
*
|
|
5037
|
+
* For example,
|
|
5038
|
+
* {
|
|
5039
|
+
* 'rgb': {'purple':'ff00ff', 'red':'#ff0000'},
|
|
5040
|
+
* 'cmyk': {'cyan':'ff000000', 'magenta':'%0,100,0,0'},
|
|
5041
|
+
* 'gray': {'grey':'#33'}
|
|
5042
|
+
* }
|
|
5043
|
+
*
|
|
5044
|
+
* @param name - the name to be associated to given color value, or `Recipe.ChromaCommand.LOAD`
|
|
5045
|
+
* @param value - the color value (HexColor, DecimalColor, or PercentColor), or the path of the JSON file to load
|
|
5046
|
+
* @param colorspace - One of the `Recipe.Colorspace`; defaults to ''.
|
|
5047
|
+
* values; empty picks gray, rgb or cmyk from the value length.
|
|
5048
|
+
* @returns The recipe instance.
|
|
5049
|
+
* @throws {Error} If the file to load cannot be read or is not valid JSON.
|
|
5050
|
+
* @throws {Error} If a loaded color definition has an unrecognized colorspace.
|
|
5051
|
+
* @throws {Error} If a color value has an invalid size.
|
|
5052
|
+
* @throws {TypeError} If the colorspace is unknown.
|
|
5053
|
+
*/
|
|
1757
5054
|
chroma<ColorspaceValue extends string | undefined = undefined>(
|
|
1758
5055
|
name: string,
|
|
1759
5056
|
value: Recipe.Color,
|
|
1760
5057
|
colorspace?: Recipe.ValidColorspace<ColorspaceValue>,
|
|
1761
5058
|
): Recipe;
|
|
5059
|
+
/**
|
|
5060
|
+
* Encryption user access permissions
|
|
5061
|
+
*
|
|
5062
|
+
* This function supplies the numeric value for the encrypt function's 'userProtectionFlag'
|
|
5063
|
+
* option. When no argument is given, the default 'print' value is used.
|
|
5064
|
+
*
|
|
5065
|
+
* @param flags - One or more `Recipe.Permission` values; defaults to 'print'.
|
|
5066
|
+
* (print, modify, copy, edit, fillform, extract, assemble, printbest),
|
|
5067
|
+
* separated by commas, for example `[Permission.PRINT, Permission.COPY].join()`.
|
|
5068
|
+
* @returns The numeric user protection flag.
|
|
5069
|
+
* @throws {Error} If a name is not a `Recipe.Permission` value.
|
|
5070
|
+
*/
|
|
1762
5071
|
permission(flags?: Recipe.PermissionList): number;
|
|
5072
|
+
/**
|
|
5073
|
+
* Write the PDF object structure to a file.
|
|
5074
|
+
* @param output - The output file path.
|
|
5075
|
+
* @returns The recipe instance.
|
|
5076
|
+
* @throws {Error} If the source reader was released by endPDF(), or the
|
|
5077
|
+
* output file cannot be written.
|
|
5078
|
+
*/
|
|
1763
5079
|
structure(output: string): Recipe;
|
|
5080
|
+
/**
|
|
5081
|
+
* Convert HTML into Recipe text layout objects.
|
|
5082
|
+
* @param htmlCodes - The HTML source. Tag names are matched case-insensitively.
|
|
5083
|
+
* @param options - Text options used to initialize the objects.
|
|
5084
|
+
* @param options.font - The font of every object.
|
|
5085
|
+
* @param options.size - The base font size of every object.
|
|
5086
|
+
* @returns The parsed text layout objects: one per child node,
|
|
5087
|
+
* each with its value, tag, style flags, link, font size ratio and childs.
|
|
5088
|
+
*/
|
|
1764
5089
|
htmlToTextObjects(
|
|
1765
5090
|
htmlCodes: string,
|
|
1766
5091
|
options?: Recipe.TextOptions,
|
|
1767
5092
|
): Recipe.HtmlTextObject[];
|
|
1768
5093
|
|
|
5094
|
+
/**
|
|
5095
|
+
* End the pdfDoc. Finalization happens once; later calls do not rewrite the
|
|
5096
|
+
* PDF and invoke the callback with the completed output when applicable.
|
|
5097
|
+
* An active page is finished first, so a forgotten endPage() does not cost
|
|
5098
|
+
* that page. A failed finalization retires the Recipe and later calls
|
|
5099
|
+
* rethrow the original error.
|
|
5100
|
+
* @param callback - Called when the PDF is
|
|
5101
|
+
* finished: with the output Buffer for a Buffer source without an output
|
|
5102
|
+
* path, with the output path for a Buffer source with one, and without an
|
|
5103
|
+
* argument for a path source.
|
|
5104
|
+
* @returns The callback result, or undefined without a callback.
|
|
5105
|
+
* @throws {Error} If pages are being deleted while a page is still open.
|
|
5106
|
+
* @throws {Error} If finalization fails; later calls rethrow the same error.
|
|
5107
|
+
*/
|
|
1769
5108
|
endPDF(): void;
|
|
1770
5109
|
endPDF<T>(callback: (output?: Buffer | string) => T): T;
|
|
5110
|
+
/** The 6.x callback shape, also accepted as `Recipe.EndPDFCallback`. */
|
|
5111
|
+
endPDF<T>(callback: (buffer: Buffer) => T): T;
|
|
1771
5112
|
}
|
|
1772
5113
|
}
|
|
1773
5114
|
|