pdf-oxide-fips 0.3.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSE-APACHE +176 -0
  2. package/LICENSE-MIT +25 -0
  3. package/README.md +218 -0
  4. package/lib/builders/annotation-builder.d.ts +198 -0
  5. package/lib/builders/annotation-builder.js +317 -0
  6. package/lib/builders/conversion-options-builder.d.ts +106 -0
  7. package/lib/builders/conversion-options-builder.js +214 -0
  8. package/lib/builders/document-builder.d.ts +381 -0
  9. package/lib/builders/document-builder.js +770 -0
  10. package/lib/builders/index.d.ts +13 -0
  11. package/lib/builders/index.js +13 -0
  12. package/lib/builders/metadata-builder.d.ts +201 -0
  13. package/lib/builders/metadata-builder.js +285 -0
  14. package/lib/builders/pdf-builder.d.ts +216 -0
  15. package/lib/builders/pdf-builder.js +350 -0
  16. package/lib/builders/search-options-builder.d.ts +73 -0
  17. package/lib/builders/search-options-builder.js +129 -0
  18. package/lib/builders/streaming-table.d.ts +64 -0
  19. package/lib/builders/streaming-table.js +140 -0
  20. package/lib/document-editor-manager.d.ts +139 -0
  21. package/lib/document-editor-manager.js +256 -0
  22. package/lib/document-editor.d.ts +124 -0
  23. package/lib/document-editor.js +318 -0
  24. package/lib/errors.d.ts +382 -0
  25. package/lib/errors.js +1115 -0
  26. package/lib/form-field-manager.d.ts +299 -0
  27. package/lib/form-field-manager.js +568 -0
  28. package/lib/hybrid-ml-manager.d.ts +142 -0
  29. package/lib/hybrid-ml-manager.js +208 -0
  30. package/lib/index.d.ts +205 -0
  31. package/lib/index.js +693 -0
  32. package/lib/managers/accessibility-manager.d.ts +148 -0
  33. package/lib/managers/accessibility-manager.js +234 -0
  34. package/lib/managers/annotation-manager.d.ts +219 -0
  35. package/lib/managers/annotation-manager.js +359 -0
  36. package/lib/managers/barcode-manager.d.ts +82 -0
  37. package/lib/managers/barcode-manager.js +263 -0
  38. package/lib/managers/batch-manager.d.ts +185 -0
  39. package/lib/managers/batch-manager.js +385 -0
  40. package/lib/managers/cache-manager.d.ts +181 -0
  41. package/lib/managers/cache-manager.js +384 -0
  42. package/lib/managers/compliance-manager.d.ts +103 -0
  43. package/lib/managers/compliance-manager.js +453 -0
  44. package/lib/managers/content-manager.d.ts +120 -0
  45. package/lib/managers/content-manager.js +294 -0
  46. package/lib/managers/document-utility-manager.d.ts +369 -0
  47. package/lib/managers/document-utility-manager.js +730 -0
  48. package/lib/managers/dom-pdf-creator.d.ts +104 -0
  49. package/lib/managers/dom-pdf-creator.js +299 -0
  50. package/lib/managers/editing-manager.d.ts +248 -0
  51. package/lib/managers/editing-manager.js +387 -0
  52. package/lib/managers/enterprise-manager.d.ts +192 -0
  53. package/lib/managers/enterprise-manager.js +307 -0
  54. package/lib/managers/extended-managers.d.ts +122 -0
  55. package/lib/managers/extended-managers.js +664 -0
  56. package/lib/managers/extraction-manager.d.ts +246 -0
  57. package/lib/managers/extraction-manager.js +482 -0
  58. package/lib/managers/final-utilities.d.ts +127 -0
  59. package/lib/managers/final-utilities.js +657 -0
  60. package/lib/managers/hybrid-ml-advanced.d.ts +136 -0
  61. package/lib/managers/hybrid-ml-advanced.js +722 -0
  62. package/lib/managers/index.d.ts +64 -0
  63. package/lib/managers/index.js +69 -0
  64. package/lib/managers/layer-manager.d.ts +203 -0
  65. package/lib/managers/layer-manager.js +401 -0
  66. package/lib/managers/metadata-manager.d.ts +148 -0
  67. package/lib/managers/metadata-manager.js +280 -0
  68. package/lib/managers/ocr-manager.d.ts +194 -0
  69. package/lib/managers/ocr-manager.js +582 -0
  70. package/lib/managers/optimization-manager.d.ts +102 -0
  71. package/lib/managers/optimization-manager.js +213 -0
  72. package/lib/managers/outline-manager.d.ts +101 -0
  73. package/lib/managers/outline-manager.js +169 -0
  74. package/lib/managers/page-manager.d.ts +142 -0
  75. package/lib/managers/page-manager.js +235 -0
  76. package/lib/managers/pattern-detection.d.ts +169 -0
  77. package/lib/managers/pattern-detection.js +322 -0
  78. package/lib/managers/rendering-manager.d.ts +353 -0
  79. package/lib/managers/rendering-manager.js +679 -0
  80. package/lib/managers/search-manager.d.ts +235 -0
  81. package/lib/managers/search-manager.js +329 -0
  82. package/lib/managers/security-manager.d.ts +161 -0
  83. package/lib/managers/security-manager.js +292 -0
  84. package/lib/managers/signature-manager.d.ts +738 -0
  85. package/lib/managers/signature-manager.js +1509 -0
  86. package/lib/managers/streams.d.ts +262 -0
  87. package/lib/managers/streams.js +477 -0
  88. package/lib/managers/xfa-manager.d.ts +227 -0
  89. package/lib/managers/xfa-manager.js +539 -0
  90. package/lib/native-loader.d.ts +7 -0
  91. package/lib/native-loader.js +62 -0
  92. package/lib/native.d.ts +16 -0
  93. package/lib/native.js +69 -0
  94. package/lib/pdf-creator-manager.d.ts +200 -0
  95. package/lib/pdf-creator-manager.js +381 -0
  96. package/lib/properties.d.ts +79 -0
  97. package/lib/properties.js +454 -0
  98. package/lib/result-accessors-manager.d.ts +346 -0
  99. package/lib/result-accessors-manager.js +706 -0
  100. package/lib/thumbnail-manager.d.ts +121 -0
  101. package/lib/thumbnail-manager.js +205 -0
  102. package/lib/timestamp.d.ts +54 -0
  103. package/lib/timestamp.js +115 -0
  104. package/lib/tsa-client.d.ts +44 -0
  105. package/lib/tsa-client.js +67 -0
  106. package/lib/types/common.d.ts +189 -0
  107. package/lib/types/common.js +17 -0
  108. package/lib/types/document-types.d.ts +352 -0
  109. package/lib/types/document-types.js +82 -0
  110. package/lib/types/index.d.ts +5 -0
  111. package/lib/types/index.js +5 -0
  112. package/lib/types/manager-types.d.ts +179 -0
  113. package/lib/types/manager-types.js +100 -0
  114. package/lib/types/native-bindings.d.ts +439 -0
  115. package/lib/types/native-bindings.js +7 -0
  116. package/lib/workers/index.d.ts +6 -0
  117. package/lib/workers/index.js +5 -0
  118. package/lib/workers/pool.d.ts +64 -0
  119. package/lib/workers/pool.js +192 -0
  120. package/lib/workers/worker.d.ts +5 -0
  121. package/lib/workers/worker.js +99 -0
  122. package/package.json +79 -0
  123. package/prebuilds/darwin-arm64/pdf_oxide.node +0 -0
  124. package/prebuilds/darwin-x64/pdf_oxide.node +0 -0
  125. package/prebuilds/linux-arm64/pdf_oxide.node +0 -0
  126. package/prebuilds/linux-x64/pdf_oxide.node +0 -0
  127. package/prebuilds/win32-x64/pdf_oxide.node +0 -0
@@ -0,0 +1,317 @@
1
+ /**
2
+ * Builder for creating PDF annotations
3
+ *
4
+ * Configures annotation properties like content, appearance, author, and behavior.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { AnnotationBuilder } from 'pdf_oxide';
9
+ *
10
+ * const annotation = AnnotationBuilder.create()
11
+ * .type('highlight')
12
+ * .content('Important section')
13
+ * .author('Reviewer')
14
+ * .color([1, 1, 0]) // Yellow
15
+ * .build();
16
+ *
17
+ * pdf.addAnnotation(annotation);
18
+ * ```
19
+ */
20
+ export class AnnotationBuilder {
21
+ /**
22
+ * Creates a new AnnotationBuilder instance
23
+ * @private
24
+ */
25
+ constructor() {
26
+ this._type = 'text';
27
+ this._content = '';
28
+ this._color = [1, 0, 0]; // Default: red (RGB normalized 0-1)
29
+ this._opacity = 1.0;
30
+ this._creationDate = new Date();
31
+ this._modificationDate = new Date();
32
+ this._flags = 0;
33
+ }
34
+ /**
35
+ * Creates a new AnnotationBuilder instance
36
+ * @returns New builder instance
37
+ */
38
+ static create() {
39
+ return new AnnotationBuilder();
40
+ }
41
+ /**
42
+ * Creates a text annotation (comment/note)
43
+ * @returns This builder for chaining
44
+ */
45
+ asText() {
46
+ this._type = 'text';
47
+ return this;
48
+ }
49
+ /**
50
+ * Creates a highlight annotation
51
+ * @returns This builder for chaining
52
+ */
53
+ asHighlight() {
54
+ this._type = 'highlight';
55
+ return this;
56
+ }
57
+ /**
58
+ * Creates an underline annotation
59
+ * @returns This builder for chaining
60
+ */
61
+ asUnderline() {
62
+ this._type = 'underline';
63
+ return this;
64
+ }
65
+ /**
66
+ * Creates a strikeout annotation
67
+ * @returns This builder for chaining
68
+ */
69
+ asStrikeout() {
70
+ this._type = 'strikeout';
71
+ return this;
72
+ }
73
+ /**
74
+ * Creates a squiggly (wavy underline) annotation
75
+ * @returns This builder for chaining
76
+ */
77
+ asSquiggly() {
78
+ this._type = 'squiggly';
79
+ return this;
80
+ }
81
+ /**
82
+ * Sets the annotation type
83
+ * @param type - Annotation type ('text', 'highlight', 'underline', 'strikeout', 'squiggly')
84
+ * @returns This builder for chaining
85
+ */
86
+ type(type) {
87
+ const validTypes = ['text', 'highlight', 'underline', 'strikeout', 'squiggly', 'note'];
88
+ if (!validTypes.includes(type)) {
89
+ throw new Error(`Invalid annotation type. Must be one of: ${validTypes.join(', ')}`);
90
+ }
91
+ this._type = type;
92
+ return this;
93
+ }
94
+ /**
95
+ * Sets the annotation content/text
96
+ * @param content - The annotation content
97
+ * @returns This builder for chaining
98
+ */
99
+ content(content) {
100
+ if (typeof content !== 'string') {
101
+ throw new Error('Content must be a string');
102
+ }
103
+ this._content = content;
104
+ return this;
105
+ }
106
+ /**
107
+ * Sets the author of the annotation
108
+ * @param author - The author name
109
+ * @returns This builder for chaining
110
+ */
111
+ author(author) {
112
+ if (typeof author !== 'string') {
113
+ throw new Error('Author must be a string');
114
+ }
115
+ this._author = author.length > 0 ? author : undefined;
116
+ return this;
117
+ }
118
+ /**
119
+ * Sets the subject/title of the annotation
120
+ * @param subject - The annotation subject
121
+ * @returns This builder for chaining
122
+ */
123
+ subject(subject) {
124
+ if (typeof subject !== 'string') {
125
+ throw new Error('Subject must be a string');
126
+ }
127
+ this._subject = subject.length > 0 ? subject : undefined;
128
+ return this;
129
+ }
130
+ /**
131
+ * Sets the color of the annotation (RGB, normalized 0-1)
132
+ * @param rgb - RGB color array [r, g, b] with values 0-1
133
+ * @returns This builder for chaining
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * builder.color([1, 1, 0]); // Yellow
138
+ * builder.color([1, 0, 0]); // Red
139
+ * builder.color([0, 1, 0]); // Green
140
+ * ```
141
+ */
142
+ color(rgb) {
143
+ if (!Array.isArray(rgb) || rgb.length !== 3) {
144
+ throw new Error('Color must be an array of 3 RGB values [r, g, b]');
145
+ }
146
+ if (!rgb.every((c) => typeof c === 'number' && c >= 0 && c <= 1)) {
147
+ throw new Error('RGB values must be numbers between 0 and 1');
148
+ }
149
+ this._color = [...rgb];
150
+ return this;
151
+ }
152
+ /**
153
+ * Sets the color using common color names
154
+ * @param colorName - Color name (e.g., 'red', 'yellow', 'green', 'blue')
155
+ * @returns This builder for chaining
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * builder.colorName('yellow');
160
+ * builder.colorName('red');
161
+ * ```
162
+ */
163
+ colorName(colorName) {
164
+ const colors = {
165
+ red: [1, 0, 0],
166
+ green: [0, 1, 0],
167
+ blue: [0, 0, 1],
168
+ yellow: [1, 1, 0],
169
+ cyan: [0, 1, 1],
170
+ magenta: [1, 0, 1],
171
+ white: [1, 1, 1],
172
+ black: [0, 0, 0],
173
+ gray: [0.5, 0.5, 0.5],
174
+ orange: [1, 0.5, 0],
175
+ purple: [0.5, 0, 0.5],
176
+ };
177
+ const lowerColorName = colorName.toLowerCase();
178
+ if (!colors[lowerColorName]) {
179
+ const available = Object.keys(colors).join(', ');
180
+ throw new Error(`Unknown color. Available colors: ${available}`);
181
+ }
182
+ this._color = [...colors[lowerColorName]];
183
+ return this;
184
+ }
185
+ /**
186
+ * Sets the opacity/transparency (0-1)
187
+ * @param opacity - Opacity value (0=transparent, 1=opaque)
188
+ * @returns This builder for chaining
189
+ */
190
+ opacity(opacity) {
191
+ if (typeof opacity !== 'number' || opacity < 0 || opacity > 1) {
192
+ throw new Error('Opacity must be a number between 0 and 1');
193
+ }
194
+ this._opacity = opacity;
195
+ return this;
196
+ }
197
+ /**
198
+ * Sets the bounding box for the annotation
199
+ * @param bounds - Bounding box {x, y, width, height}
200
+ * @returns This builder for chaining
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * builder.bounds({x: 100, y: 200, width: 150, height: 30});
205
+ * ```
206
+ */
207
+ bounds(bounds) {
208
+ if (typeof bounds !== 'object' || bounds === null) {
209
+ throw new Error('Bounds must be an object');
210
+ }
211
+ const { x, y, width, height } = bounds;
212
+ if (![x, y, width, height].every((v) => typeof v === 'number' && v >= 0)) {
213
+ throw new Error('Bounds must have numeric x, y, width, height values >= 0');
214
+ }
215
+ this._bounds = { x, y, width, height };
216
+ return this;
217
+ }
218
+ /**
219
+ * Sets the creation date
220
+ * @param date - The creation date
221
+ * @returns This builder for chaining
222
+ */
223
+ creationDate(date) {
224
+ if (!(date instanceof Date)) {
225
+ throw new Error('creationDate must be a Date object');
226
+ }
227
+ this._creationDate = new Date(date);
228
+ return this;
229
+ }
230
+ /**
231
+ * Sets the modification date
232
+ * @param date - The modification date
233
+ * @returns This builder for chaining
234
+ */
235
+ modificationDate(date) {
236
+ if (!(date instanceof Date)) {
237
+ throw new Error('modificationDate must be a Date object');
238
+ }
239
+ this._modificationDate = new Date(date);
240
+ return this;
241
+ }
242
+ /**
243
+ * Sets the annotation to be printed
244
+ * @returns This builder for chaining
245
+ */
246
+ printable() {
247
+ this._flags |= 4; // Print flag
248
+ return this;
249
+ }
250
+ /**
251
+ * Sets the annotation to NOT be printed
252
+ * @returns This builder for chaining
253
+ */
254
+ notPrintable() {
255
+ this._flags &= ~4; // Clear print flag
256
+ return this;
257
+ }
258
+ /**
259
+ * Sets whether the annotation is locked (read-only)
260
+ * @param locked - Whether to lock the annotation
261
+ * @returns This builder for chaining
262
+ */
263
+ locked(locked) {
264
+ if (typeof locked !== 'boolean') {
265
+ throw new Error('locked must be a boolean');
266
+ }
267
+ if (locked) {
268
+ this._flags |= 128; // Locked flag
269
+ }
270
+ else {
271
+ this._flags &= ~128;
272
+ }
273
+ return this;
274
+ }
275
+ /**
276
+ * Sets a reply to this annotation
277
+ * @param replyContent - Content of the reply
278
+ * @returns This builder for chaining
279
+ */
280
+ reply(replyContent) {
281
+ if (typeof replyContent !== 'string') {
282
+ throw new Error('Reply content must be a string');
283
+ }
284
+ this._reply = replyContent;
285
+ return this;
286
+ }
287
+ /**
288
+ * Builds and returns the annotation object
289
+ * @returns Immutable annotation object
290
+ */
291
+ build() {
292
+ if (!this._bounds && this._type !== 'text') {
293
+ throw new Error(`Annotation type "${this._type}" requires bounds to be set`);
294
+ }
295
+ return {
296
+ type: this._type,
297
+ content: this._content,
298
+ author: this._author,
299
+ subject: this._subject,
300
+ color: [...this._color],
301
+ opacity: this._opacity,
302
+ bounds: this._bounds ? { ...this._bounds } : undefined,
303
+ creationDate: new Date(this._creationDate),
304
+ modificationDate: new Date(this._modificationDate),
305
+ flags: this._flags,
306
+ reply: this._reply,
307
+ };
308
+ }
309
+ }
310
+ /**
311
+ * Create a new AnnotationBuilder with static factory
312
+ * @deprecated Use AnnotationBuilder.create() instead
313
+ * @returns New builder instance
314
+ */
315
+ export function createAnnotationBuilder() {
316
+ return AnnotationBuilder.create();
317
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Builder for conversion options when converting PDF to other formats
3
+ *
4
+ * Configures how PDFs are converted to Markdown, HTML, or other text formats
5
+ * with options for formatting, image handling, and content extraction.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { ConversionOptionsBuilder } from 'pdf_oxide';
10
+ *
11
+ * const options = ConversionOptionsBuilder.create()
12
+ * .preserveFormatting(true)
13
+ * .includeImages(true)
14
+ * .detectHeadings(true)
15
+ * .detectTables(true)
16
+ * .build();
17
+ *
18
+ * const doc = PdfDocument.open('file.pdf');
19
+ * const markdown = doc.toMarkdown(0, options);
20
+ * ```
21
+ */
22
+ interface PageRangeOptions {
23
+ start: number;
24
+ end: number;
25
+ }
26
+ export interface ConversionOptions {
27
+ preserveFormatting: boolean;
28
+ detectHeadings: boolean;
29
+ detectTables: boolean;
30
+ detectLists: boolean;
31
+ includeImages: boolean;
32
+ imageFormat: string;
33
+ imageQuality: number;
34
+ maxImageDimension: number;
35
+ outputEncoding: string;
36
+ normalizeWhitespace: boolean;
37
+ extractAnnotations: boolean;
38
+ useStructureTree: boolean;
39
+ pageRange?: PageRangeOptions;
40
+ }
41
+ export declare class ConversionOptionsBuilder {
42
+ private _preserveFormatting;
43
+ private _detectHeadings;
44
+ private _detectTables;
45
+ private _detectLists;
46
+ private _includeImages;
47
+ private _imageFormat;
48
+ private _imageQuality;
49
+ private _maxImageDimension;
50
+ private _outputEncoding;
51
+ private _normalizeWhitespace;
52
+ private _extractAnnotations;
53
+ private _useStructureTree;
54
+ private _pageRange?;
55
+ /**
56
+ * Creates a new ConversionOptionsBuilder instance
57
+ * @private
58
+ */
59
+ private constructor();
60
+ /**
61
+ * Creates a new ConversionOptionsBuilder instance
62
+ * @returns New builder instance
63
+ */
64
+ static create(): ConversionOptionsBuilder;
65
+ /**
66
+ * Creates options with default settings optimized for readability
67
+ * @returns Conversion options with default preset
68
+ */
69
+ static default(): ConversionOptions;
70
+ /**
71
+ * Creates options optimized for text-only extraction
72
+ * @returns Conversion options with text-only preset
73
+ */
74
+ static textOnly(): ConversionOptions;
75
+ /**
76
+ * Creates options optimized for maximum quality and detail preservation
77
+ * @returns Conversion options with high-quality preset
78
+ */
79
+ static highQuality(): ConversionOptions;
80
+ /**
81
+ * Creates options for fast, basic conversion
82
+ * @returns Conversion options with fast preset
83
+ */
84
+ static fast(): ConversionOptions;
85
+ preserveFormatting(preserve: boolean): this;
86
+ detectHeadings(detect: boolean): this;
87
+ detectTables(detect: boolean): this;
88
+ detectLists(detect: boolean): this;
89
+ includeImages(include: boolean): this;
90
+ imageFormat(format: string): this;
91
+ imageQuality(quality: number): this;
92
+ maxImageDimension(maxDimension: number): this;
93
+ outputEncoding(encoding: string): this;
94
+ normalizeWhitespace(normalize: boolean): this;
95
+ extractAnnotations(extract: boolean): this;
96
+ useStructureTree(use: boolean): this;
97
+ pageRange(start: number, end: number): this;
98
+ build(): ConversionOptions;
99
+ }
100
+ /**
101
+ * Create a new ConversionOptionsBuilder with static factory
102
+ * @deprecated Use ConversionOptionsBuilder.create() instead
103
+ * @returns New builder instance
104
+ */
105
+ export declare function createConversionOptionsBuilder(): ConversionOptionsBuilder;
106
+ export {};
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Builder for conversion options when converting PDF to other formats
3
+ *
4
+ * Configures how PDFs are converted to Markdown, HTML, or other text formats
5
+ * with options for formatting, image handling, and content extraction.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { ConversionOptionsBuilder } from 'pdf_oxide';
10
+ *
11
+ * const options = ConversionOptionsBuilder.create()
12
+ * .preserveFormatting(true)
13
+ * .includeImages(true)
14
+ * .detectHeadings(true)
15
+ * .detectTables(true)
16
+ * .build();
17
+ *
18
+ * const doc = PdfDocument.open('file.pdf');
19
+ * const markdown = doc.toMarkdown(0, options);
20
+ * ```
21
+ */
22
+ export class ConversionOptionsBuilder {
23
+ /**
24
+ * Creates a new ConversionOptionsBuilder instance
25
+ * @private
26
+ */
27
+ constructor() {
28
+ this._preserveFormatting = true;
29
+ this._detectHeadings = true;
30
+ this._detectTables = true;
31
+ this._detectLists = true;
32
+ this._includeImages = true;
33
+ this._imageFormat = 'png';
34
+ this._imageQuality = 85;
35
+ this._maxImageDimension = 2048;
36
+ this._outputEncoding = 'utf-8';
37
+ this._normalizeWhitespace = true;
38
+ this._extractAnnotations = false;
39
+ this._useStructureTree = true;
40
+ }
41
+ /**
42
+ * Creates a new ConversionOptionsBuilder instance
43
+ * @returns New builder instance
44
+ */
45
+ static create() {
46
+ return new ConversionOptionsBuilder();
47
+ }
48
+ /**
49
+ * Creates options with default settings optimized for readability
50
+ * @returns Conversion options with default preset
51
+ */
52
+ static default() {
53
+ return ConversionOptionsBuilder.create().build();
54
+ }
55
+ /**
56
+ * Creates options optimized for text-only extraction
57
+ * @returns Conversion options with text-only preset
58
+ */
59
+ static textOnly() {
60
+ return ConversionOptionsBuilder.create()
61
+ .preserveFormatting(false)
62
+ .detectHeadings(true)
63
+ .detectTables(false)
64
+ .detectLists(false)
65
+ .includeImages(false)
66
+ .build();
67
+ }
68
+ /**
69
+ * Creates options optimized for maximum quality and detail preservation
70
+ * @returns Conversion options with high-quality preset
71
+ */
72
+ static highQuality() {
73
+ return ConversionOptionsBuilder.create()
74
+ .preserveFormatting(true)
75
+ .detectHeadings(true)
76
+ .detectTables(true)
77
+ .detectLists(true)
78
+ .includeImages(true)
79
+ .imageQuality(95)
80
+ .normalizeWhitespace(false)
81
+ .build();
82
+ }
83
+ /**
84
+ * Creates options for fast, basic conversion
85
+ * @returns Conversion options with fast preset
86
+ */
87
+ static fast() {
88
+ return ConversionOptionsBuilder.create()
89
+ .preserveFormatting(false)
90
+ .detectHeadings(false)
91
+ .detectTables(false)
92
+ .detectLists(false)
93
+ .includeImages(false)
94
+ .normalizeWhitespace(true)
95
+ .build();
96
+ }
97
+ preserveFormatting(preserve) {
98
+ if (typeof preserve !== 'boolean') {
99
+ throw new Error('preserveFormatting must be a boolean');
100
+ }
101
+ this._preserveFormatting = preserve;
102
+ return this;
103
+ }
104
+ detectHeadings(detect) {
105
+ if (typeof detect !== 'boolean') {
106
+ throw new Error('detectHeadings must be a boolean');
107
+ }
108
+ this._detectHeadings = detect;
109
+ return this;
110
+ }
111
+ detectTables(detect) {
112
+ if (typeof detect !== 'boolean') {
113
+ throw new Error('detectTables must be a boolean');
114
+ }
115
+ this._detectTables = detect;
116
+ return this;
117
+ }
118
+ detectLists(detect) {
119
+ if (typeof detect !== 'boolean') {
120
+ throw new Error('detectLists must be a boolean');
121
+ }
122
+ this._detectLists = detect;
123
+ return this;
124
+ }
125
+ includeImages(include) {
126
+ if (typeof include !== 'boolean') {
127
+ throw new Error('includeImages must be a boolean');
128
+ }
129
+ this._includeImages = include;
130
+ return this;
131
+ }
132
+ imageFormat(format) {
133
+ const validFormats = ['png', 'jpg', 'jpeg', 'webp'];
134
+ if (!validFormats.includes(format.toLowerCase())) {
135
+ throw new Error(`Invalid image format. Must be one of: ${validFormats.join(', ')}`);
136
+ }
137
+ this._imageFormat = format.toLowerCase();
138
+ return this;
139
+ }
140
+ imageQuality(quality) {
141
+ if (typeof quality !== 'number' || quality < 0 || quality > 100) {
142
+ throw new Error('imageQuality must be a number between 0 and 100');
143
+ }
144
+ this._imageQuality = quality;
145
+ return this;
146
+ }
147
+ maxImageDimension(maxDimension) {
148
+ if (typeof maxDimension !== 'number' || maxDimension <= 0) {
149
+ throw new Error('maxImageDimension must be a positive number');
150
+ }
151
+ this._maxImageDimension = maxDimension;
152
+ return this;
153
+ }
154
+ outputEncoding(encoding) {
155
+ if (typeof encoding !== 'string' || encoding.length === 0) {
156
+ throw new Error('outputEncoding must be a non-empty string');
157
+ }
158
+ this._outputEncoding = encoding;
159
+ return this;
160
+ }
161
+ normalizeWhitespace(normalize) {
162
+ if (typeof normalize !== 'boolean') {
163
+ throw new Error('normalizeWhitespace must be a boolean');
164
+ }
165
+ this._normalizeWhitespace = normalize;
166
+ return this;
167
+ }
168
+ extractAnnotations(extract) {
169
+ if (typeof extract !== 'boolean') {
170
+ throw new Error('extractAnnotations must be a boolean');
171
+ }
172
+ this._extractAnnotations = extract;
173
+ return this;
174
+ }
175
+ useStructureTree(use) {
176
+ if (typeof use !== 'boolean') {
177
+ throw new Error('useStructureTree must be a boolean');
178
+ }
179
+ this._useStructureTree = use;
180
+ return this;
181
+ }
182
+ pageRange(start, end) {
183
+ if (typeof start !== 'number' || typeof end !== 'number' || start < 0 || end < start) {
184
+ throw new Error('pageRange must have valid start and end indices');
185
+ }
186
+ this._pageRange = { start, end };
187
+ return this;
188
+ }
189
+ build() {
190
+ return {
191
+ preserveFormatting: this._preserveFormatting,
192
+ detectHeadings: this._detectHeadings,
193
+ detectTables: this._detectTables,
194
+ detectLists: this._detectLists,
195
+ includeImages: this._includeImages,
196
+ imageFormat: this._imageFormat,
197
+ imageQuality: this._imageQuality,
198
+ maxImageDimension: this._maxImageDimension,
199
+ outputEncoding: this._outputEncoding,
200
+ normalizeWhitespace: this._normalizeWhitespace,
201
+ extractAnnotations: this._extractAnnotations,
202
+ useStructureTree: this._useStructureTree,
203
+ pageRange: this._pageRange,
204
+ };
205
+ }
206
+ }
207
+ /**
208
+ * Create a new ConversionOptionsBuilder with static factory
209
+ * @deprecated Use ConversionOptionsBuilder.create() instead
210
+ * @returns New builder instance
211
+ */
212
+ export function createConversionOptionsBuilder() {
213
+ return ConversionOptionsBuilder.create();
214
+ }