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,387 @@
1
+ /**
2
+ * EditingManager - Document Editing Manager for redaction and flattening operations
3
+ *
4
+ * Provides PDF document editing capabilities:
5
+ * - Content redaction (add, apply, count redaction areas)
6
+ * - Metadata scrubbing (remove Info, XMP, JavaScript)
7
+ * - Form flattening (all pages or single page)
8
+ * - Annotation flattening (all pages or single page)
9
+ *
10
+ * Uses native FFI functions:
11
+ * - pdf_redaction_add, pdf_redaction_apply, pdf_redaction_scrub_metadata, pdf_redaction_count
12
+ * - pdf_document_editor_flatten_forms, pdf_document_editor_flatten_forms_page
13
+ * - pdf_document_editor_flatten_annotations, pdf_document_editor_flatten_annotations_page
14
+ */
15
+ import { EventEmitter } from 'events';
16
+ import { mapFfiErrorCode } from '../errors.js';
17
+ // =============================================================================
18
+ // Canonical EditingManager
19
+ // =============================================================================
20
+ /**
21
+ * Manages document editing operations including redaction and flattening.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { EditingManager } from 'pdf_oxide';
26
+ *
27
+ * const editor = new EditingManager(document);
28
+ *
29
+ * // Add redaction areas
30
+ * editor.addRedaction(0, { x1: 100, y1: 200, x2: 300, y2: 250 });
31
+ * editor.addRedaction(0, { x1: 50, y1: 400, x2: 200, y2: 450 }, { r: 0, g: 0, b: 0 });
32
+ *
33
+ * // Apply all queued redactions
34
+ * const count = editor.applyRedactions({ scrubMetadata: true });
35
+ * console.log(`Applied ${count} redactions`);
36
+ *
37
+ * // Flatten forms and annotations
38
+ * editor.flattenForms();
39
+ * editor.flattenAnnotations();
40
+ * ```
41
+ */
42
+ export class EditingManager extends EventEmitter {
43
+ constructor(document) {
44
+ super();
45
+ this.document = document;
46
+ try {
47
+ this.native = require('../../index.node');
48
+ }
49
+ catch {
50
+ this.native = null;
51
+ }
52
+ }
53
+ // ===========================================================================
54
+ // Redaction Operations
55
+ // ===========================================================================
56
+ /**
57
+ * Adds a redaction area to the document.
58
+ *
59
+ * Queues a rectangular region on a page for redaction. The content within
60
+ * the rectangle will be permanently removed when {@link applyRedactions}
61
+ * is called.
62
+ *
63
+ * @param page - Zero-based page index
64
+ * @param rect - Rectangle coordinates defining the redaction area
65
+ * @param color - Optional fill color for the redacted area (defaults to black)
66
+ * @throws {PdfException} If the document handle is invalid or page is out of range
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * // Redact a region with default black fill
71
+ * editor.addRedaction(0, { x1: 100, y1: 200, x2: 300, y2: 250 });
72
+ *
73
+ * // Redact with a custom gray fill
74
+ * editor.addRedaction(1, { x1: 50, y1: 100, x2: 200, y2: 150 }, { r: 0.5, g: 0.5, b: 0.5 });
75
+ * ```
76
+ */
77
+ addRedaction(page, rect, color) {
78
+ const fillColor = color ?? { r: 0, g: 0, b: 0 };
79
+ if (this.native?.pdf_redaction_add) {
80
+ const errorCode = { value: 0 };
81
+ const result = this.native.pdf_redaction_add(this.document?.handle ?? this.document, page, rect.x1, rect.y1, rect.x2, rect.y2, fillColor.r, fillColor.g, fillColor.b, errorCode);
82
+ if (result < 0 && errorCode.value !== 0) {
83
+ throw mapFfiErrorCode(errorCode.value, 'Failed to add redaction area');
84
+ }
85
+ }
86
+ else if (this.document?.addRedaction) {
87
+ this.document.addRedaction(page, rect, fillColor);
88
+ }
89
+ this.emit('redactionAdded', { page, rect, color: fillColor });
90
+ }
91
+ /**
92
+ * Applies all queued redactions to the document.
93
+ *
94
+ * Permanently removes content within all previously added redaction
95
+ * rectangles. Optionally scrubs document metadata and applies a
96
+ * fill color overlay.
97
+ *
98
+ * @param options - Options controlling redaction behavior
99
+ * @returns Number of redactions applied
100
+ * @throws {PdfException} If redaction application fails
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * // Apply with metadata scrubbing
105
+ * const count = editor.applyRedactions({ scrubMetadata: true });
106
+ *
107
+ * // Apply with custom fill color
108
+ * const count = editor.applyRedactions({
109
+ * fillColor: { r: 1.0, g: 1.0, b: 1.0 }
110
+ * });
111
+ * ```
112
+ */
113
+ applyRedactions(options) {
114
+ const scrubMetadata = options?.scrubMetadata ?? false;
115
+ const fillColor = options?.fillColor ?? { r: 0, g: 0, b: 0 };
116
+ if (this.native?.pdf_redaction_apply) {
117
+ const errorCode = { value: 0 };
118
+ const result = this.native.pdf_redaction_apply(this.document?.handle ?? this.document, scrubMetadata, fillColor.r, fillColor.g, fillColor.b, errorCode);
119
+ if (result < 0 && errorCode.value !== 0) {
120
+ throw mapFfiErrorCode(errorCode.value, 'Failed to apply redactions');
121
+ }
122
+ this.emit('redactionsApplied', { count: result, scrubMetadata });
123
+ return result;
124
+ }
125
+ else if (this.document?.applyRedactions) {
126
+ const count = this.document.applyRedactions(options);
127
+ this.emit('redactionsApplied', { count, scrubMetadata });
128
+ return count ?? 0;
129
+ }
130
+ return 0;
131
+ }
132
+ /**
133
+ * Scrubs sensitive metadata from the document.
134
+ *
135
+ * Removes document metadata fields that may contain sensitive information,
136
+ * such as author names, creation tools, and JavaScript.
137
+ *
138
+ * @param options - Options controlling which metadata to remove
139
+ * @throws {PdfException} If metadata scrubbing fails
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * // Remove all metadata
144
+ * editor.scrubMetadata();
145
+ *
146
+ * // Remove only Info dictionary and JavaScript
147
+ * editor.scrubMetadata({ removeInfo: true, removeXmp: false, removeJs: true });
148
+ * ```
149
+ */
150
+ scrubMetadata(options) {
151
+ const removeInfo = options?.removeInfo ?? true;
152
+ const removeXmp = options?.removeXmp ?? true;
153
+ const removeJs = options?.removeJs ?? true;
154
+ if (this.native?.pdf_redaction_scrub_metadata) {
155
+ const errorCode = { value: 0 };
156
+ const result = this.native.pdf_redaction_scrub_metadata(this.document?.handle ?? this.document, removeInfo, removeXmp, removeJs, errorCode);
157
+ if (result < 0 && errorCode.value !== 0) {
158
+ throw mapFfiErrorCode(errorCode.value, 'Failed to scrub metadata');
159
+ }
160
+ }
161
+ else if (this.document?.scrubMetadata) {
162
+ this.document.scrubMetadata(options);
163
+ }
164
+ this.emit('metadataScrubbed', { removeInfo, removeXmp, removeJs });
165
+ }
166
+ /**
167
+ * Gets the number of queued (pending) redaction areas.
168
+ *
169
+ * @returns Number of redaction areas queued for application
170
+ * @throws {PdfException} If the document handle is invalid
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * editor.addRedaction(0, { x1: 10, y1: 20, x2: 100, y2: 50 });
175
+ * editor.addRedaction(1, { x1: 30, y1: 40, x2: 200, y2: 80 });
176
+ * console.log(editor.getRedactionCount()); // 2
177
+ * ```
178
+ */
179
+ getRedactionCount() {
180
+ if (this.native?.pdf_redaction_count) {
181
+ const errorCode = { value: 0 };
182
+ const result = this.native.pdf_redaction_count(this.document?.handle ?? this.document, errorCode);
183
+ if (result < 0 && errorCode.value !== 0) {
184
+ throw mapFfiErrorCode(errorCode.value, 'Failed to get redaction count');
185
+ }
186
+ return result;
187
+ }
188
+ else if (this.document?.getRedactionCount) {
189
+ return this.document.getRedactionCount() ?? 0;
190
+ }
191
+ return 0;
192
+ }
193
+ // ===========================================================================
194
+ // Form Flattening Operations
195
+ // ===========================================================================
196
+ /**
197
+ * Flattens all form fields in the document.
198
+ *
199
+ * Renders form field widgets into page content and removes the AcroForm
200
+ * dictionary. After flattening, form fields become static content and
201
+ * can no longer be edited interactively.
202
+ *
203
+ * @throws {PdfException} If flattening fails
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * editor.flattenForms();
208
+ * ```
209
+ */
210
+ flattenForms() {
211
+ if (this.native?.pdf_document_editor_flatten_forms) {
212
+ const errorCode = { value: 0 };
213
+ const result = this.native.pdf_document_editor_flatten_forms(this.document?.handle ?? this.document, errorCode);
214
+ if (result < 0 && errorCode.value !== 0) {
215
+ throw mapFfiErrorCode(errorCode.value, 'Failed to flatten forms');
216
+ }
217
+ }
218
+ else if (this.document?.flattenForms) {
219
+ this.document.flattenForms();
220
+ }
221
+ this.emit('formsFlattened');
222
+ }
223
+ /**
224
+ * Flattens form fields on a specific page.
225
+ *
226
+ * Only flattens form field widgets located on the specified page,
227
+ * leaving form fields on other pages editable.
228
+ *
229
+ * @param page - Zero-based page index
230
+ * @throws {PdfException} If flattening fails or page is out of range
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * // Flatten forms on first page only
235
+ * editor.flattenFormsPage(0);
236
+ * ```
237
+ */
238
+ flattenFormsPage(page) {
239
+ if (this.native?.pdf_document_editor_flatten_forms_page) {
240
+ const errorCode = { value: 0 };
241
+ const result = this.native.pdf_document_editor_flatten_forms_page(this.document?.handle ?? this.document, page, errorCode);
242
+ if (result < 0 && errorCode.value !== 0) {
243
+ throw mapFfiErrorCode(errorCode.value, `Failed to flatten forms on page ${page}`);
244
+ }
245
+ }
246
+ else if (this.document?.flattenFormsPage) {
247
+ this.document.flattenFormsPage(page);
248
+ }
249
+ this.emit('formsPageFlattened', { page });
250
+ }
251
+ // ===========================================================================
252
+ // Annotation Flattening Operations
253
+ // ===========================================================================
254
+ /**
255
+ * Flattens all annotations in the document.
256
+ *
257
+ * Renders annotations into page content and removes them from
258
+ * annotation arrays. After flattening, annotations become static
259
+ * content and can no longer be edited or deleted.
260
+ *
261
+ * @throws {PdfException} If flattening fails
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * editor.flattenAnnotations();
266
+ * ```
267
+ */
268
+ flattenAnnotations() {
269
+ if (this.native?.pdf_document_editor_flatten_annotations) {
270
+ const errorCode = { value: 0 };
271
+ const result = this.native.pdf_document_editor_flatten_annotations(this.document?.handle ?? this.document, errorCode);
272
+ if (result < 0 && errorCode.value !== 0) {
273
+ throw mapFfiErrorCode(errorCode.value, 'Failed to flatten annotations');
274
+ }
275
+ }
276
+ else if (this.document?.flattenAnnotations) {
277
+ this.document.flattenAnnotations();
278
+ }
279
+ this.emit('annotationsFlattened');
280
+ }
281
+ /**
282
+ * Flattens annotations on a specific page.
283
+ *
284
+ * Only flattens annotations located on the specified page,
285
+ * leaving annotations on other pages editable.
286
+ *
287
+ * @param page - Zero-based page index
288
+ * @throws {PdfException} If flattening fails or page is out of range
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * // Flatten annotations on page 2
293
+ * editor.flattenAnnotationsPage(1);
294
+ * ```
295
+ */
296
+ flattenAnnotationsPage(page) {
297
+ if (this.native?.pdf_document_editor_flatten_annotations_page) {
298
+ const errorCode = { value: 0 };
299
+ const result = this.native.pdf_document_editor_flatten_annotations_page(this.document?.handle ?? this.document, page, errorCode);
300
+ if (result < 0 && errorCode.value !== 0) {
301
+ throw mapFfiErrorCode(errorCode.value, `Failed to flatten annotations on page ${page}`);
302
+ }
303
+ }
304
+ else if (this.document?.flattenAnnotationsPage) {
305
+ this.document.flattenAnnotationsPage(page);
306
+ }
307
+ this.emit('annotationsPageFlattened', { page });
308
+ }
309
+ // ===========================================================================
310
+ // Form Data Import/Export
311
+ // ===========================================================================
312
+ /**
313
+ * Import form data from a file (FDF or XFDF, auto-detected by extension).
314
+ * @param filePath Path to the FDF or XFDF file
315
+ * @returns Number of fields imported
316
+ */
317
+ importFormDataFromFile(filePath) {
318
+ if (this.native?.pdf_document_import_form_data) {
319
+ const errorCode = { value: 0 };
320
+ const count = this.native.pdf_document_import_form_data(this.document?.handle ?? this.document, filePath, errorCode);
321
+ if (errorCode.value !== 0) {
322
+ throw mapFfiErrorCode(errorCode.value, `Failed to import form data from ${filePath}`);
323
+ }
324
+ return count;
325
+ }
326
+ throw new Error('Form data import not available');
327
+ }
328
+ /**
329
+ * Import FDF form data from in-memory bytes.
330
+ * @param data FDF data bytes
331
+ * @returns Number of fields imported
332
+ */
333
+ importFdfBytes(data) {
334
+ if (this.native?.pdf_editor_import_fdf_bytes) {
335
+ const errorCode = { value: 0 };
336
+ const count = this.native.pdf_editor_import_fdf_bytes(this.document?.handle ?? this.document, data, data.length, errorCode);
337
+ if (errorCode.value !== 0) {
338
+ throw mapFfiErrorCode(errorCode.value, 'Failed to import FDF bytes');
339
+ }
340
+ return count;
341
+ }
342
+ throw new Error('FDF byte import not available');
343
+ }
344
+ /**
345
+ * Import XFDF form data from in-memory bytes.
346
+ * @param data XFDF data bytes
347
+ * @returns Number of fields imported
348
+ */
349
+ importXfdfBytes(data) {
350
+ if (this.native?.pdf_editor_import_xfdf_bytes) {
351
+ const errorCode = { value: 0 };
352
+ const count = this.native.pdf_editor_import_xfdf_bytes(this.document?.handle ?? this.document, data, data.length, errorCode);
353
+ if (errorCode.value !== 0) {
354
+ throw mapFfiErrorCode(errorCode.value, 'Failed to import XFDF bytes');
355
+ }
356
+ return count;
357
+ }
358
+ throw new Error('XFDF byte import not available');
359
+ }
360
+ /**
361
+ * Export form data to in-memory bytes.
362
+ * @param format 0 for FDF, 1 for XFDF
363
+ * @returns Exported form data bytes
364
+ */
365
+ exportFormDataToBytes(format = 0) {
366
+ if (this.native?.pdf_document_export_form_data_to_bytes) {
367
+ const errorCode = { value: 0 };
368
+ const outLen = { value: 0 };
369
+ const ptr = this.native.pdf_document_export_form_data_to_bytes(this.document?.handle ?? this.document, format, outLen, errorCode);
370
+ if (errorCode.value !== 0 || !ptr) {
371
+ throw mapFfiErrorCode(errorCode.value, 'Failed to export form data');
372
+ }
373
+ return Buffer.from(ptr, 0, outLen.value);
374
+ }
375
+ throw new Error('Form data export not available');
376
+ }
377
+ // ===========================================================================
378
+ // Lifecycle
379
+ // ===========================================================================
380
+ /**
381
+ * Releases resources held by this manager.
382
+ */
383
+ destroy() {
384
+ this.removeAllListeners();
385
+ }
386
+ }
387
+ export default EditingManager;
@@ -0,0 +1,192 @@
1
+ /**
2
+ * EnterpriseManager - Enterprise PDF Operations
3
+ *
4
+ * Provides enterprise-level PDF operations including:
5
+ * - Bates numbering (standard and advanced)
6
+ * - Page-level and document-level comparison
7
+ * - Header and footer stamping
8
+ *
9
+ * @since 1.0.0
10
+ */
11
+ import { EventEmitter } from 'events';
12
+ /**
13
+ * Position for Bates number placement.
14
+ */
15
+ export declare enum BatesPosition {
16
+ TOP_LEFT = 0,
17
+ TOP_CENTER = 1,
18
+ TOP_RIGHT = 2,
19
+ BOTTOM_LEFT = 3,
20
+ BOTTOM_CENTER = 4,
21
+ BOTTOM_RIGHT = 5
22
+ }
23
+ /**
24
+ * Text alignment for header/footer stamps.
25
+ */
26
+ export declare enum StampAlignment {
27
+ LEFT = 0,
28
+ CENTER = 1,
29
+ RIGHT = 2
30
+ }
31
+ /**
32
+ * Types of differences found in page comparison.
33
+ */
34
+ export declare enum DifferenceType {
35
+ TEXT_ADDED = 0,
36
+ TEXT_REMOVED = 1,
37
+ TEXT_CHANGED = 2,
38
+ IMAGE_ADDED = 3,
39
+ IMAGE_REMOVED = 4,
40
+ IMAGE_CHANGED = 5,
41
+ LAYOUT_CHANGED = 6,
42
+ ANNOTATION_CHANGED = 7
43
+ }
44
+ /**
45
+ * A single difference found between two pages.
46
+ */
47
+ export interface Difference {
48
+ /** Type of difference */
49
+ readonly type: DifferenceType;
50
+ /** Description of the difference */
51
+ readonly description: string;
52
+ /** Page region where the difference was found (x, y, width, height) */
53
+ readonly bounds?: {
54
+ x: number;
55
+ y: number;
56
+ width: number;
57
+ height: number;
58
+ };
59
+ }
60
+ /**
61
+ * Result of comparing two pages.
62
+ */
63
+ export interface PageComparisonResult {
64
+ /** Similarity score (0.0 - 1.0, where 1.0 means identical) */
65
+ readonly similarity: number;
66
+ /** Number of differences found */
67
+ readonly diffCount: number;
68
+ /** List of differences */
69
+ readonly differences: readonly Difference[];
70
+ }
71
+ /**
72
+ * Result of comparing two documents.
73
+ */
74
+ export interface DocumentComparisonResult {
75
+ /** Overall similarity score (0.0 - 1.0) */
76
+ readonly similarity: number;
77
+ /** Per-page comparison results */
78
+ readonly pageResults: readonly PageComparisonResult[];
79
+ /** Number of pages in document A */
80
+ readonly pagesA: number;
81
+ /** Number of pages in document B */
82
+ readonly pagesB: number;
83
+ /** Total differences found across all pages */
84
+ readonly totalDifferences: number;
85
+ }
86
+ /**
87
+ * Manager for enterprise PDF operations.
88
+ *
89
+ * Provides methods for Bates numbering, document comparison,
90
+ * and header/footer stamping.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const enterprise = new EnterpriseManager(document);
95
+ *
96
+ * // Apply Bates numbering
97
+ * await enterprise.applyBates('DOC', 1, 6, BatesPosition.BOTTOM_RIGHT);
98
+ *
99
+ * // Compare pages
100
+ * const result = await enterprise.comparePages(docA, 0, docB, 0);
101
+ * console.log(`Pages are ${(result.similarity * 100).toFixed(1)}% similar`);
102
+ *
103
+ * // Stamp headers and footers
104
+ * await enterprise.stampHeader('CONFIDENTIAL', StampAlignment.CENTER, 12, 36);
105
+ * ```
106
+ */
107
+ export declare class EnterpriseManager extends EventEmitter {
108
+ private document;
109
+ private native;
110
+ constructor(document: any);
111
+ /**
112
+ * Applies Bates numbering to the document.
113
+ *
114
+ * @param prefix - Text prefix before the number (e.g., 'DOC')
115
+ * @param startNumber - Starting number
116
+ * @param numDigits - Number of digits (zero-padded)
117
+ * @param position - Position on the page
118
+ * @throws PdfException if the operation fails
119
+ */
120
+ applyBates(prefix: string, startNumber: number, numDigits: number, position: BatesPosition): Promise<void>;
121
+ /**
122
+ * Applies advanced Bates numbering with full configuration.
123
+ *
124
+ * @param prefix - Text prefix before the number
125
+ * @param suffix - Text suffix after the number
126
+ * @param startNumber - Starting number
127
+ * @param numDigits - Number of digits (zero-padded)
128
+ * @param position - Position on the page
129
+ * @param fontSize - Font size in points
130
+ * @param margin - Margin from page edge in points
131
+ * @param startPage - Starting page index (0-based)
132
+ * @param endPage - Ending page index (0-based, -1 for last page)
133
+ * @throws PdfException if the operation fails
134
+ */
135
+ applyBatesAdvanced(prefix: string, suffix: string, startNumber: number, numDigits: number, position: BatesPosition, fontSize: number, margin: number, startPage: number, endPage: number): Promise<void>;
136
+ /**
137
+ * Compares two pages from potentially different documents.
138
+ *
139
+ * @param docA - First document handle
140
+ * @param pageA - Page index in first document (0-based)
141
+ * @param docB - Second document handle
142
+ * @param pageB - Page index in second document (0-based)
143
+ * @returns Comparison result with similarity score and differences
144
+ * @throws PdfException if the comparison fails
145
+ */
146
+ comparePages(docA: any, pageA: number, docB: any, pageB: number): Promise<PageComparisonResult>;
147
+ /**
148
+ * Compares two entire documents page by page.
149
+ *
150
+ * @param docA - First document handle
151
+ * @param docB - Second document handle
152
+ * @returns Document-level comparison result
153
+ * @throws PdfException if the comparison fails
154
+ */
155
+ compareDocuments(docA: any, docB: any): Promise<DocumentComparisonResult>;
156
+ /**
157
+ * Stamps a header on all pages of the document.
158
+ *
159
+ * @param text - Header text (supports placeholders: {page}, {pages}, {date})
160
+ * @param align - Text alignment
161
+ * @param size - Font size in points
162
+ * @param margin - Top margin in points
163
+ * @throws PdfException if the operation fails
164
+ */
165
+ stampHeader(text: string, align: StampAlignment, size: number, margin: number): Promise<void>;
166
+ /**
167
+ * Stamps a footer on all pages of the document.
168
+ *
169
+ * @param text - Footer text (supports placeholders: {page}, {pages}, {date})
170
+ * @param align - Text alignment
171
+ * @param size - Font size in points
172
+ * @param margin - Bottom margin in points
173
+ * @throws PdfException if the operation fails
174
+ */
175
+ stampFooter(text: string, align: StampAlignment, size: number, margin: number): Promise<void>;
176
+ /**
177
+ * Stamps both header and footer on all pages of the document.
178
+ *
179
+ * @param headerText - Header text
180
+ * @param footerText - Footer text
181
+ * @param align - Text alignment for both
182
+ * @param size - Font size in points
183
+ * @param margin - Margin from page edge in points
184
+ * @throws PdfException if the operation fails
185
+ */
186
+ stampHeaderFooter(headerText: string, footerText: string, align: StampAlignment, size: number, margin: number): Promise<void>;
187
+ /**
188
+ * Releases resources held by this manager.
189
+ */
190
+ destroy(): void;
191
+ }
192
+ export default EnterpriseManager;