@f-o-t/pdf 0.1.0
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 +39 -0
- package/dist/generation/index.d.ts +268 -0
- package/dist/generation/index.js +26 -0
- package/dist/index.d.ts +808 -0
- package/dist/index.js +111 -0
- package/dist/parsing/index.d.ts +234 -0
- package/dist/parsing/index.js +16 -0
- package/dist/shared/chunk-10ftnz45.js +572 -0
- package/dist/shared/chunk-37mjkw9w.js +492 -0
- package/dist/shared/chunk-6dengthp.js +48 -0
- package/package.json +88 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF object types
|
|
3
|
+
*/
|
|
4
|
+
type PDFObjectType = "boolean" | "number" | "string" | "name" | "array" | "dictionary" | "stream" | "null" | "indirect";
|
|
5
|
+
/**
|
|
6
|
+
* PDF reference to indirect object
|
|
7
|
+
*/
|
|
8
|
+
type PDFRef = {
|
|
9
|
+
readonly objectNumber: number;
|
|
10
|
+
readonly generation: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* PDF indirect object
|
|
14
|
+
*/
|
|
15
|
+
type PDFIndirectObject = {
|
|
16
|
+
ref: PDFRef;
|
|
17
|
+
value: PDFValue;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* PDF value types
|
|
21
|
+
*/
|
|
22
|
+
type PDFValue = boolean | number | string | PDFName | PDFArray | PDFDictionary | PDFStream | null | PDFRef;
|
|
23
|
+
/**
|
|
24
|
+
* PDF Name object
|
|
25
|
+
*/
|
|
26
|
+
type PDFName = {
|
|
27
|
+
readonly type: "name";
|
|
28
|
+
readonly value: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* PDF Array
|
|
32
|
+
*/
|
|
33
|
+
type PDFArray = PDFValue[];
|
|
34
|
+
/**
|
|
35
|
+
* PDF Dictionary
|
|
36
|
+
*/
|
|
37
|
+
type PDFDictionary = Record<string, PDFValue>;
|
|
38
|
+
/**
|
|
39
|
+
* PDF Stream
|
|
40
|
+
*/
|
|
41
|
+
type PDFStream = {
|
|
42
|
+
readonly dictionary: PDFDictionary;
|
|
43
|
+
readonly data: Uint8Array;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* PDF Page size presets
|
|
47
|
+
*/
|
|
48
|
+
type PageSize = "A4" | "Letter" | "Legal" | "A3" | "A5" | "Tabloid" | {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* PDF Color
|
|
54
|
+
*/
|
|
55
|
+
type PDFColor = {
|
|
56
|
+
type: "rgb";
|
|
57
|
+
r: number;
|
|
58
|
+
g: number;
|
|
59
|
+
b: number;
|
|
60
|
+
} | {
|
|
61
|
+
type: "cmyk";
|
|
62
|
+
c: number;
|
|
63
|
+
m: number;
|
|
64
|
+
y: number;
|
|
65
|
+
k: number;
|
|
66
|
+
} | {
|
|
67
|
+
type: "gray";
|
|
68
|
+
gray: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Text options
|
|
72
|
+
*/
|
|
73
|
+
type TextOptions = {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
size?: number;
|
|
77
|
+
font?: string;
|
|
78
|
+
color?: PDFColor;
|
|
79
|
+
align?: "left" | "center" | "right";
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Rectangle options
|
|
83
|
+
*/
|
|
84
|
+
type RectOptions = {
|
|
85
|
+
x: number;
|
|
86
|
+
y: number;
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
fill?: PDFColor;
|
|
90
|
+
stroke?: PDFColor;
|
|
91
|
+
lineWidth?: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Line options
|
|
95
|
+
*/
|
|
96
|
+
type LineOptions = {
|
|
97
|
+
x1: number;
|
|
98
|
+
y1: number;
|
|
99
|
+
x2: number;
|
|
100
|
+
y2: number;
|
|
101
|
+
color?: PDFColor;
|
|
102
|
+
lineWidth?: number;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* PDF metadata
|
|
106
|
+
*/
|
|
107
|
+
type PDFMetadata = {
|
|
108
|
+
title?: string;
|
|
109
|
+
author?: string;
|
|
110
|
+
subject?: string;
|
|
111
|
+
keywords?: string[];
|
|
112
|
+
creator?: string;
|
|
113
|
+
producer?: string;
|
|
114
|
+
creationDate?: Date;
|
|
115
|
+
modificationDate?: Date;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* PDF version
|
|
119
|
+
*/
|
|
120
|
+
type PDFVersion = "1.4" | "1.5" | "1.6" | "1.7";
|
|
121
|
+
type PDFPageOptions = {
|
|
122
|
+
size?: PageSize;
|
|
123
|
+
parent?: PDFRef;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* PDF Page class
|
|
127
|
+
*/
|
|
128
|
+
declare class PDFPage {
|
|
129
|
+
ref: PDFRef;
|
|
130
|
+
size: PageSize;
|
|
131
|
+
parent?: PDFRef;
|
|
132
|
+
contentStream: string[];
|
|
133
|
+
private resources;
|
|
134
|
+
constructor(ref: PDFRef, options?: PDFPageOptions);
|
|
135
|
+
/**
|
|
136
|
+
* Get page dimensions in points
|
|
137
|
+
*/
|
|
138
|
+
getDimensions(): {
|
|
139
|
+
width: number;
|
|
140
|
+
height: number;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Set fill color
|
|
144
|
+
*/
|
|
145
|
+
private setFillColor;
|
|
146
|
+
/**
|
|
147
|
+
* Set stroke color
|
|
148
|
+
*/
|
|
149
|
+
private setStrokeColor;
|
|
150
|
+
/**
|
|
151
|
+
* Draw text on the page
|
|
152
|
+
*/
|
|
153
|
+
drawText(text: string, options: TextOptions): void;
|
|
154
|
+
/**
|
|
155
|
+
* Draw a rectangle
|
|
156
|
+
*/
|
|
157
|
+
drawRectangle(options: RectOptions): void;
|
|
158
|
+
/**
|
|
159
|
+
* Draw a line
|
|
160
|
+
*/
|
|
161
|
+
drawLine(options: LineOptions): void;
|
|
162
|
+
/**
|
|
163
|
+
* Get content stream reference
|
|
164
|
+
*/
|
|
165
|
+
getContentStreamRef(): PDFRef;
|
|
166
|
+
/**
|
|
167
|
+
* Generate content stream as PDFStream
|
|
168
|
+
*/
|
|
169
|
+
toContentStream(): PDFStream;
|
|
170
|
+
/**
|
|
171
|
+
* Convert page to PDF dictionary
|
|
172
|
+
*/
|
|
173
|
+
toDictionary(): PDFDictionary;
|
|
174
|
+
}
|
|
175
|
+
type PDFDocumentOptions = {
|
|
176
|
+
version?: PDFVersion;
|
|
177
|
+
metadata?: PDFMetadata;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Main PDF Document class for generation
|
|
181
|
+
*
|
|
182
|
+
* @property version - PDF version (1.4, 1.5, 1.6, or 1.7)
|
|
183
|
+
* @property metadata - Document metadata (title, author, etc.)
|
|
184
|
+
* @property catalog - Reference to the document catalog
|
|
185
|
+
* @property pages - Reference to the pages tree root
|
|
186
|
+
*/
|
|
187
|
+
declare class PDFDocument {
|
|
188
|
+
version: PDFVersion;
|
|
189
|
+
metadata: PDFMetadata;
|
|
190
|
+
private objects;
|
|
191
|
+
private nextObjectNumber;
|
|
192
|
+
catalog: PDFRef;
|
|
193
|
+
pages: PDFRef;
|
|
194
|
+
private pagesArray;
|
|
195
|
+
constructor(options?: PDFDocumentOptions);
|
|
196
|
+
/**
|
|
197
|
+
* Allocate a new object reference
|
|
198
|
+
*/
|
|
199
|
+
private allocateRef;
|
|
200
|
+
/**
|
|
201
|
+
* Add a page to the document
|
|
202
|
+
*/
|
|
203
|
+
addPage(options?: PDFPageOptions): PDFPage;
|
|
204
|
+
/**
|
|
205
|
+
* Save PDF to bytes
|
|
206
|
+
*/
|
|
207
|
+
save(): Uint8Array;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* PDF Standard 14 Fonts
|
|
211
|
+
* These fonts are guaranteed to be available in all PDF readers
|
|
212
|
+
*/
|
|
213
|
+
declare const STANDARD_FONTS: {
|
|
214
|
+
readonly "Times-Roman": "Times-Roman";
|
|
215
|
+
readonly "Times-Bold": "Times-Bold";
|
|
216
|
+
readonly "Times-Italic": "Times-Italic";
|
|
217
|
+
readonly "Times-BoldItalic": "Times-BoldItalic";
|
|
218
|
+
readonly Helvetica: "Helvetica";
|
|
219
|
+
readonly "Helvetica-Bold": "Helvetica-Bold";
|
|
220
|
+
readonly "Helvetica-Oblique": "Helvetica-Oblique";
|
|
221
|
+
readonly "Helvetica-BoldOblique": "Helvetica-BoldOblique";
|
|
222
|
+
readonly Courier: "Courier";
|
|
223
|
+
readonly "Courier-Bold": "Courier-Bold";
|
|
224
|
+
readonly "Courier-Oblique": "Courier-Oblique";
|
|
225
|
+
readonly "Courier-BoldOblique": "Courier-BoldOblique";
|
|
226
|
+
readonly Symbol: "Symbol";
|
|
227
|
+
readonly ZapfDingbats: "ZapfDingbats";
|
|
228
|
+
};
|
|
229
|
+
type StandardFont = keyof typeof STANDARD_FONTS;
|
|
230
|
+
/**
|
|
231
|
+
* Font families for convenience
|
|
232
|
+
*/
|
|
233
|
+
declare const FONT_FAMILIES: {
|
|
234
|
+
times: {
|
|
235
|
+
regular: StandardFont;
|
|
236
|
+
bold: StandardFont;
|
|
237
|
+
italic: StandardFont;
|
|
238
|
+
boldItalic: StandardFont;
|
|
239
|
+
};
|
|
240
|
+
helvetica: {
|
|
241
|
+
regular: StandardFont;
|
|
242
|
+
bold: StandardFont;
|
|
243
|
+
oblique: StandardFont;
|
|
244
|
+
boldOblique: StandardFont;
|
|
245
|
+
};
|
|
246
|
+
courier: {
|
|
247
|
+
regular: StandardFont;
|
|
248
|
+
bold: StandardFont;
|
|
249
|
+
oblique: StandardFont;
|
|
250
|
+
boldOblique: StandardFont;
|
|
251
|
+
};
|
|
252
|
+
symbol: {
|
|
253
|
+
regular: StandardFont;
|
|
254
|
+
};
|
|
255
|
+
zapfDingbats: {
|
|
256
|
+
regular: StandardFont;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Check if a font is a standard PDF font
|
|
261
|
+
*/
|
|
262
|
+
declare function isStandardFont(font: string): font is StandardFont;
|
|
263
|
+
/**
|
|
264
|
+
* Get font object reference name
|
|
265
|
+
*/
|
|
266
|
+
declare function getFontRefName(font: StandardFont): string;
|
|
267
|
+
/**
|
|
268
|
+
* Serialize a PDF value to string
|
|
269
|
+
*/
|
|
270
|
+
declare function serializeValue(value: PDFValue): string;
|
|
271
|
+
/**
|
|
272
|
+
* Serialize a PDF stream
|
|
273
|
+
*/
|
|
274
|
+
declare function serializeStream(stream: PDFStream): Uint8Array;
|
|
275
|
+
/**
|
|
276
|
+
* Serialize an indirect object
|
|
277
|
+
*/
|
|
278
|
+
declare function serializeObject(objectNumber: number, generation: number, value: any): Uint8Array;
|
|
279
|
+
/**
|
|
280
|
+
* PDF token types
|
|
281
|
+
*/
|
|
282
|
+
declare enum TokenType {
|
|
283
|
+
NUMBER = "NUMBER",
|
|
284
|
+
STRING = "STRING",
|
|
285
|
+
NAME = "NAME",
|
|
286
|
+
BOOLEAN = "BOOLEAN",
|
|
287
|
+
NULL = "NULL",
|
|
288
|
+
ARRAY_START = "ARRAY_START",
|
|
289
|
+
ARRAY_END = "ARRAY_END",
|
|
290
|
+
DICT_START = "DICT_START",
|
|
291
|
+
DICT_END = "DICT_END",
|
|
292
|
+
OBJ = "OBJ",
|
|
293
|
+
ENDOBJ = "ENDOBJ",
|
|
294
|
+
STREAM = "STREAM",
|
|
295
|
+
ENDSTREAM = "ENDSTREAM",
|
|
296
|
+
XREF = "XREF",
|
|
297
|
+
TRAILER = "TRAILER",
|
|
298
|
+
STARTXREF = "STARTXREF",
|
|
299
|
+
R = "R",
|
|
300
|
+
EOF = "EOF"
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* PDF token
|
|
304
|
+
*/
|
|
305
|
+
interface Token {
|
|
306
|
+
type: TokenType;
|
|
307
|
+
value: any;
|
|
308
|
+
position: number;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* PDF Lexer
|
|
312
|
+
*/
|
|
313
|
+
declare class PDFLexer {
|
|
314
|
+
private data;
|
|
315
|
+
private position;
|
|
316
|
+
constructor(data: Uint8Array);
|
|
317
|
+
/**
|
|
318
|
+
* Get next token
|
|
319
|
+
*/
|
|
320
|
+
nextToken(): Token;
|
|
321
|
+
/**
|
|
322
|
+
* Peek at next character without consuming
|
|
323
|
+
*/
|
|
324
|
+
private peek;
|
|
325
|
+
/**
|
|
326
|
+
* Skip whitespace and comments
|
|
327
|
+
*/
|
|
328
|
+
private skipWhitespace;
|
|
329
|
+
/**
|
|
330
|
+
* Read a name token
|
|
331
|
+
*/
|
|
332
|
+
private readName;
|
|
333
|
+
/**
|
|
334
|
+
* Read a string token
|
|
335
|
+
*/
|
|
336
|
+
private readString;
|
|
337
|
+
/**
|
|
338
|
+
* Read a number token
|
|
339
|
+
*/
|
|
340
|
+
private readNumber;
|
|
341
|
+
/**
|
|
342
|
+
* Read a keyword token
|
|
343
|
+
*/
|
|
344
|
+
private readKeyword;
|
|
345
|
+
/**
|
|
346
|
+
* Check if character is delimiter
|
|
347
|
+
*/
|
|
348
|
+
private isDelimiter;
|
|
349
|
+
/**
|
|
350
|
+
* Check if byte is whitespace
|
|
351
|
+
*/
|
|
352
|
+
private isWhitespace;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* PDF Parser
|
|
356
|
+
*/
|
|
357
|
+
declare class PDFParser {
|
|
358
|
+
private lexer;
|
|
359
|
+
private currentToken;
|
|
360
|
+
private nextToken;
|
|
361
|
+
private data;
|
|
362
|
+
constructor(data: Uint8Array);
|
|
363
|
+
/**
|
|
364
|
+
* Parse a PDF value
|
|
365
|
+
*/
|
|
366
|
+
parseValue(): PDFValue;
|
|
367
|
+
/**
|
|
368
|
+
* Parse number or reference (number number R)
|
|
369
|
+
*/
|
|
370
|
+
private parseNumberOrRef;
|
|
371
|
+
/**
|
|
372
|
+
* Parse string
|
|
373
|
+
*/
|
|
374
|
+
private parseString;
|
|
375
|
+
/**
|
|
376
|
+
* Parse name
|
|
377
|
+
*/
|
|
378
|
+
private parseName;
|
|
379
|
+
/**
|
|
380
|
+
* Parse boolean
|
|
381
|
+
*/
|
|
382
|
+
private parseBoolean;
|
|
383
|
+
/**
|
|
384
|
+
* Parse null
|
|
385
|
+
*/
|
|
386
|
+
private parseNull;
|
|
387
|
+
/**
|
|
388
|
+
* Parse array
|
|
389
|
+
*/
|
|
390
|
+
private parseArray;
|
|
391
|
+
/**
|
|
392
|
+
* Parse dictionary
|
|
393
|
+
*/
|
|
394
|
+
private parseDictionary;
|
|
395
|
+
/**
|
|
396
|
+
* Parse indirect object
|
|
397
|
+
*/
|
|
398
|
+
parseIndirectObject(): {
|
|
399
|
+
ref: PDFRef;
|
|
400
|
+
value: PDFValue;
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* Parse stream (dictionary already parsed)
|
|
404
|
+
*/
|
|
405
|
+
private parseStream;
|
|
406
|
+
/**
|
|
407
|
+
* Advance to next token
|
|
408
|
+
*/
|
|
409
|
+
private advance;
|
|
410
|
+
/**
|
|
411
|
+
* Check if more tokens available
|
|
412
|
+
*/
|
|
413
|
+
hasMore(): boolean;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Parsed PDF Document
|
|
417
|
+
*/
|
|
418
|
+
interface ParsedPDF {
|
|
419
|
+
version: string;
|
|
420
|
+
catalog: PDFRef;
|
|
421
|
+
pages: PDFPage2[];
|
|
422
|
+
objects: Map<number, any>;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Parsed PDF Page
|
|
426
|
+
*/
|
|
427
|
+
interface PDFPage2 {
|
|
428
|
+
ref: PDFRef;
|
|
429
|
+
size: {
|
|
430
|
+
width: number;
|
|
431
|
+
height: number;
|
|
432
|
+
};
|
|
433
|
+
content: string;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* PDF Reader - reads and parses existing PDFs
|
|
437
|
+
*/
|
|
438
|
+
declare class PDFReader {
|
|
439
|
+
private data;
|
|
440
|
+
private objects;
|
|
441
|
+
constructor(data: Uint8Array);
|
|
442
|
+
/**
|
|
443
|
+
* Parse PDF file
|
|
444
|
+
*/
|
|
445
|
+
parse(): ParsedPDF;
|
|
446
|
+
/**
|
|
447
|
+
* Find startxref offset
|
|
448
|
+
*/
|
|
449
|
+
private findStartXRef;
|
|
450
|
+
/**
|
|
451
|
+
* Parse xref table
|
|
452
|
+
*/
|
|
453
|
+
private parseXRefTable;
|
|
454
|
+
/**
|
|
455
|
+
* Parse trailer dictionary
|
|
456
|
+
*/
|
|
457
|
+
private parseTrailer;
|
|
458
|
+
/**
|
|
459
|
+
* Read all objects from xref table
|
|
460
|
+
*/
|
|
461
|
+
private readObjects;
|
|
462
|
+
/**
|
|
463
|
+
* Parse PDF version from header
|
|
464
|
+
*/
|
|
465
|
+
private parseVersion;
|
|
466
|
+
/**
|
|
467
|
+
* Parse pages from catalog
|
|
468
|
+
*/
|
|
469
|
+
private parsePages;
|
|
470
|
+
/**
|
|
471
|
+
* Parse a single page
|
|
472
|
+
*/
|
|
473
|
+
private parsePage;
|
|
474
|
+
/**
|
|
475
|
+
* Extract text from content stream
|
|
476
|
+
*/
|
|
477
|
+
private extractText;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Create a PDF Name object
|
|
481
|
+
*/
|
|
482
|
+
declare function createName(value: string): PDFName;
|
|
483
|
+
/**
|
|
484
|
+
* Create a PDF Reference
|
|
485
|
+
*/
|
|
486
|
+
declare function createRef(objectNumber: number, generation?: number): PDFRef;
|
|
487
|
+
/**
|
|
488
|
+
* Create a PDF Dictionary
|
|
489
|
+
*/
|
|
490
|
+
declare function createDictionary(entries?: Record<string, PDFValue>): PDFDictionary;
|
|
491
|
+
/**
|
|
492
|
+
* Create a PDF Array
|
|
493
|
+
*/
|
|
494
|
+
declare function createArray(values?: PDFValue[]): PDFArray;
|
|
495
|
+
/**
|
|
496
|
+
* Create a PDF Stream
|
|
497
|
+
*/
|
|
498
|
+
declare function createStream(data: Uint8Array, dictionary?: PDFDictionary): PDFStream;
|
|
499
|
+
/**
|
|
500
|
+
* Type guard for PDF Reference
|
|
501
|
+
*/
|
|
502
|
+
declare function isRef(value: unknown): value is PDFRef;
|
|
503
|
+
/**
|
|
504
|
+
* Type guard for PDF Name
|
|
505
|
+
*/
|
|
506
|
+
declare function isName(value: unknown): value is PDFName;
|
|
507
|
+
/**
|
|
508
|
+
* Type guard for PDF Dictionary
|
|
509
|
+
*/
|
|
510
|
+
declare function isDictionary(value: unknown): value is PDFDictionary;
|
|
511
|
+
/**
|
|
512
|
+
* Type guard for PDF Stream
|
|
513
|
+
*/
|
|
514
|
+
declare function isStream(value: unknown): value is PDFStream;
|
|
515
|
+
/**
|
|
516
|
+
* Type guard for PDF Array
|
|
517
|
+
*/
|
|
518
|
+
declare function isArray(value: unknown): value is PDFArray;
|
|
519
|
+
/**
|
|
520
|
+
* Base error class for all PDF errors
|
|
521
|
+
*/
|
|
522
|
+
declare class PDFError extends Error {
|
|
523
|
+
constructor(message: string);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Error thrown when PDF parsing fails
|
|
527
|
+
*/
|
|
528
|
+
declare class PDFParseError extends PDFError {
|
|
529
|
+
readonly offset?: number | undefined;
|
|
530
|
+
constructor(message: string, offset?: number | undefined);
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Error thrown when PDF generation fails
|
|
534
|
+
*/
|
|
535
|
+
declare class PDFGenerationError extends PDFError {
|
|
536
|
+
constructor(message: string);
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Error thrown when PDF object is invalid
|
|
540
|
+
*/
|
|
541
|
+
declare class InvalidPDFObjectError extends PDFError {
|
|
542
|
+
readonly objectType: string;
|
|
543
|
+
constructor(objectType: string, reason: string);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Error thrown when font is not found
|
|
547
|
+
*/
|
|
548
|
+
declare class FontNotFoundError extends PDFError {
|
|
549
|
+
readonly fontName: string;
|
|
550
|
+
constructor(fontName: string);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Error thrown when image is invalid
|
|
554
|
+
*/
|
|
555
|
+
declare class InvalidImageError extends PDFError {
|
|
556
|
+
constructor(reason: string);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Error thrown when PDF signature fails
|
|
560
|
+
*/
|
|
561
|
+
declare class PDFSignatureError extends PDFError {
|
|
562
|
+
constructor(reason: string);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Error thrown when PDF encryption fails
|
|
566
|
+
*/
|
|
567
|
+
declare class PDFEncryptionError extends PDFError {
|
|
568
|
+
constructor(reason: string);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Error thrown when required feature is not implemented
|
|
572
|
+
*/
|
|
573
|
+
declare class NotImplementedError extends PDFError {
|
|
574
|
+
constructor(feature: string);
|
|
575
|
+
}
|
|
576
|
+
import { z } from "zod";
|
|
577
|
+
/**
|
|
578
|
+
* PDF Reference schema
|
|
579
|
+
*/
|
|
580
|
+
declare const PDFRefSchema: z.ZodObject<{
|
|
581
|
+
objectNumber: z.ZodNumber;
|
|
582
|
+
generation: z.ZodNumber;
|
|
583
|
+
}, z.core.$strip>;
|
|
584
|
+
/**
|
|
585
|
+
* PDF Name schema
|
|
586
|
+
*/
|
|
587
|
+
declare const PDFNameSchema: z.ZodObject<{
|
|
588
|
+
type: z.ZodLiteral<"name">;
|
|
589
|
+
value: z.ZodString;
|
|
590
|
+
}, z.core.$strip>;
|
|
591
|
+
/**
|
|
592
|
+
* Page size schema
|
|
593
|
+
*/
|
|
594
|
+
declare const PageSizeSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
595
|
+
A4: "A4";
|
|
596
|
+
Letter: "Letter";
|
|
597
|
+
Legal: "Legal";
|
|
598
|
+
A3: "A3";
|
|
599
|
+
A5: "A5";
|
|
600
|
+
Tabloid: "Tabloid";
|
|
601
|
+
}>, z.ZodObject<{
|
|
602
|
+
width: z.ZodNumber;
|
|
603
|
+
height: z.ZodNumber;
|
|
604
|
+
}, z.core.$strip>]>;
|
|
605
|
+
/**
|
|
606
|
+
* RGB color schema
|
|
607
|
+
*/
|
|
608
|
+
declare const RGBColorSchema: z.ZodObject<{
|
|
609
|
+
type: z.ZodLiteral<"rgb">;
|
|
610
|
+
r: z.ZodNumber;
|
|
611
|
+
g: z.ZodNumber;
|
|
612
|
+
b: z.ZodNumber;
|
|
613
|
+
}, z.core.$strip>;
|
|
614
|
+
/**
|
|
615
|
+
* CMYK color schema
|
|
616
|
+
*/
|
|
617
|
+
declare const CMYKColorSchema: z.ZodObject<{
|
|
618
|
+
type: z.ZodLiteral<"cmyk">;
|
|
619
|
+
c: z.ZodNumber;
|
|
620
|
+
m: z.ZodNumber;
|
|
621
|
+
y: z.ZodNumber;
|
|
622
|
+
k: z.ZodNumber;
|
|
623
|
+
}, z.core.$strip>;
|
|
624
|
+
/**
|
|
625
|
+
* Gray color schema
|
|
626
|
+
*/
|
|
627
|
+
declare const GrayColorSchema: z.ZodObject<{
|
|
628
|
+
type: z.ZodLiteral<"gray">;
|
|
629
|
+
gray: z.ZodNumber;
|
|
630
|
+
}, z.core.$strip>;
|
|
631
|
+
/**
|
|
632
|
+
* PDF Color schema
|
|
633
|
+
*/
|
|
634
|
+
declare const PDFColorSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
635
|
+
type: z.ZodLiteral<"rgb">;
|
|
636
|
+
r: z.ZodNumber;
|
|
637
|
+
g: z.ZodNumber;
|
|
638
|
+
b: z.ZodNumber;
|
|
639
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
640
|
+
type: z.ZodLiteral<"cmyk">;
|
|
641
|
+
c: z.ZodNumber;
|
|
642
|
+
m: z.ZodNumber;
|
|
643
|
+
y: z.ZodNumber;
|
|
644
|
+
k: z.ZodNumber;
|
|
645
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
646
|
+
type: z.ZodLiteral<"gray">;
|
|
647
|
+
gray: z.ZodNumber;
|
|
648
|
+
}, z.core.$strip>]>;
|
|
649
|
+
/**
|
|
650
|
+
* Text options schema
|
|
651
|
+
*/
|
|
652
|
+
declare const TextOptionsSchema: z.ZodObject<{
|
|
653
|
+
x: z.ZodNumber;
|
|
654
|
+
y: z.ZodNumber;
|
|
655
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
656
|
+
font: z.ZodOptional<z.ZodString>;
|
|
657
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
658
|
+
type: z.ZodLiteral<"rgb">;
|
|
659
|
+
r: z.ZodNumber;
|
|
660
|
+
g: z.ZodNumber;
|
|
661
|
+
b: z.ZodNumber;
|
|
662
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
663
|
+
type: z.ZodLiteral<"cmyk">;
|
|
664
|
+
c: z.ZodNumber;
|
|
665
|
+
m: z.ZodNumber;
|
|
666
|
+
y: z.ZodNumber;
|
|
667
|
+
k: z.ZodNumber;
|
|
668
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
669
|
+
type: z.ZodLiteral<"gray">;
|
|
670
|
+
gray: z.ZodNumber;
|
|
671
|
+
}, z.core.$strip>]>>;
|
|
672
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
673
|
+
left: "left";
|
|
674
|
+
center: "center";
|
|
675
|
+
right: "right";
|
|
676
|
+
}>>;
|
|
677
|
+
}, z.core.$strip>;
|
|
678
|
+
/**
|
|
679
|
+
* Rectangle options schema
|
|
680
|
+
*/
|
|
681
|
+
declare const RectOptionsSchema: z.ZodObject<{
|
|
682
|
+
x: z.ZodNumber;
|
|
683
|
+
y: z.ZodNumber;
|
|
684
|
+
width: z.ZodNumber;
|
|
685
|
+
height: z.ZodNumber;
|
|
686
|
+
fill: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
687
|
+
type: z.ZodLiteral<"rgb">;
|
|
688
|
+
r: z.ZodNumber;
|
|
689
|
+
g: z.ZodNumber;
|
|
690
|
+
b: z.ZodNumber;
|
|
691
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
692
|
+
type: z.ZodLiteral<"cmyk">;
|
|
693
|
+
c: z.ZodNumber;
|
|
694
|
+
m: z.ZodNumber;
|
|
695
|
+
y: z.ZodNumber;
|
|
696
|
+
k: z.ZodNumber;
|
|
697
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
698
|
+
type: z.ZodLiteral<"gray">;
|
|
699
|
+
gray: z.ZodNumber;
|
|
700
|
+
}, z.core.$strip>]>>;
|
|
701
|
+
stroke: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
702
|
+
type: z.ZodLiteral<"rgb">;
|
|
703
|
+
r: z.ZodNumber;
|
|
704
|
+
g: z.ZodNumber;
|
|
705
|
+
b: z.ZodNumber;
|
|
706
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
707
|
+
type: z.ZodLiteral<"cmyk">;
|
|
708
|
+
c: z.ZodNumber;
|
|
709
|
+
m: z.ZodNumber;
|
|
710
|
+
y: z.ZodNumber;
|
|
711
|
+
k: z.ZodNumber;
|
|
712
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
713
|
+
type: z.ZodLiteral<"gray">;
|
|
714
|
+
gray: z.ZodNumber;
|
|
715
|
+
}, z.core.$strip>]>>;
|
|
716
|
+
lineWidth: z.ZodOptional<z.ZodNumber>;
|
|
717
|
+
}, z.core.$strip>;
|
|
718
|
+
/**
|
|
719
|
+
* Line options schema
|
|
720
|
+
*/
|
|
721
|
+
declare const LineOptionsSchema: z.ZodObject<{
|
|
722
|
+
x1: z.ZodNumber;
|
|
723
|
+
y1: z.ZodNumber;
|
|
724
|
+
x2: z.ZodNumber;
|
|
725
|
+
y2: z.ZodNumber;
|
|
726
|
+
color: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
727
|
+
type: z.ZodLiteral<"rgb">;
|
|
728
|
+
r: z.ZodNumber;
|
|
729
|
+
g: z.ZodNumber;
|
|
730
|
+
b: z.ZodNumber;
|
|
731
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
732
|
+
type: z.ZodLiteral<"cmyk">;
|
|
733
|
+
c: z.ZodNumber;
|
|
734
|
+
m: z.ZodNumber;
|
|
735
|
+
y: z.ZodNumber;
|
|
736
|
+
k: z.ZodNumber;
|
|
737
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
738
|
+
type: z.ZodLiteral<"gray">;
|
|
739
|
+
gray: z.ZodNumber;
|
|
740
|
+
}, z.core.$strip>]>>;
|
|
741
|
+
lineWidth: z.ZodOptional<z.ZodNumber>;
|
|
742
|
+
}, z.core.$strip>;
|
|
743
|
+
/**
|
|
744
|
+
* PDF metadata schema
|
|
745
|
+
*/
|
|
746
|
+
declare const PDFMetadataSchema: z.ZodObject<{
|
|
747
|
+
title: z.ZodOptional<z.ZodString>;
|
|
748
|
+
author: z.ZodOptional<z.ZodString>;
|
|
749
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
750
|
+
keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
751
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
752
|
+
producer: z.ZodOptional<z.ZodString>;
|
|
753
|
+
creationDate: z.ZodOptional<z.ZodDate>;
|
|
754
|
+
modificationDate: z.ZodOptional<z.ZodDate>;
|
|
755
|
+
}, z.core.$strip>;
|
|
756
|
+
/**
|
|
757
|
+
* PDF Dictionary schema (recursive)
|
|
758
|
+
*/
|
|
759
|
+
declare const PDFDictionarySchema: z.ZodType<Record<string, any>>;
|
|
760
|
+
/**
|
|
761
|
+
* PDF Array schema (recursive)
|
|
762
|
+
*/
|
|
763
|
+
declare const PDFArraySchema: z.ZodType<any[]>;
|
|
764
|
+
/**
|
|
765
|
+
* PDF Stream schema
|
|
766
|
+
*/
|
|
767
|
+
declare const PDFStreamSchema: z.ZodObject<{
|
|
768
|
+
dictionary: z.ZodType<Record<string, any>, unknown, z.core.$ZodTypeInternals<Record<string, any>, unknown>>;
|
|
769
|
+
data: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
770
|
+
}, z.core.$strip>;
|
|
771
|
+
/**
|
|
772
|
+
* PDF Value schema (recursive union)
|
|
773
|
+
*/
|
|
774
|
+
declare const PDFValueSchema: z.ZodType<any>;
|
|
775
|
+
/**
|
|
776
|
+
* PDF Indirect Object schema
|
|
777
|
+
*/
|
|
778
|
+
declare const PDFIndirectObjectSchema: z.ZodObject<{
|
|
779
|
+
ref: z.ZodObject<{
|
|
780
|
+
objectNumber: z.ZodNumber;
|
|
781
|
+
generation: z.ZodNumber;
|
|
782
|
+
}, z.core.$strip>;
|
|
783
|
+
value: z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>;
|
|
784
|
+
}, z.core.$strip>;
|
|
785
|
+
/**
|
|
786
|
+
* PDF Object Type schema
|
|
787
|
+
*/
|
|
788
|
+
declare const PDFObjectTypeSchema: z.ZodEnum<{
|
|
789
|
+
string: "string";
|
|
790
|
+
number: "number";
|
|
791
|
+
boolean: "boolean";
|
|
792
|
+
name: "name";
|
|
793
|
+
null: "null";
|
|
794
|
+
array: "array";
|
|
795
|
+
dictionary: "dictionary";
|
|
796
|
+
stream: "stream";
|
|
797
|
+
indirect: "indirect";
|
|
798
|
+
}>;
|
|
799
|
+
/**
|
|
800
|
+
* PDF version schema
|
|
801
|
+
*/
|
|
802
|
+
declare const PDFVersionSchema: z.ZodEnum<{
|
|
803
|
+
1.4: "1.4";
|
|
804
|
+
1.5: "1.5";
|
|
805
|
+
1.6: "1.6";
|
|
806
|
+
1.7: "1.7";
|
|
807
|
+
}>;
|
|
808
|
+
export { serializeValue, serializeStream, serializeObject, isStream, isStandardFont, isRef, isName, isDictionary, isArray, getFontRefName, createStream, createRef, createName, createDictionary, createArray, TokenType, Token, TextOptionsSchema, TextOptions, StandardFont, STANDARD_FONTS, RectOptionsSchema, RectOptions, RGBColorSchema, ParsedPDF, PageSizeSchema, PageSize, PDFVersionSchema, PDFVersion, PDFValueSchema, PDFValue, PDFStreamSchema, PDFStream, PDFSignatureError, PDFRefSchema, PDFRef, PDFReader, PDFParser, PDFParseError, PDFPageOptions, PDFObjectTypeSchema, PDFObjectType, PDFNameSchema, PDFName, PDFMetadataSchema, PDFMetadata, PDFLexer, PDFIndirectObjectSchema, PDFIndirectObject, PDFGenerationError, PDFError, PDFEncryptionError, PDFDocumentOptions, PDFDocument, PDFDictionarySchema, PDFDictionary, PDFColorSchema, PDFColor, PDFArraySchema, PDFArray, NotImplementedError, LineOptionsSchema, LineOptions, InvalidPDFObjectError, InvalidImageError, GrayColorSchema, FontNotFoundError, FONT_FAMILIES, CMYKColorSchema };
|