@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/dist/index.js ADDED
@@ -0,0 +1,111 @@
1
+ import {
2
+ CMYKColorSchema,
3
+ FONT_FAMILIES,
4
+ GrayColorSchema,
5
+ LineOptionsSchema,
6
+ PDFArraySchema,
7
+ PDFColorSchema,
8
+ PDFDictionarySchema,
9
+ PDFDocument,
10
+ PDFIndirectObjectSchema,
11
+ PDFMetadataSchema,
12
+ PDFNameSchema,
13
+ PDFObjectTypeSchema,
14
+ PDFPage,
15
+ PDFRefSchema,
16
+ PDFStreamSchema,
17
+ PDFValueSchema,
18
+ PDFVersionSchema,
19
+ PageSizeSchema,
20
+ RGBColorSchema,
21
+ RectOptionsSchema,
22
+ STANDARD_FONTS,
23
+ TextOptionsSchema,
24
+ getFontRefName,
25
+ isStandardFont,
26
+ serializeObject,
27
+ serializeStream,
28
+ serializeValue
29
+ } from "./shared/chunk-37mjkw9w.js";
30
+ import {
31
+ FontNotFoundError,
32
+ InvalidImageError,
33
+ InvalidPDFObjectError,
34
+ NotImplementedError,
35
+ PDFEncryptionError,
36
+ PDFError,
37
+ PDFGenerationError,
38
+ PDFLexer,
39
+ PDFParseError,
40
+ PDFParser,
41
+ PDFReader,
42
+ PDFSignatureError,
43
+ TokenType
44
+ } from "./shared/chunk-10ftnz45.js";
45
+ import {
46
+ createArray,
47
+ createDictionary,
48
+ createName,
49
+ createRef,
50
+ createStream,
51
+ isArray,
52
+ isDictionary,
53
+ isName,
54
+ isRef,
55
+ isStream
56
+ } from "./shared/chunk-6dengthp.js";
57
+ export {
58
+ serializeValue,
59
+ serializeStream,
60
+ serializeObject,
61
+ isStream,
62
+ isStandardFont,
63
+ isRef,
64
+ isName,
65
+ isDictionary,
66
+ isArray,
67
+ getFontRefName,
68
+ createStream,
69
+ createRef,
70
+ createName,
71
+ createDictionary,
72
+ createArray,
73
+ TokenType,
74
+ TextOptionsSchema,
75
+ STANDARD_FONTS,
76
+ RectOptionsSchema,
77
+ RGBColorSchema,
78
+ PageSizeSchema,
79
+ PDFVersionSchema,
80
+ PDFValueSchema,
81
+ PDFStreamSchema,
82
+ PDFSignatureError,
83
+ PDFRefSchema,
84
+ PDFReader,
85
+ PDFParser,
86
+ PDFParseError,
87
+ PDFPage,
88
+ PDFObjectTypeSchema,
89
+ PDFNameSchema,
90
+ PDFMetadataSchema,
91
+ PDFLexer,
92
+ PDFIndirectObjectSchema,
93
+ PDFGenerationError,
94
+ PDFError,
95
+ PDFEncryptionError,
96
+ PDFDocument,
97
+ PDFDictionarySchema,
98
+ PDFColorSchema,
99
+ PDFArraySchema,
100
+ NotImplementedError,
101
+ LineOptionsSchema,
102
+ InvalidPDFObjectError,
103
+ InvalidImageError,
104
+ GrayColorSchema,
105
+ FontNotFoundError,
106
+ FONT_FAMILIES,
107
+ CMYKColorSchema
108
+ };
109
+
110
+ //# debugId=EECFD06F56D594E564756E2164756E21
111
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFsKICBdLAogICJtYXBwaW5ncyI6ICIiLAogICJkZWJ1Z0lkIjogIkVFQ0ZEMDZGNTZENTk0RTU2NDc1NkUyMTY0NzU2RTIxIiwKICAibmFtZXMiOiBbXQp9
@@ -0,0 +1,234 @@
1
+ /**
2
+ * PDF token types
3
+ */
4
+ declare enum TokenType {
5
+ NUMBER = "NUMBER",
6
+ STRING = "STRING",
7
+ NAME = "NAME",
8
+ BOOLEAN = "BOOLEAN",
9
+ NULL = "NULL",
10
+ ARRAY_START = "ARRAY_START",
11
+ ARRAY_END = "ARRAY_END",
12
+ DICT_START = "DICT_START",
13
+ DICT_END = "DICT_END",
14
+ OBJ = "OBJ",
15
+ ENDOBJ = "ENDOBJ",
16
+ STREAM = "STREAM",
17
+ ENDSTREAM = "ENDSTREAM",
18
+ XREF = "XREF",
19
+ TRAILER = "TRAILER",
20
+ STARTXREF = "STARTXREF",
21
+ R = "R",
22
+ EOF = "EOF"
23
+ }
24
+ /**
25
+ * PDF token
26
+ */
27
+ interface Token {
28
+ type: TokenType;
29
+ value: any;
30
+ position: number;
31
+ }
32
+ /**
33
+ * PDF Lexer
34
+ */
35
+ declare class PDFLexer {
36
+ private data;
37
+ private position;
38
+ constructor(data: Uint8Array);
39
+ /**
40
+ * Get next token
41
+ */
42
+ nextToken(): Token;
43
+ /**
44
+ * Peek at next character without consuming
45
+ */
46
+ private peek;
47
+ /**
48
+ * Skip whitespace and comments
49
+ */
50
+ private skipWhitespace;
51
+ /**
52
+ * Read a name token
53
+ */
54
+ private readName;
55
+ /**
56
+ * Read a string token
57
+ */
58
+ private readString;
59
+ /**
60
+ * Read a number token
61
+ */
62
+ private readNumber;
63
+ /**
64
+ * Read a keyword token
65
+ */
66
+ private readKeyword;
67
+ /**
68
+ * Check if character is delimiter
69
+ */
70
+ private isDelimiter;
71
+ /**
72
+ * Check if byte is whitespace
73
+ */
74
+ private isWhitespace;
75
+ }
76
+ /**
77
+ * PDF reference to indirect object
78
+ */
79
+ type PDFRef = {
80
+ readonly objectNumber: number;
81
+ readonly generation: number;
82
+ };
83
+ /**
84
+ * PDF value types
85
+ */
86
+ type PDFValue = boolean | number | string | PDFName | PDFArray | PDFDictionary | PDFStream | null | PDFRef;
87
+ /**
88
+ * PDF Name object
89
+ */
90
+ type PDFName = {
91
+ readonly type: "name";
92
+ readonly value: string;
93
+ };
94
+ /**
95
+ * PDF Array
96
+ */
97
+ type PDFArray = PDFValue[];
98
+ /**
99
+ * PDF Dictionary
100
+ */
101
+ type PDFDictionary = Record<string, PDFValue>;
102
+ /**
103
+ * PDF Stream
104
+ */
105
+ type PDFStream = {
106
+ readonly dictionary: PDFDictionary;
107
+ readonly data: Uint8Array;
108
+ };
109
+ /**
110
+ * PDF Parser
111
+ */
112
+ declare class PDFParser {
113
+ private lexer;
114
+ private currentToken;
115
+ private nextToken;
116
+ private data;
117
+ constructor(data: Uint8Array);
118
+ /**
119
+ * Parse a PDF value
120
+ */
121
+ parseValue(): PDFValue;
122
+ /**
123
+ * Parse number or reference (number number R)
124
+ */
125
+ private parseNumberOrRef;
126
+ /**
127
+ * Parse string
128
+ */
129
+ private parseString;
130
+ /**
131
+ * Parse name
132
+ */
133
+ private parseName;
134
+ /**
135
+ * Parse boolean
136
+ */
137
+ private parseBoolean;
138
+ /**
139
+ * Parse null
140
+ */
141
+ private parseNull;
142
+ /**
143
+ * Parse array
144
+ */
145
+ private parseArray;
146
+ /**
147
+ * Parse dictionary
148
+ */
149
+ private parseDictionary;
150
+ /**
151
+ * Parse indirect object
152
+ */
153
+ parseIndirectObject(): {
154
+ ref: PDFRef;
155
+ value: PDFValue;
156
+ };
157
+ /**
158
+ * Parse stream (dictionary already parsed)
159
+ */
160
+ private parseStream;
161
+ /**
162
+ * Advance to next token
163
+ */
164
+ private advance;
165
+ /**
166
+ * Check if more tokens available
167
+ */
168
+ hasMore(): boolean;
169
+ }
170
+ /**
171
+ * Parsed PDF Document
172
+ */
173
+ interface ParsedPDF {
174
+ version: string;
175
+ catalog: PDFRef;
176
+ pages: PDFPage[];
177
+ objects: Map<number, any>;
178
+ }
179
+ /**
180
+ * Parsed PDF Page
181
+ */
182
+ interface PDFPage {
183
+ ref: PDFRef;
184
+ size: {
185
+ width: number;
186
+ height: number;
187
+ };
188
+ content: string;
189
+ }
190
+ /**
191
+ * PDF Reader - reads and parses existing PDFs
192
+ */
193
+ declare class PDFReader {
194
+ private data;
195
+ private objects;
196
+ constructor(data: Uint8Array);
197
+ /**
198
+ * Parse PDF file
199
+ */
200
+ parse(): ParsedPDF;
201
+ /**
202
+ * Find startxref offset
203
+ */
204
+ private findStartXRef;
205
+ /**
206
+ * Parse xref table
207
+ */
208
+ private parseXRefTable;
209
+ /**
210
+ * Parse trailer dictionary
211
+ */
212
+ private parseTrailer;
213
+ /**
214
+ * Read all objects from xref table
215
+ */
216
+ private readObjects;
217
+ /**
218
+ * Parse PDF version from header
219
+ */
220
+ private parseVersion;
221
+ /**
222
+ * Parse pages from catalog
223
+ */
224
+ private parsePages;
225
+ /**
226
+ * Parse a single page
227
+ */
228
+ private parsePage;
229
+ /**
230
+ * Extract text from content stream
231
+ */
232
+ private extractText;
233
+ }
234
+ export { TokenType, Token, ParsedPDF, PDFReader, PDFParser, PDFPage, PDFLexer };
@@ -0,0 +1,16 @@
1
+ import {
2
+ PDFLexer,
3
+ PDFParser,
4
+ PDFReader,
5
+ TokenType
6
+ } from "../shared/chunk-10ftnz45.js";
7
+ import"../shared/chunk-6dengthp.js";
8
+ export {
9
+ TokenType,
10
+ PDFReader,
11
+ PDFParser,
12
+ PDFLexer
13
+ };
14
+
15
+ //# debugId=1306B1E9F61CD14B64756E2164756E21
16
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFsKICBdLAogICJtYXBwaW5ncyI6ICIiLAogICJkZWJ1Z0lkIjogIjEzMDZCMUU5RjYxQ0QxNEI2NDc1NkUyMTY0NzU2RTIxIiwKICAibmFtZXMiOiBbXQp9