pdf-oxide 0.3.37 → 0.3.39

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 (65) hide show
  1. package/lib/builders/document-builder.d.ts +350 -0
  2. package/lib/builders/document-builder.js +724 -0
  3. package/lib/builders/index.d.ts +4 -2
  4. package/lib/builders/index.js +4 -2
  5. package/lib/builders/pdf-builder.d.ts +2 -0
  6. package/lib/builders/pdf-builder.js +12 -0
  7. package/lib/builders/streaming-table.d.ts +49 -0
  8. package/lib/builders/streaming-table.js +110 -0
  9. package/lib/document-editor.d.ts +122 -0
  10. package/lib/document-editor.js +313 -0
  11. package/lib/errors.js +3 -4
  12. package/lib/form-field-manager.js +3 -1
  13. package/lib/index.d.ts +41 -7
  14. package/lib/index.js +266 -90
  15. package/lib/managers/accessibility-manager.js +19 -8
  16. package/lib/managers/annotation-manager.js +9 -9
  17. package/lib/managers/barcode-manager.js +18 -7
  18. package/lib/managers/batch-manager.js +2 -5
  19. package/lib/managers/cache-manager.js +1 -3
  20. package/lib/managers/compliance-manager.js +58 -19
  21. package/lib/managers/document-utility-manager.js +6 -6
  22. package/lib/managers/dom-pdf-creator.js +9 -9
  23. package/lib/managers/enterprise-manager.js +4 -1
  24. package/lib/managers/extended-managers.js +8 -1
  25. package/lib/managers/extraction-manager.js +7 -2
  26. package/lib/managers/final-utilities.d.ts +3 -3
  27. package/lib/managers/final-utilities.js +9 -4
  28. package/lib/managers/hybrid-ml-advanced.js +22 -6
  29. package/lib/managers/index.d.ts +22 -22
  30. package/lib/managers/index.js +23 -23
  31. package/lib/managers/layer-manager.js +20 -21
  32. package/lib/managers/ocr-manager.d.ts +2 -2
  33. package/lib/managers/ocr-manager.js +7 -7
  34. package/lib/managers/optimization-manager.js +24 -4
  35. package/lib/managers/page-manager.js +5 -6
  36. package/lib/managers/pattern-detection.d.ts +1 -1
  37. package/lib/managers/pattern-detection.js +4 -6
  38. package/lib/managers/search-manager.js +3 -3
  39. package/lib/managers/signature-manager.d.ts +14 -0
  40. package/lib/managers/signature-manager.js +185 -40
  41. package/lib/managers/streams.js +8 -2
  42. package/lib/managers/xfa-manager.js +69 -19
  43. package/lib/native-loader.d.ts +7 -0
  44. package/lib/native-loader.js +62 -0
  45. package/lib/native.d.ts +16 -0
  46. package/lib/native.js +69 -0
  47. package/lib/pdf-creator-manager.js +4 -1
  48. package/lib/result-accessors-manager.js +3 -1
  49. package/lib/timestamp.d.ts +54 -0
  50. package/lib/timestamp.js +115 -0
  51. package/lib/tsa-client.d.ts +44 -0
  52. package/lib/tsa-client.js +67 -0
  53. package/lib/types/common.d.ts +80 -1
  54. package/lib/types/common.js +14 -1
  55. package/lib/types/index.d.ts +1 -1
  56. package/lib/types/index.js +1 -1
  57. package/lib/types/manager-types.js +4 -2
  58. package/lib/workers/index.d.ts +1 -1
  59. package/lib/workers/pool.js +2 -4
  60. package/package.json +17 -11
  61. package/prebuilds/darwin-arm64/pdf_oxide.node +0 -0
  62. package/prebuilds/darwin-x64/pdf_oxide.node +0 -0
  63. package/prebuilds/linux-arm64/pdf_oxide.node +0 -0
  64. package/prebuilds/linux-x64/pdf_oxide.node +0 -0
  65. package/prebuilds/win32-x64/pdf_oxide.node +0 -0
@@ -69,7 +69,8 @@ export class BarcodeManager extends EventEmitter {
69
69
  if (this.native?.detect_barcodes) {
70
70
  try {
71
71
  const barcodesJson = this.native.detect_barcodes(pageIndex) ?? [];
72
- barcodes = barcodesJson.length > 0 ? barcodesJson.map((json) => JSON.parse(json)) : [];
72
+ barcodes =
73
+ barcodesJson.length > 0 ? barcodesJson.map((json) => JSON.parse(json)) : [];
73
74
  }
74
75
  catch {
75
76
  barcodes = [];
@@ -89,7 +90,7 @@ export class BarcodeManager extends EventEmitter {
89
90
  const barcodesJson = this.native.detect_all_barcodes();
90
91
  const parsed = JSON.parse(barcodesJson);
91
92
  for (const [page, barcodesArray] of Object.entries(parsed)) {
92
- barcodes.set(parseInt(page), barcodesArray.map(b => JSON.parse(typeof b === 'string' ? b : JSON.stringify(b))));
93
+ barcodes.set(parseInt(page), barcodesArray.map((b) => JSON.parse(typeof b === 'string' ? b : JSON.stringify(b))));
93
94
  }
94
95
  }
95
96
  catch {
@@ -101,7 +102,9 @@ export class BarcodeManager extends EventEmitter {
101
102
  return barcodes;
102
103
  }
103
104
  async getBarcodesOfFormat(format, pageIndex) {
104
- const cacheKey = pageIndex ? `barcodes:format:${format}:${pageIndex}` : `barcodes:format:${format}:all`;
105
+ const cacheKey = pageIndex
106
+ ? `barcodes:format:${format}:${pageIndex}`
107
+ : `barcodes:format:${format}:all`;
105
108
  if (this.resultCache.has(cacheKey))
106
109
  return this.resultCache.get(cacheKey);
107
110
  let barcodes = [];
@@ -109,7 +112,8 @@ export class BarcodeManager extends EventEmitter {
109
112
  try {
110
113
  const page = pageIndex ?? -1;
111
114
  const barcodesJson = this.native.get_barcodes_of_format(format, page) ?? [];
112
- barcodes = barcodesJson.length > 0 ? barcodesJson.map((json) => JSON.parse(json)) : [];
115
+ barcodes =
116
+ barcodesJson.length > 0 ? barcodesJson.map((json) => JSON.parse(json)) : [];
113
117
  }
114
118
  catch {
115
119
  barcodes = [];
@@ -168,7 +172,7 @@ export class BarcodeManager extends EventEmitter {
168
172
  if (sizePx < 1 || sizePx > 10000)
169
173
  throw new Error('Size must be between 1 and 10000 pixels');
170
174
  const barcodeData = await this.document?.generateQrCode?.(data, errorCorrection, sizePx);
171
- this.emit('barcode-generated', { format: 'qr', size: sizePx });
175
+ this.emit('barcodeGenerated', { format: 'qr', size: sizePx });
172
176
  return barcodeData || Buffer.alloc(0);
173
177
  }
174
178
  catch (error) {
@@ -209,9 +213,16 @@ export class BarcodeManager extends EventEmitter {
209
213
  // ===========================================================================
210
214
  // Cache
211
215
  // ===========================================================================
212
- clearCache() { this.resultCache.clear(); this.emit('cacheCleared'); }
216
+ clearCache() {
217
+ this.resultCache.clear();
218
+ this.emit('cacheCleared');
219
+ }
213
220
  getCacheStats() {
214
- return { cacheSize: this.resultCache.size, maxCacheSize: this.maxCacheSize, entries: Array.from(this.resultCache.keys()) };
221
+ return {
222
+ cacheSize: this.resultCache.size,
223
+ maxCacheSize: this.maxCacheSize,
224
+ entries: Array.from(this.resultCache.keys()),
225
+ };
215
226
  }
216
227
  setCached(key, value) {
217
228
  this.resultCache.set(key, value);
@@ -96,9 +96,7 @@ export class BatchManager {
96
96
  const elapsedTime = Date.now() - startTime;
97
97
  const completedDocs = completed + failed;
98
98
  const avgTimePerDoc = completedDocs > 0 ? elapsedTime / completedDocs : 0;
99
- const eta = completedDocs > 0
100
- ? (this.documents.length - completedDocs) * avgTimePerDoc
101
- : 0;
99
+ const eta = completedDocs > 0 ? (this.documents.length - completedDocs) * avgTimePerDoc : 0;
102
100
  if (options.onProgress) {
103
101
  options.onProgress({
104
102
  total: this.documents.length,
@@ -180,8 +178,7 @@ export class BatchManager {
180
178
  this.stats.totalTime = totalTime;
181
179
  this.stats.completed = completed;
182
180
  this.stats.failed = failed;
183
- this.stats.averageTime =
184
- completed > 0 ? totalTime / completed : 0;
181
+ this.stats.averageTime = completed > 0 ? totalTime / completed : 0;
185
182
  this.stats.throughput = totalTime > 0 ? (completed / totalTime) * 1000 : 0;
186
183
  return results.filter((r) => r !== undefined);
187
184
  }
@@ -216,9 +216,7 @@ export class CacheManager extends EventEmitter {
216
216
  totalSize,
217
217
  hitCount: this.hitCount,
218
218
  missCount: this.missCount,
219
- hitRate: this.hitCount + this.missCount > 0
220
- ? this.hitCount / (this.hitCount + this.missCount)
221
- : 0,
219
+ hitRate: this.hitCount + this.missCount > 0 ? this.hitCount / (this.hitCount + this.missCount) : 0,
222
220
  evictionCount: this.evictionCount,
223
221
  oldestEntry: timestamps.length > 0 ? Math.min(...timestamps) : undefined,
224
222
  newestEntry: timestamps.length > 0 ? Math.max(...timestamps) : undefined,
@@ -109,7 +109,12 @@ export class ComplianceManager extends EventEmitter {
109
109
  isCompliant = true;
110
110
  }
111
111
  }
112
- const result = { isCompliant, level: typeof level === 'string' ? level : level, issues, validationTime };
112
+ const result = {
113
+ isCompliant,
114
+ level: typeof level === 'string' ? level : level,
115
+ issues,
116
+ validationTime,
117
+ };
113
118
  this.setCached(cacheKey, result);
114
119
  this.emit('pdfAValidated', { level, isCompliant, issueCount: issues.length });
115
120
  return result;
@@ -149,7 +154,12 @@ export class ComplianceManager extends EventEmitter {
149
154
  isCompliant = true;
150
155
  }
151
156
  }
152
- const result = { isCompliant, level: typeof level === 'string' ? level : level, issues, validationTime };
157
+ const result = {
158
+ isCompliant,
159
+ level: typeof level === 'string' ? level : level,
160
+ issues,
161
+ validationTime,
162
+ };
153
163
  this.setCached(cacheKey, result);
154
164
  this.emit('pdfXValidated', { level, isCompliant, issueCount: issues.length });
155
165
  return result;
@@ -188,7 +198,12 @@ export class ComplianceManager extends EventEmitter {
188
198
  isCompliant = true;
189
199
  }
190
200
  }
191
- const result = { isCompliant, level: typeof level === 'string' ? level : level, issues, validationTime };
201
+ const result = {
202
+ isCompliant,
203
+ level: typeof level === 'string' ? level : level,
204
+ issues,
205
+ validationTime,
206
+ };
192
207
  this.setCached(cacheKey, result);
193
208
  this.emit('pdfUAValidated', { level, isCompliant, issueCount: issues.length });
194
209
  return result;
@@ -215,11 +230,17 @@ export class ComplianceManager extends EventEmitter {
215
230
  }
216
231
  async getIssuesOfType(type) {
217
232
  const allIssues = await this.getAllIssues();
218
- return allIssues.filter(issue => issue.type === type);
233
+ return allIssues.filter((issue) => issue.type === type);
234
+ }
235
+ async getIssueCount() {
236
+ return (await this.getAllIssues()).length;
237
+ }
238
+ async getErrorCount() {
239
+ return (await this.getAllIssues()).filter((i) => i.severity === IssueSeverity.Error).length;
240
+ }
241
+ async getWarningCount() {
242
+ return (await this.getAllIssues()).filter((i) => i.severity === IssueSeverity.Warning).length;
219
243
  }
220
- async getIssueCount() { return (await this.getAllIssues()).length; }
221
- async getErrorCount() { return (await this.getAllIssues()).filter(i => i.severity === IssueSeverity.Error).length; }
222
- async getWarningCount() { return (await this.getAllIssues()).filter(i => i.severity === IssueSeverity.Warning).length; }
223
244
  // ===========================================================================
224
245
  // Conversion & Fixing (from managers version)
225
246
  // ===========================================================================
@@ -249,7 +270,7 @@ export class ComplianceManager extends EventEmitter {
249
270
  }
250
271
  async getComplianceReport(complianceType = 'all') {
251
272
  try {
252
- return await this.document?.getComplianceReport?.(complianceType) ?? '';
273
+ return (await this.document?.getComplianceReport?.(complianceType)) ?? '';
253
274
  }
254
275
  catch (error) {
255
276
  this.emit('error', error);
@@ -260,25 +281,33 @@ export class ComplianceManager extends EventEmitter {
260
281
  const cacheKey = 'compliance:fonts_embedded';
261
282
  if (this.resultCache.has(cacheKey))
262
283
  return this.resultCache.get(cacheKey);
263
- const result = this.document?.checkFontEmbedding?.() ?? this.native?.compliance_has_embedded_fonts?.() ?? true;
284
+ const result = this.document?.checkFontEmbedding?.() ??
285
+ this.native?.compliance_has_embedded_fonts?.() ??
286
+ true;
264
287
  this.setCached(cacheKey, result);
265
288
  return result;
266
289
  }
267
290
  /** @deprecated Use checkFontEmbedding() instead */
268
- async hasFontsEmbedded() { return this.checkFontEmbedding(); }
291
+ async hasFontsEmbedded() {
292
+ return this.checkFontEmbedding();
293
+ }
269
294
  async checkColorSpace() {
270
295
  const cacheKey = 'compliance:valid_color_space';
271
296
  if (this.resultCache.has(cacheKey))
272
297
  return this.resultCache.get(cacheKey);
273
- const result = this.document?.checkColorSpace?.() ?? this.native?.compliance_has_valid_color_space?.() ?? true;
298
+ const result = this.document?.checkColorSpace?.() ??
299
+ this.native?.compliance_has_valid_color_space?.() ??
300
+ true;
274
301
  this.setCached(cacheKey, result);
275
302
  return result;
276
303
  }
277
304
  /** @deprecated Use checkColorSpace() instead */
278
- async hasValidColorSpace() { return this.checkColorSpace(); }
305
+ async hasValidColorSpace() {
306
+ return this.checkColorSpace();
307
+ }
279
308
  async checkTaggedContent() {
280
309
  try {
281
- return await this.document?.checkTaggedContent?.() ?? false;
310
+ return (await this.document?.checkTaggedContent?.()) ?? false;
282
311
  }
283
312
  catch (error) {
284
313
  this.emit('error', error);
@@ -298,7 +327,7 @@ export class ComplianceManager extends EventEmitter {
298
327
  }
299
328
  async fixFontIssues() {
300
329
  try {
301
- const count = await this.document?.fixFontIssues?.() ?? 0;
330
+ const count = (await this.document?.fixFontIssues?.()) ?? 0;
302
331
  this.emit('fonts-fixed', { count });
303
332
  return count;
304
333
  }
@@ -309,7 +338,7 @@ export class ComplianceManager extends EventEmitter {
309
338
  }
310
339
  async fixColorIssues() {
311
340
  try {
312
- const count = await this.document?.fixColorIssues?.() ?? 0;
341
+ const count = (await this.document?.fixColorIssues?.()) ?? 0;
313
342
  this.emit('colors-fixed', { count });
314
343
  return count;
315
344
  }
@@ -320,7 +349,7 @@ export class ComplianceManager extends EventEmitter {
320
349
  }
321
350
  async removeUnsupportedFeatures() {
322
351
  try {
323
- const count = await this.document?.removeUnsupportedFeatures?.() ?? 0;
352
+ const count = (await this.document?.removeUnsupportedFeatures?.()) ?? 0;
324
353
  this.emit('features-removed', { count });
325
354
  return count;
326
355
  }
@@ -397,11 +426,21 @@ export class ComplianceManager extends EventEmitter {
397
426
  // ===========================================================================
398
427
  // Cache
399
428
  // ===========================================================================
400
- clearCache() { this.resultCache.clear(); this.emit('cacheCleared'); }
429
+ clearCache() {
430
+ this.resultCache.clear();
431
+ this.emit('cacheCleared');
432
+ }
401
433
  getCacheStats() {
402
- return { cacheSize: this.resultCache.size, maxCacheSize: this.maxCacheSize, entries: Array.from(this.resultCache.keys()) };
434
+ return {
435
+ cacheSize: this.resultCache.size,
436
+ maxCacheSize: this.maxCacheSize,
437
+ entries: Array.from(this.resultCache.keys()),
438
+ };
439
+ }
440
+ destroy() {
441
+ this.resultCache.clear();
442
+ this.removeAllListeners();
403
443
  }
404
- destroy() { this.resultCache.clear(); this.removeAllListeners(); }
405
444
  setCached(key, value) {
406
445
  this.resultCache.set(key, value);
407
446
  if (this.resultCache.size > this.maxCacheSize) {
@@ -420,7 +420,7 @@ export class DocumentUtilityManager extends EventEmitter {
420
420
  async getDocumentStatistics() {
421
421
  try {
422
422
  const stats = await this.document?.getDocumentStatistics?.();
423
- return stats ?? {
423
+ return (stats ?? {
424
424
  pageCount: await this.getPageCount(),
425
425
  fileSize: await this.getFileSize(),
426
426
  objectCount: 0,
@@ -437,7 +437,7 @@ export class DocumentUtilityManager extends EventEmitter {
437
437
  isLinearized: false,
438
438
  isEncrypted: false,
439
439
  pdfVersion: '1.7',
440
- };
440
+ });
441
441
  }
442
442
  catch (error) {
443
443
  this.emit('error', error);
@@ -462,7 +462,7 @@ export class DocumentUtilityManager extends EventEmitter {
462
462
  */
463
463
  async getPageCount() {
464
464
  try {
465
- return await this.document?.getPageCount?.() ?? 0;
465
+ return (await this.document?.getPageCount?.()) ?? 0;
466
466
  }
467
467
  catch (error) {
468
468
  this.emit('error', error);
@@ -474,7 +474,7 @@ export class DocumentUtilityManager extends EventEmitter {
474
474
  */
475
475
  async getFileSize() {
476
476
  try {
477
- return await this.document?.getFileSize?.() ?? 0;
477
+ return (await this.document?.getFileSize?.()) ?? 0;
478
478
  }
479
479
  catch (error) {
480
480
  this.emit('error', error);
@@ -486,7 +486,7 @@ export class DocumentUtilityManager extends EventEmitter {
486
486
  */
487
487
  async isLinearized() {
488
488
  try {
489
- return await this.document?.isLinearized?.() ?? false;
489
+ return (await this.document?.isLinearized?.()) ?? false;
490
490
  }
491
491
  catch (error) {
492
492
  this.emit('error', error);
@@ -610,7 +610,7 @@ export class DocumentUtilityManager extends EventEmitter {
610
610
  */
611
611
  async saveToBytes() {
612
612
  try {
613
- return await this.document?.saveToBytes?.() ?? null;
613
+ return (await this.document?.saveToBytes?.()) ?? null;
614
614
  }
615
615
  catch (error) {
616
616
  this.emit('error', error);
@@ -57,7 +57,7 @@ export class DOMElementsManager extends EventEmitter {
57
57
  rotation: element.rotation || 0,
58
58
  opacity: element.opacity || 1.0,
59
59
  visible: element.visible !== false,
60
- metadata: element.metadata
60
+ metadata: element.metadata,
61
61
  };
62
62
  }
63
63
  catch (error) {
@@ -67,7 +67,7 @@ export class DOMElementsManager extends EventEmitter {
67
67
  }
68
68
  async getElementType(elementIndex) {
69
69
  try {
70
- return await this.document?.getElementType(elementIndex) || null;
70
+ return (await this.document?.getElementType(elementIndex)) || null;
71
71
  }
72
72
  catch (error) {
73
73
  this.emit('error', error);
@@ -84,7 +84,7 @@ export class DOMElementsManager extends EventEmitter {
84
84
  rotation: 0,
85
85
  opacity: 1.0,
86
86
  visible: true,
87
- type: 'text'
87
+ type: 'text',
88
88
  };
89
89
  return properties;
90
90
  }
@@ -95,7 +95,7 @@ export class DOMElementsManager extends EventEmitter {
95
95
  }
96
96
  async getElementChildren(elementIndex) {
97
97
  try {
98
- return await this.document?.getElementChildren(elementIndex) || [];
98
+ return (await this.document?.getElementChildren(elementIndex)) || [];
99
99
  }
100
100
  catch (error) {
101
101
  this.emit('error', error);
@@ -116,7 +116,7 @@ export class DOMElementsManager extends EventEmitter {
116
116
  try {
117
117
  if (!this.document)
118
118
  return false;
119
- return await this.document?.setElementProperties(elementIndex, properties) || false;
119
+ return (await this.document?.setElementProperties(elementIndex, properties)) || false;
120
120
  }
121
121
  catch (error) {
122
122
  this.emit('error', error);
@@ -171,7 +171,7 @@ export class PdfCreatorManager extends EventEmitter {
171
171
  index: pageIndex,
172
172
  width: pageW,
173
173
  height: pageH,
174
- elements: []
174
+ elements: [],
175
175
  });
176
176
  const result = await this.document?.addPage(pageW, pageH);
177
177
  this.emit('page-added', { pageIndex, width: pageW, height: pageH });
@@ -210,7 +210,7 @@ export class PdfCreatorManager extends EventEmitter {
210
210
  text,
211
211
  font: fontName,
212
212
  size: fontSize,
213
- color
213
+ color,
214
214
  };
215
215
  const page = this.pages[pageIndex];
216
216
  if (page) {
@@ -235,7 +235,7 @@ export class PdfCreatorManager extends EventEmitter {
235
235
  y,
236
236
  path: imagePath,
237
237
  width,
238
- height
238
+ height,
239
239
  };
240
240
  const page = this.pages[pageIndex];
241
241
  if (page) {
@@ -264,7 +264,7 @@ export class PdfCreatorManager extends EventEmitter {
264
264
  fillColor: shape.fillColor,
265
265
  strokeColor: shape.strokeColor,
266
266
  strokeWidth: shape.strokeWidth,
267
- rotation: shape.rotation
267
+ rotation: shape.rotation,
268
268
  };
269
269
  const page = this.pages[pageIndex];
270
270
  if (page) {
@@ -215,7 +215,10 @@ export class EnterpriseManager extends EventEmitter {
215
215
  totalDifferences: 0,
216
216
  };
217
217
  }
218
- this.emit('documents-compared', { similarity: result.similarity, totalDifferences: result.totalDifferences });
218
+ this.emit('documents-compared', {
219
+ similarity: result.similarity,
220
+ totalDifferences: result.totalDifferences,
221
+ });
219
222
  return result;
220
223
  }
221
224
  finally {
@@ -380,7 +380,14 @@ export class BatchProcessingManager extends EventEmitter {
380
380
  }
381
381
  async createBatchJob(jobId, filePath, operation) {
382
382
  try {
383
- const job = { jobId, filePath, operation, status: 'pending', progress: 0, errorMessage: undefined };
383
+ const job = {
384
+ jobId,
385
+ filePath,
386
+ operation,
387
+ status: 'pending',
388
+ progress: 0,
389
+ errorMessage: undefined,
390
+ };
384
391
  this.jobs.set(jobId, job);
385
392
  return job;
386
393
  }
@@ -153,7 +153,9 @@ export class ExtractionManager {
153
153
  try {
154
154
  const parts = [];
155
155
  for (const pageIndex of pageIndices) {
156
- if (typeof pageIndex !== 'number' || pageIndex < 0 || pageIndex >= this._document.pageCount) {
156
+ if (typeof pageIndex !== 'number' ||
157
+ pageIndex < 0 ||
158
+ pageIndex >= this._document.pageCount) {
157
159
  throw new Error(`Invalid page index: ${pageIndex}`);
158
160
  }
159
161
  parts.push(this.extractText(pageIndex, options));
@@ -297,7 +299,10 @@ export class ExtractionManager {
297
299
  */
298
300
  getTotalWordCount() {
299
301
  const allText = this.extractAllText();
300
- return allText.trim().split(/\s+/).filter(word => word.length > 0).length;
302
+ return allText
303
+ .trim()
304
+ .split(/\s+/)
305
+ .filter((word) => word.length > 0).length;
301
306
  }
302
307
  /**
303
308
  * Gets character count for a page
@@ -45,8 +45,8 @@ export declare class EventManager extends EventEmitter {
45
45
  private document;
46
46
  private eventListeners;
47
47
  constructor(document: any);
48
- addEventListener(eventType: EventType, handler: Function): Promise<boolean>;
49
- removeEventListener(eventType: EventType, handler: Function): Promise<boolean>;
48
+ addEventListener(eventType: EventType, handler: (event: unknown) => void): Promise<boolean>;
49
+ removeEventListener(eventType: EventType, handler: (event: unknown) => void): Promise<boolean>;
50
50
  emitEvent(event: DocumentEvent): Promise<boolean>;
51
51
  hasListener(eventType: EventType): Promise<boolean>;
52
52
  getListenerCount(eventType: EventType): Promise<number>;
@@ -96,7 +96,7 @@ export declare class CustomAnnotationManager extends EventEmitter {
96
96
  private customAnnotations;
97
97
  constructor(document: any);
98
98
  createCustomAnnotation(annotationType: string, properties: Record<string, any>): Promise<string | null>;
99
- registerAnnotationType(typeName: string, handler: Function): Promise<boolean>;
99
+ registerAnnotationType(typeName: string, handler: (...args: unknown[]) => unknown): Promise<boolean>;
100
100
  modifyAnnotation(annotationId: string, properties: Record<string, any>): Promise<boolean>;
101
101
  deleteCustomAnnotation(annotationId: string): Promise<boolean>;
102
102
  getCustomAnnotations(pageIndex: number): Promise<Record<string, any>[]>;
@@ -54,8 +54,11 @@ export class EventManager extends EventEmitter {
54
54
  async emitEvent(event) {
55
55
  try {
56
56
  const handlers = this.eventListeners.get(event.eventType);
57
- if (handlers)
58
- handlers.forEach(h => h(event));
57
+ if (handlers) {
58
+ handlers.forEach((h) => {
59
+ h(event);
60
+ });
61
+ }
59
62
  return true;
60
63
  }
61
64
  catch (error) {
@@ -65,7 +68,7 @@ export class EventManager extends EventEmitter {
65
68
  }
66
69
  async hasListener(eventType) {
67
70
  try {
68
- return this.eventListeners.has(eventType) && (this.eventListeners.get(eventType)?.length ?? 0) > 0;
71
+ return (this.eventListeners.has(eventType) && (this.eventListeners.get(eventType)?.length ?? 0) > 0);
69
72
  }
70
73
  catch (error) {
71
74
  this.emit('error', error);
@@ -112,7 +115,9 @@ export class EventManager extends EventEmitter {
112
115
  async getEventStatistics() {
113
116
  try {
114
117
  let total = 0;
115
- this.eventListeners.forEach(handlers => { total += handlers.length; });
118
+ this.eventListeners.forEach((handlers) => {
119
+ total += handlers.length;
120
+ });
116
121
  return { total_listeners: total, event_types: this.eventListeners.size };
117
122
  }
118
123
  catch (error) {
@@ -293,7 +293,12 @@ export class ConfigurationManager extends EventEmitter {
293
293
  if (!this.document)
294
294
  return false;
295
295
  try {
296
- this.config.set(`doc_${key}`, { key, value, level: ConfigLevel.DOCUMENT, typeHint: typeof value });
296
+ this.config.set(`doc_${key}`, {
297
+ key,
298
+ value,
299
+ level: ConfigLevel.DOCUMENT,
300
+ typeHint: typeof value,
301
+ });
297
302
  return true;
298
303
  }
299
304
  catch (error) {
@@ -303,7 +308,12 @@ export class ConfigurationManager extends EventEmitter {
303
308
  }
304
309
  async setPageConfig(pageIndex, key, value) {
305
310
  try {
306
- this.config.set(`page_${pageIndex}_${key}`, { key, value, level: ConfigLevel.PAGE, typeHint: typeof value });
311
+ this.config.set(`page_${pageIndex}_${key}`, {
312
+ key,
313
+ value,
314
+ level: ConfigLevel.PAGE,
315
+ typeHint: typeof value,
316
+ });
307
317
  return true;
308
318
  }
309
319
  catch (error) {
@@ -325,7 +335,9 @@ export class ConfigurationManager extends EventEmitter {
325
335
  const keysToRemove = Array.from(this.config.entries())
326
336
  .filter(([_, item]) => item.level === level)
327
337
  .map(([key, _]) => key);
328
- keysToRemove.forEach(k => this.config.delete(k));
338
+ keysToRemove.forEach((k) => {
339
+ this.config.delete(k);
340
+ });
329
341
  return true;
330
342
  }
331
343
  catch (error) {
@@ -372,7 +384,9 @@ export class ConfigurationManager extends EventEmitter {
372
384
  async getAllConfig() {
373
385
  try {
374
386
  const result = {};
375
- this.config.forEach((item, key) => { result[key] = item.value; });
387
+ this.config.forEach((item, key) => {
388
+ result[key] = item.value;
389
+ });
376
390
  return result;
377
391
  }
378
392
  catch (error) {
@@ -382,7 +396,9 @@ export class ConfigurationManager extends EventEmitter {
382
396
  }
383
397
  async mergeConfig(otherConfig) {
384
398
  try {
385
- Object.entries(otherConfig).forEach(([key, value]) => this.setGlobalConfig(key, value));
399
+ Object.entries(otherConfig).forEach(([key, value]) => {
400
+ this.setGlobalConfig(key, value);
401
+ });
386
402
  return true;
387
403
  }
388
404
  catch (error) {
@@ -657,7 +673,7 @@ export class AdvancedSearchManager extends EventEmitter {
657
673
  try {
658
674
  return {
659
675
  total_searches: this.searchHistory.length,
660
- unique_queries: new Set(this.searchHistory.map(s => s.query)).size
676
+ unique_queries: new Set(this.searchHistory.map((s) => s.query)).size,
661
677
  };
662
678
  }
663
679
  catch (error) {
@@ -38,27 +38,27 @@
38
38
  * const highlights = annotationManager.getHighlights();
39
39
  * ```
40
40
  */
41
- export { OutlineManager, type OutlineItem } from './outline-manager.js';
42
- export { MetadataManager, type MetadataComparison, type ValidationResult, } from './metadata-manager.js';
43
- export { ExtractionManager, type ContentStatistics, type SearchMatch, } from './extraction-manager.js';
44
- export { SearchManager, type SearchResult, type SearchStatistics, type SearchCapabilities, } from './search-manager.js';
45
- export { SecurityManager, type PermissionsSummary, type SecurityLevel, type AccessibilityValidation, } from './security-manager.js';
46
- export { AnnotationManager, type Annotation, type AnnotationStatistics, type AnnotationValidation, } from './annotation-manager.js';
47
- export { LayerManager, type Layer, type LayerHierarchy, type LayerStatistics, type LayerValidation, } from './layer-manager.js';
48
- export { RenderingManager, RenderOptions, type RenderOptionsConfig, type PageDimensions, type PageBox, type RenderingStatistics, type PageResources, } from './rendering-manager.js';
49
- export { PageManager, type PageInfo, type PageRange, type PageStatistics, } from './page-manager.js';
50
- export { ContentManager, type ContentAnalysis, } from './content-manager.js';
51
- export { SearchStream, ExtractionStream, MetadataStream, createSearchStream, createExtractionStream, createMetadataStream, type SearchResultData, type ExtractionProgressData, type PageMetadataData, } from './streams.js';
52
- export { BatchManager, type BatchDocument, type BatchProgress, type BatchResult, type BatchOptions, type BatchStatistics, } from './batch-manager.js';
53
- export { ResultAccessorsManager, type SearchResultProperties, type FontProperties, type ImageProperties, type AnnotationProperties, } from '../result-accessors-manager.js';
54
- export { FormFieldManager, FormFieldType, FieldVisibility, type FormField, type FormFieldConfig, } from '../form-field-manager.js';
55
- export { OcrManager, OCRManager, OcrDetectionMode, type OcrConfig, type OcrSpan, type OcrPageAnalysis, } from './ocr-manager.js';
56
- export { SignatureManager, SignatureAlgorithm, DigestAlgorithm, SignatureType, CertificationPermission, CertificateFormat, TimestampStatus, FfiDigestAlgorithm, FfiSignatureSubFilter, type DigitalSignature, type SignatureField, type SignatureValidationResult, type SignatureConfig, type Certificate, type Signature, type CertificateInfo, type CertificateChain, type LoadedCertificate, type SignatureAppearance, type SignatureFieldConfig, type SigningOptions, type TimestampConfig, type SigningResult, type TimestampResult, type SigningCredentials, type SignOptions, } from './signature-manager.js';
57
- export { XfaManager, XFAManager, XfaFormType, XfaFieldType, XfaValidationType, XfaBindingType, type XfaField, type XfaDataset, type XfaFieldConfig, type XfaTemplateConfig, type XfaSubformConfig, type XfaScriptConfig, type XfaCreationResult, type XfaDataOptions, type XfaFieldHandle, } from './xfa-manager.js';
58
- export { ComplianceManager, PdfALevel, PdfXLevel, PdfUALevel, ComplianceIssueType, IssueSeverity, type ComplianceIssue, type ComplianceValidationResult, } from './compliance-manager.js';
59
- export { BarcodeManager, BarcodeFormat, BarcodeErrorCorrection, QrErrorCorrection, type DetectedBarcode, type BarcodeGenerationConfig, } from './barcode-manager.js';
41
+ export { FieldVisibility, type FormField, type FormFieldConfig, FormFieldManager, FormFieldType, } from '../form-field-manager.js';
42
+ export { type AnnotationProperties, type FontProperties, type ImageProperties, ResultAccessorsManager, type SearchResultProperties, } from '../result-accessors-manager.js';
43
+ export { AccessibilityManager, type AutoTagResult, type StructureElement, type StructureTree, } from './accessibility-manager.js';
44
+ export { type Annotation, AnnotationManager, type AnnotationStatistics, type AnnotationValidation, } from './annotation-manager.js';
45
+ export { BarcodeErrorCorrection, BarcodeFormat, type BarcodeGenerationConfig, BarcodeManager, type DetectedBarcode, QrErrorCorrection, } from './barcode-manager.js';
46
+ export { type BatchDocument, BatchManager, type BatchOptions, type BatchProgress, type BatchResult, type BatchStatistics, } from './batch-manager.js';
60
47
  export { CacheManager, type CacheStatistics as CacheStats, } from './cache-manager.js';
61
- export { EditingManager, type RedactionRect, type RgbColor, type ApplyRedactionsOptions, type ScrubMetadataOptions, } from './editing-manager.js';
62
- export { AccessibilityManager, type StructureElement, type StructureTree, type AutoTagResult, } from './accessibility-manager.js';
48
+ export { type ComplianceIssue, ComplianceIssueType, ComplianceManager, type ComplianceValidationResult, IssueSeverity, PdfALevel, PdfUALevel, PdfXLevel, } from './compliance-manager.js';
49
+ export { type ContentAnalysis, ContentManager, } from './content-manager.js';
50
+ export { type ApplyRedactionsOptions, EditingManager, type RedactionRect, type RgbColor, type ScrubMetadataOptions, } from './editing-manager.js';
51
+ export { BatesPosition, type Difference, DifferenceType, type DocumentComparisonResult, EnterpriseManager, type PageComparisonResult, StampAlignment, } from './enterprise-manager.js';
52
+ export { type ContentStatistics, ExtractionManager, type SearchMatch, } from './extraction-manager.js';
53
+ export { type Layer, type LayerHierarchy, LayerManager, type LayerStatistics, type LayerValidation, } from './layer-manager.js';
54
+ export { type MetadataComparison, MetadataManager, type ValidationResult, } from './metadata-manager.js';
55
+ export { OCRManager, type OcrConfig, OcrDetectionMode, OcrManager, type OcrPageAnalysis, type OcrSpan, } from './ocr-manager.js';
63
56
  export { OptimizationManager, type OptimizationResult, } from './optimization-manager.js';
64
- export { EnterpriseManager, BatesPosition, StampAlignment, DifferenceType, type Difference, type PageComparisonResult, type DocumentComparisonResult, } from './enterprise-manager.js';
57
+ export { type OutlineItem, OutlineManager } from './outline-manager.js';
58
+ export { type PageInfo, PageManager, type PageRange, type PageStatistics, } from './page-manager.js';
59
+ export { type PageBox, type PageDimensions, type PageResources, RenderingManager, type RenderingStatistics, RenderOptions, type RenderOptionsConfig, } from './rendering-manager.js';
60
+ export { type SearchCapabilities, SearchManager, type SearchResult, type SearchStatistics, } from './search-manager.js';
61
+ export { type AccessibilityValidation, type PermissionsSummary, type SecurityLevel, SecurityManager, } from './security-manager.js';
62
+ export { type Certificate, type CertificateChain, CertificateFormat, type CertificateInfo, CertificationPermission, DigestAlgorithm, type DigitalSignature, FfiDigestAlgorithm, FfiSignatureSubFilter, type LoadedCertificate, type Signature, SignatureAlgorithm, type SignatureAppearance, type SignatureConfig, type SignatureField, type SignatureFieldConfig, SignatureManager, SignatureType, type SignatureValidationResult, type SigningCredentials, type SigningOptions, type SigningResult, type SignOptions, type TimestampConfig, type TimestampResult, TimestampStatus, } from './signature-manager.js';
63
+ export { createExtractionStream, createMetadataStream, createSearchStream, type ExtractionProgressData, ExtractionStream, MetadataStream, type PageMetadataData, type SearchResultData, SearchStream, } from './streams.js';
64
+ export { XFAManager, XfaBindingType, type XfaCreationResult, type XfaDataOptions, type XfaDataset, type XfaField, type XfaFieldConfig, type XfaFieldHandle, XfaFieldType, XfaFormType, XfaManager, type XfaScriptConfig, type XfaSubformConfig, type XfaTemplateConfig, XfaValidationType, } from './xfa-manager.js';