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.
- package/LICENSE-APACHE +176 -0
- package/LICENSE-MIT +25 -0
- package/README.md +218 -0
- package/lib/builders/annotation-builder.d.ts +198 -0
- package/lib/builders/annotation-builder.js +317 -0
- package/lib/builders/conversion-options-builder.d.ts +106 -0
- package/lib/builders/conversion-options-builder.js +214 -0
- package/lib/builders/document-builder.d.ts +381 -0
- package/lib/builders/document-builder.js +770 -0
- package/lib/builders/index.d.ts +13 -0
- package/lib/builders/index.js +13 -0
- package/lib/builders/metadata-builder.d.ts +201 -0
- package/lib/builders/metadata-builder.js +285 -0
- package/lib/builders/pdf-builder.d.ts +216 -0
- package/lib/builders/pdf-builder.js +350 -0
- package/lib/builders/search-options-builder.d.ts +73 -0
- package/lib/builders/search-options-builder.js +129 -0
- package/lib/builders/streaming-table.d.ts +64 -0
- package/lib/builders/streaming-table.js +140 -0
- package/lib/document-editor-manager.d.ts +139 -0
- package/lib/document-editor-manager.js +256 -0
- package/lib/document-editor.d.ts +124 -0
- package/lib/document-editor.js +318 -0
- package/lib/errors.d.ts +382 -0
- package/lib/errors.js +1115 -0
- package/lib/form-field-manager.d.ts +299 -0
- package/lib/form-field-manager.js +568 -0
- package/lib/hybrid-ml-manager.d.ts +142 -0
- package/lib/hybrid-ml-manager.js +208 -0
- package/lib/index.d.ts +205 -0
- package/lib/index.js +693 -0
- package/lib/managers/accessibility-manager.d.ts +148 -0
- package/lib/managers/accessibility-manager.js +234 -0
- package/lib/managers/annotation-manager.d.ts +219 -0
- package/lib/managers/annotation-manager.js +359 -0
- package/lib/managers/barcode-manager.d.ts +82 -0
- package/lib/managers/barcode-manager.js +263 -0
- package/lib/managers/batch-manager.d.ts +185 -0
- package/lib/managers/batch-manager.js +385 -0
- package/lib/managers/cache-manager.d.ts +181 -0
- package/lib/managers/cache-manager.js +384 -0
- package/lib/managers/compliance-manager.d.ts +103 -0
- package/lib/managers/compliance-manager.js +453 -0
- package/lib/managers/content-manager.d.ts +120 -0
- package/lib/managers/content-manager.js +294 -0
- package/lib/managers/document-utility-manager.d.ts +369 -0
- package/lib/managers/document-utility-manager.js +730 -0
- package/lib/managers/dom-pdf-creator.d.ts +104 -0
- package/lib/managers/dom-pdf-creator.js +299 -0
- package/lib/managers/editing-manager.d.ts +248 -0
- package/lib/managers/editing-manager.js +387 -0
- package/lib/managers/enterprise-manager.d.ts +192 -0
- package/lib/managers/enterprise-manager.js +307 -0
- package/lib/managers/extended-managers.d.ts +122 -0
- package/lib/managers/extended-managers.js +664 -0
- package/lib/managers/extraction-manager.d.ts +246 -0
- package/lib/managers/extraction-manager.js +482 -0
- package/lib/managers/final-utilities.d.ts +127 -0
- package/lib/managers/final-utilities.js +657 -0
- package/lib/managers/hybrid-ml-advanced.d.ts +136 -0
- package/lib/managers/hybrid-ml-advanced.js +722 -0
- package/lib/managers/index.d.ts +64 -0
- package/lib/managers/index.js +69 -0
- package/lib/managers/layer-manager.d.ts +203 -0
- package/lib/managers/layer-manager.js +401 -0
- package/lib/managers/metadata-manager.d.ts +148 -0
- package/lib/managers/metadata-manager.js +280 -0
- package/lib/managers/ocr-manager.d.ts +194 -0
- package/lib/managers/ocr-manager.js +582 -0
- package/lib/managers/optimization-manager.d.ts +102 -0
- package/lib/managers/optimization-manager.js +213 -0
- package/lib/managers/outline-manager.d.ts +101 -0
- package/lib/managers/outline-manager.js +169 -0
- package/lib/managers/page-manager.d.ts +142 -0
- package/lib/managers/page-manager.js +235 -0
- package/lib/managers/pattern-detection.d.ts +169 -0
- package/lib/managers/pattern-detection.js +322 -0
- package/lib/managers/rendering-manager.d.ts +353 -0
- package/lib/managers/rendering-manager.js +679 -0
- package/lib/managers/search-manager.d.ts +235 -0
- package/lib/managers/search-manager.js +329 -0
- package/lib/managers/security-manager.d.ts +161 -0
- package/lib/managers/security-manager.js +292 -0
- package/lib/managers/signature-manager.d.ts +738 -0
- package/lib/managers/signature-manager.js +1509 -0
- package/lib/managers/streams.d.ts +262 -0
- package/lib/managers/streams.js +477 -0
- package/lib/managers/xfa-manager.d.ts +227 -0
- package/lib/managers/xfa-manager.js +539 -0
- package/lib/native-loader.d.ts +7 -0
- package/lib/native-loader.js +62 -0
- package/lib/native.d.ts +16 -0
- package/lib/native.js +69 -0
- package/lib/pdf-creator-manager.d.ts +200 -0
- package/lib/pdf-creator-manager.js +381 -0
- package/lib/properties.d.ts +79 -0
- package/lib/properties.js +454 -0
- package/lib/result-accessors-manager.d.ts +346 -0
- package/lib/result-accessors-manager.js +706 -0
- package/lib/thumbnail-manager.d.ts +121 -0
- package/lib/thumbnail-manager.js +205 -0
- package/lib/timestamp.d.ts +54 -0
- package/lib/timestamp.js +115 -0
- package/lib/tsa-client.d.ts +44 -0
- package/lib/tsa-client.js +67 -0
- package/lib/types/common.d.ts +189 -0
- package/lib/types/common.js +17 -0
- package/lib/types/document-types.d.ts +352 -0
- package/lib/types/document-types.js +82 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.js +5 -0
- package/lib/types/manager-types.d.ts +179 -0
- package/lib/types/manager-types.js +100 -0
- package/lib/types/native-bindings.d.ts +439 -0
- package/lib/types/native-bindings.js +7 -0
- package/lib/workers/index.d.ts +6 -0
- package/lib/workers/index.js +5 -0
- package/lib/workers/pool.d.ts +64 -0
- package/lib/workers/pool.js +192 -0
- package/lib/workers/worker.d.ts +5 -0
- package/lib/workers/worker.js +99 -0
- package/package.json +79 -0
- package/prebuilds/darwin-arm64/pdf_oxide.node +0 -0
- package/prebuilds/darwin-x64/pdf_oxide.node +0 -0
- package/prebuilds/linux-arm64/pdf_oxide.node +0 -0
- package/prebuilds/linux-x64/pdf_oxide.node +0 -0
- package/prebuilds/win32-x64/pdf_oxide.node +0 -0
|
@@ -0,0 +1,307 @@
|
|
|
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
|
+
import { mapFfiErrorCode, PdfException } from '../errors.js';
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// Enums
|
|
15
|
+
// =============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Position for Bates number placement.
|
|
18
|
+
*/
|
|
19
|
+
export var BatesPosition;
|
|
20
|
+
(function (BatesPosition) {
|
|
21
|
+
BatesPosition[BatesPosition["TOP_LEFT"] = 0] = "TOP_LEFT";
|
|
22
|
+
BatesPosition[BatesPosition["TOP_CENTER"] = 1] = "TOP_CENTER";
|
|
23
|
+
BatesPosition[BatesPosition["TOP_RIGHT"] = 2] = "TOP_RIGHT";
|
|
24
|
+
BatesPosition[BatesPosition["BOTTOM_LEFT"] = 3] = "BOTTOM_LEFT";
|
|
25
|
+
BatesPosition[BatesPosition["BOTTOM_CENTER"] = 4] = "BOTTOM_CENTER";
|
|
26
|
+
BatesPosition[BatesPosition["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
|
|
27
|
+
})(BatesPosition || (BatesPosition = {}));
|
|
28
|
+
/**
|
|
29
|
+
* Text alignment for header/footer stamps.
|
|
30
|
+
*/
|
|
31
|
+
export var StampAlignment;
|
|
32
|
+
(function (StampAlignment) {
|
|
33
|
+
StampAlignment[StampAlignment["LEFT"] = 0] = "LEFT";
|
|
34
|
+
StampAlignment[StampAlignment["CENTER"] = 1] = "CENTER";
|
|
35
|
+
StampAlignment[StampAlignment["RIGHT"] = 2] = "RIGHT";
|
|
36
|
+
})(StampAlignment || (StampAlignment = {}));
|
|
37
|
+
/**
|
|
38
|
+
* Types of differences found in page comparison.
|
|
39
|
+
*/
|
|
40
|
+
export var DifferenceType;
|
|
41
|
+
(function (DifferenceType) {
|
|
42
|
+
DifferenceType[DifferenceType["TEXT_ADDED"] = 0] = "TEXT_ADDED";
|
|
43
|
+
DifferenceType[DifferenceType["TEXT_REMOVED"] = 1] = "TEXT_REMOVED";
|
|
44
|
+
DifferenceType[DifferenceType["TEXT_CHANGED"] = 2] = "TEXT_CHANGED";
|
|
45
|
+
DifferenceType[DifferenceType["IMAGE_ADDED"] = 3] = "IMAGE_ADDED";
|
|
46
|
+
DifferenceType[DifferenceType["IMAGE_REMOVED"] = 4] = "IMAGE_REMOVED";
|
|
47
|
+
DifferenceType[DifferenceType["IMAGE_CHANGED"] = 5] = "IMAGE_CHANGED";
|
|
48
|
+
DifferenceType[DifferenceType["LAYOUT_CHANGED"] = 6] = "LAYOUT_CHANGED";
|
|
49
|
+
DifferenceType[DifferenceType["ANNOTATION_CHANGED"] = 7] = "ANNOTATION_CHANGED";
|
|
50
|
+
})(DifferenceType || (DifferenceType = {}));
|
|
51
|
+
// =============================================================================
|
|
52
|
+
// EnterpriseManager
|
|
53
|
+
// =============================================================================
|
|
54
|
+
/**
|
|
55
|
+
* Manager for enterprise PDF operations.
|
|
56
|
+
*
|
|
57
|
+
* Provides methods for Bates numbering, document comparison,
|
|
58
|
+
* and header/footer stamping.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const enterprise = new EnterpriseManager(document);
|
|
63
|
+
*
|
|
64
|
+
* // Apply Bates numbering
|
|
65
|
+
* await enterprise.applyBates('DOC', 1, 6, BatesPosition.BOTTOM_RIGHT);
|
|
66
|
+
*
|
|
67
|
+
* // Compare pages
|
|
68
|
+
* const result = await enterprise.comparePages(docA, 0, docB, 0);
|
|
69
|
+
* console.log(`Pages are ${(result.similarity * 100).toFixed(1)}% similar`);
|
|
70
|
+
*
|
|
71
|
+
* // Stamp headers and footers
|
|
72
|
+
* await enterprise.stampHeader('CONFIDENTIAL', StampAlignment.CENTER, 12, 36);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export class EnterpriseManager extends EventEmitter {
|
|
76
|
+
constructor(document) {
|
|
77
|
+
super();
|
|
78
|
+
if (!document) {
|
|
79
|
+
throw new Error('Document cannot be null or undefined');
|
|
80
|
+
}
|
|
81
|
+
this.document = document;
|
|
82
|
+
try {
|
|
83
|
+
this.native = require('../../index.node');
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
this.native = null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// ===========================================================================
|
|
90
|
+
// Bates Numbering
|
|
91
|
+
// ===========================================================================
|
|
92
|
+
/**
|
|
93
|
+
* Applies Bates numbering to the document.
|
|
94
|
+
*
|
|
95
|
+
* @param prefix - Text prefix before the number (e.g., 'DOC')
|
|
96
|
+
* @param startNumber - Starting number
|
|
97
|
+
* @param numDigits - Number of digits (zero-padded)
|
|
98
|
+
* @param position - Position on the page
|
|
99
|
+
* @throws PdfException if the operation fails
|
|
100
|
+
*/
|
|
101
|
+
async applyBates(prefix, startNumber, numDigits, position) {
|
|
102
|
+
if (!this.native?.pdf_bates_apply) {
|
|
103
|
+
throw new PdfException('9900', 'Native enterprise not available: pdf_bates_apply not found');
|
|
104
|
+
}
|
|
105
|
+
const errorCode = Buffer.alloc(4);
|
|
106
|
+
this.native.pdf_bates_apply(this.document._handle ?? this.document, prefix, startNumber, numDigits, position, errorCode);
|
|
107
|
+
const code = errorCode.readInt32LE(0);
|
|
108
|
+
if (code !== 0) {
|
|
109
|
+
throw mapFfiErrorCode(code, 'Failed to apply Bates numbering');
|
|
110
|
+
}
|
|
111
|
+
this.emit('bates-applied', { prefix, startNumber, numDigits, position });
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Applies advanced Bates numbering with full configuration.
|
|
115
|
+
*
|
|
116
|
+
* @param prefix - Text prefix before the number
|
|
117
|
+
* @param suffix - Text suffix after the number
|
|
118
|
+
* @param startNumber - Starting number
|
|
119
|
+
* @param numDigits - Number of digits (zero-padded)
|
|
120
|
+
* @param position - Position on the page
|
|
121
|
+
* @param fontSize - Font size in points
|
|
122
|
+
* @param margin - Margin from page edge in points
|
|
123
|
+
* @param startPage - Starting page index (0-based)
|
|
124
|
+
* @param endPage - Ending page index (0-based, -1 for last page)
|
|
125
|
+
* @throws PdfException if the operation fails
|
|
126
|
+
*/
|
|
127
|
+
async applyBatesAdvanced(prefix, suffix, startNumber, numDigits, position, fontSize, margin, startPage, endPage) {
|
|
128
|
+
if (!this.native?.pdf_bates_apply_advanced) {
|
|
129
|
+
throw new PdfException('9900', 'Native enterprise not available: pdf_bates_apply_advanced not found');
|
|
130
|
+
}
|
|
131
|
+
const errorCode = Buffer.alloc(4);
|
|
132
|
+
this.native.pdf_bates_apply_advanced(this.document._handle ?? this.document, prefix, suffix, startNumber, numDigits, position, fontSize, margin, startPage, endPage, errorCode);
|
|
133
|
+
const code = errorCode.readInt32LE(0);
|
|
134
|
+
if (code !== 0) {
|
|
135
|
+
throw mapFfiErrorCode(code, 'Failed to apply advanced Bates numbering');
|
|
136
|
+
}
|
|
137
|
+
this.emit('bates-applied-advanced', { prefix, suffix, startNumber, numDigits, position });
|
|
138
|
+
}
|
|
139
|
+
// ===========================================================================
|
|
140
|
+
// Document Comparison
|
|
141
|
+
// ===========================================================================
|
|
142
|
+
/**
|
|
143
|
+
* Compares two pages from potentially different documents.
|
|
144
|
+
*
|
|
145
|
+
* @param docA - First document handle
|
|
146
|
+
* @param pageA - Page index in first document (0-based)
|
|
147
|
+
* @param docB - Second document handle
|
|
148
|
+
* @param pageB - Page index in second document (0-based)
|
|
149
|
+
* @returns Comparison result with similarity score and differences
|
|
150
|
+
* @throws PdfException if the comparison fails
|
|
151
|
+
*/
|
|
152
|
+
async comparePages(docA, pageA, docB, pageB) {
|
|
153
|
+
if (!this.native?.pdf_compare_pages) {
|
|
154
|
+
throw new PdfException('9900', 'Native enterprise not available: pdf_compare_pages not found');
|
|
155
|
+
}
|
|
156
|
+
const errorCode = Buffer.alloc(4);
|
|
157
|
+
const comparisonPtr = this.native.pdf_compare_pages(docA._handle ?? docA, pageA, docB._handle ?? docB, pageB, errorCode);
|
|
158
|
+
const code = errorCode.readInt32LE(0);
|
|
159
|
+
if (code !== 0) {
|
|
160
|
+
throw mapFfiErrorCode(code, 'Failed to compare pages');
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const similarity = this.native.pdf_comparison_get_similarity?.(comparisonPtr) ?? 0;
|
|
164
|
+
const diffCount = this.native.pdf_comparison_get_diff_count?.(comparisonPtr) ?? 0;
|
|
165
|
+
const differences = [];
|
|
166
|
+
for (let i = 0; i < diffCount; i++) {
|
|
167
|
+
const diffPtr = this.native.pdf_comparison_get_diff?.(comparisonPtr, i);
|
|
168
|
+
if (diffPtr) {
|
|
169
|
+
const diffType = this.native.pdf_comparison_get_diff_type?.(diffPtr) ?? 0;
|
|
170
|
+
differences.push({
|
|
171
|
+
type: diffType,
|
|
172
|
+
description: `Difference ${i + 1}`,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const result = { similarity, diffCount, differences };
|
|
177
|
+
this.emit('pages-compared', { pageA, pageB, similarity });
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
if (this.native.pdf_comparison_free) {
|
|
182
|
+
this.native.pdf_comparison_free(comparisonPtr);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Compares two entire documents page by page.
|
|
188
|
+
*
|
|
189
|
+
* @param docA - First document handle
|
|
190
|
+
* @param docB - Second document handle
|
|
191
|
+
* @returns Document-level comparison result
|
|
192
|
+
* @throws PdfException if the comparison fails
|
|
193
|
+
*/
|
|
194
|
+
async compareDocuments(docA, docB) {
|
|
195
|
+
if (!this.native?.pdf_compare_documents) {
|
|
196
|
+
throw new PdfException('9900', 'Native enterprise not available: pdf_compare_documents not found');
|
|
197
|
+
}
|
|
198
|
+
const errorCode = Buffer.alloc(4);
|
|
199
|
+
const resultPtr = this.native.pdf_compare_documents(docA._handle ?? docA, docB._handle ?? docB, errorCode);
|
|
200
|
+
const code = errorCode.readInt32LE(0);
|
|
201
|
+
if (code !== 0) {
|
|
202
|
+
throw mapFfiErrorCode(code, 'Failed to compare documents');
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
let result;
|
|
206
|
+
if (typeof resultPtr === 'string') {
|
|
207
|
+
result = JSON.parse(resultPtr);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
result = resultPtr ?? {
|
|
211
|
+
similarity: 0,
|
|
212
|
+
pageResults: [],
|
|
213
|
+
pagesA: 0,
|
|
214
|
+
pagesB: 0,
|
|
215
|
+
totalDifferences: 0,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
this.emit('documents-compared', {
|
|
219
|
+
similarity: result.similarity,
|
|
220
|
+
totalDifferences: result.totalDifferences,
|
|
221
|
+
});
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
if (this.native.pdf_document_comparison_free && typeof resultPtr !== 'string') {
|
|
226
|
+
this.native.pdf_document_comparison_free(resultPtr);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// ===========================================================================
|
|
231
|
+
// Header / Footer Stamping
|
|
232
|
+
// ===========================================================================
|
|
233
|
+
/**
|
|
234
|
+
* Stamps a header on all pages of the document.
|
|
235
|
+
*
|
|
236
|
+
* @param text - Header text (supports placeholders: {page}, {pages}, {date})
|
|
237
|
+
* @param align - Text alignment
|
|
238
|
+
* @param size - Font size in points
|
|
239
|
+
* @param margin - Top margin in points
|
|
240
|
+
* @throws PdfException if the operation fails
|
|
241
|
+
*/
|
|
242
|
+
async stampHeader(text, align, size, margin) {
|
|
243
|
+
if (!this.native?.pdf_stamp_header) {
|
|
244
|
+
throw new PdfException('9900', 'Native enterprise not available: pdf_stamp_header not found');
|
|
245
|
+
}
|
|
246
|
+
const errorCode = Buffer.alloc(4);
|
|
247
|
+
this.native.pdf_stamp_header(this.document._handle ?? this.document, text, align, size, margin, errorCode);
|
|
248
|
+
const code = errorCode.readInt32LE(0);
|
|
249
|
+
if (code !== 0) {
|
|
250
|
+
throw mapFfiErrorCode(code, 'Failed to stamp header');
|
|
251
|
+
}
|
|
252
|
+
this.emit('header-stamped', { text, align, size, margin });
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Stamps a footer on all pages of the document.
|
|
256
|
+
*
|
|
257
|
+
* @param text - Footer text (supports placeholders: {page}, {pages}, {date})
|
|
258
|
+
* @param align - Text alignment
|
|
259
|
+
* @param size - Font size in points
|
|
260
|
+
* @param margin - Bottom margin in points
|
|
261
|
+
* @throws PdfException if the operation fails
|
|
262
|
+
*/
|
|
263
|
+
async stampFooter(text, align, size, margin) {
|
|
264
|
+
if (!this.native?.pdf_stamp_footer) {
|
|
265
|
+
throw new PdfException('9900', 'Native enterprise not available: pdf_stamp_footer not found');
|
|
266
|
+
}
|
|
267
|
+
const errorCode = Buffer.alloc(4);
|
|
268
|
+
this.native.pdf_stamp_footer(this.document._handle ?? this.document, text, align, size, margin, errorCode);
|
|
269
|
+
const code = errorCode.readInt32LE(0);
|
|
270
|
+
if (code !== 0) {
|
|
271
|
+
throw mapFfiErrorCode(code, 'Failed to stamp footer');
|
|
272
|
+
}
|
|
273
|
+
this.emit('footer-stamped', { text, align, size, margin });
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Stamps both header and footer on all pages of the document.
|
|
277
|
+
*
|
|
278
|
+
* @param headerText - Header text
|
|
279
|
+
* @param footerText - Footer text
|
|
280
|
+
* @param align - Text alignment for both
|
|
281
|
+
* @param size - Font size in points
|
|
282
|
+
* @param margin - Margin from page edge in points
|
|
283
|
+
* @throws PdfException if the operation fails
|
|
284
|
+
*/
|
|
285
|
+
async stampHeaderFooter(headerText, footerText, align, size, margin) {
|
|
286
|
+
if (!this.native?.pdf_stamp_header_footer) {
|
|
287
|
+
throw new PdfException('9900', 'Native enterprise not available: pdf_stamp_header_footer not found');
|
|
288
|
+
}
|
|
289
|
+
const errorCode = Buffer.alloc(4);
|
|
290
|
+
this.native.pdf_stamp_header_footer(this.document._handle ?? this.document, headerText, footerText, align, size, margin, errorCode);
|
|
291
|
+
const code = errorCode.readInt32LE(0);
|
|
292
|
+
if (code !== 0) {
|
|
293
|
+
throw mapFfiErrorCode(code, 'Failed to stamp header and footer');
|
|
294
|
+
}
|
|
295
|
+
this.emit('header-footer-stamped', { headerText, footerText, align, size, margin });
|
|
296
|
+
}
|
|
297
|
+
// ===========================================================================
|
|
298
|
+
// Cleanup
|
|
299
|
+
// ===========================================================================
|
|
300
|
+
/**
|
|
301
|
+
* Releases resources held by this manager.
|
|
302
|
+
*/
|
|
303
|
+
destroy() {
|
|
304
|
+
this.removeAllListeners();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
export default EnterpriseManager;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
/**
|
|
3
|
+
* Phase 6: Extended Managers and Utilities
|
|
4
|
+
* - Document Extensions (25) + Performance (15) + Batch Processing (12) + Utilities (18) = 70 Functions
|
|
5
|
+
*/
|
|
6
|
+
export interface DocumentMetadata {
|
|
7
|
+
title?: string;
|
|
8
|
+
author?: string;
|
|
9
|
+
subject?: string;
|
|
10
|
+
keywords?: string;
|
|
11
|
+
creator?: string;
|
|
12
|
+
producer?: string;
|
|
13
|
+
creationDate?: string;
|
|
14
|
+
modificationDate?: string;
|
|
15
|
+
pages: number;
|
|
16
|
+
encrypted: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface PerformanceMetrics {
|
|
19
|
+
operation: string;
|
|
20
|
+
durationMs: number;
|
|
21
|
+
memoryUsedKb: number;
|
|
22
|
+
itemsProcessed: number;
|
|
23
|
+
throughputPerSec: number;
|
|
24
|
+
}
|
|
25
|
+
export interface BatchJob {
|
|
26
|
+
jobId: string;
|
|
27
|
+
filePath: string;
|
|
28
|
+
operation: string;
|
|
29
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
|
|
30
|
+
progress: number;
|
|
31
|
+
errorMessage?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ExtractionResult {
|
|
34
|
+
success: boolean;
|
|
35
|
+
data?: string;
|
|
36
|
+
format: 'text' | 'json' | 'xml' | 'csv';
|
|
37
|
+
byteSize: number;
|
|
38
|
+
extractionTimeMs: number;
|
|
39
|
+
}
|
|
40
|
+
export declare class DocumentExtendedManager extends EventEmitter {
|
|
41
|
+
private document;
|
|
42
|
+
private metadataCache;
|
|
43
|
+
constructor(document: any);
|
|
44
|
+
getDocumentTitle(): Promise<string | null>;
|
|
45
|
+
setDocumentTitle(title: string): Promise<boolean>;
|
|
46
|
+
getDocumentAuthor(): Promise<string | null>;
|
|
47
|
+
setDocumentAuthor(author: string): Promise<boolean>;
|
|
48
|
+
getDocumentSubject(): Promise<string | null>;
|
|
49
|
+
setDocumentSubject(subject: string): Promise<boolean>;
|
|
50
|
+
getDocumentKeywords(): Promise<string | null>;
|
|
51
|
+
setDocumentKeywords(keywords: string): Promise<boolean>;
|
|
52
|
+
getDocumentCreator(): Promise<string | null>;
|
|
53
|
+
getDocumentProducer(): Promise<string | null>;
|
|
54
|
+
getDocumentCreationDate(): Promise<string | null>;
|
|
55
|
+
getDocumentModificationDate(): Promise<string | null>;
|
|
56
|
+
isDocumentEncrypted(): Promise<boolean>;
|
|
57
|
+
getEncryptionLevel(): Promise<string | null>;
|
|
58
|
+
isDocumentUserProtected(): Promise<boolean>;
|
|
59
|
+
isDocumentOwnerProtected(): Promise<boolean>;
|
|
60
|
+
getDocumentSize(): Promise<number>;
|
|
61
|
+
getPageMediaBox(pageIndex: number): Promise<[number, number, number, number] | null>;
|
|
62
|
+
getPageCropBox(pageIndex: number): Promise<[number, number, number, number] | null>;
|
|
63
|
+
getPageRotation(pageIndex: number): Promise<number>;
|
|
64
|
+
setPageRotation(pageIndex: number, rotation: number): Promise<boolean>;
|
|
65
|
+
getPageCount(): Promise<number>;
|
|
66
|
+
getDocumentMetadata(): Promise<DocumentMetadata | null>;
|
|
67
|
+
}
|
|
68
|
+
export declare class PerformanceManager extends EventEmitter {
|
|
69
|
+
private document;
|
|
70
|
+
private metrics;
|
|
71
|
+
constructor(document: any);
|
|
72
|
+
startTimer(operationName: string): Promise<string>;
|
|
73
|
+
stopTimer(timerId: string): Promise<PerformanceMetrics | null>;
|
|
74
|
+
getOperationTime(operation: string): Promise<number | null>;
|
|
75
|
+
getMemoryUsage(): Promise<number>;
|
|
76
|
+
enableCaching(): Promise<boolean>;
|
|
77
|
+
disableCaching(): Promise<boolean>;
|
|
78
|
+
clearCache(): Promise<boolean>;
|
|
79
|
+
getCacheSize(): Promise<number>;
|
|
80
|
+
setCacheLimit(limitMb: number): Promise<boolean>;
|
|
81
|
+
getMetrics(): Promise<PerformanceMetrics[]>;
|
|
82
|
+
resetMetrics(): Promise<boolean>;
|
|
83
|
+
optimizeDocument(): Promise<boolean>;
|
|
84
|
+
getOptimizationReport(): Promise<Record<string, any> | null>;
|
|
85
|
+
enableLogging(level: string): Promise<boolean>;
|
|
86
|
+
disableLogging(): Promise<boolean>;
|
|
87
|
+
}
|
|
88
|
+
export declare class BatchProcessingManager extends EventEmitter {
|
|
89
|
+
private jobs;
|
|
90
|
+
constructor();
|
|
91
|
+
createBatchJob(jobId: string, filePath: string, operation: string): Promise<BatchJob | null>;
|
|
92
|
+
submitBatchJob(jobId: string): Promise<boolean>;
|
|
93
|
+
getBatchJobStatus(jobId: string): Promise<string | null>;
|
|
94
|
+
getBatchJobProgress(jobId: string): Promise<number>;
|
|
95
|
+
cancelBatchJob(jobId: string): Promise<boolean>;
|
|
96
|
+
waitForBatchJob(jobId: string, timeoutSec?: number): Promise<boolean>;
|
|
97
|
+
getBatchJobResult(jobId: string): Promise<string | null>;
|
|
98
|
+
listBatchJobs(status?: string): Promise<BatchJob[]>;
|
|
99
|
+
clearBatchJobs(completedOnly?: boolean): Promise<number>;
|
|
100
|
+
processBatch(files: string[], operation: string): Promise<string[]>;
|
|
101
|
+
getBatchResults(jobIds: string[]): Promise<Record<string, string | null>>;
|
|
102
|
+
}
|
|
103
|
+
export declare class UtilitiesManager extends EventEmitter {
|
|
104
|
+
private document;
|
|
105
|
+
constructor(document: any);
|
|
106
|
+
extractToText(outputFile: string): Promise<ExtractionResult | null>;
|
|
107
|
+
extractToJSON(outputFile: string): Promise<ExtractionResult | null>;
|
|
108
|
+
extractToXML(outputFile: string): Promise<ExtractionResult | null>;
|
|
109
|
+
validateDocument(): Promise<boolean>;
|
|
110
|
+
repairDocument(): Promise<boolean>;
|
|
111
|
+
mergePDFs(outputFile: string, otherFiles: string[]): Promise<boolean>;
|
|
112
|
+
splitPDF(outputDir: string, pagesPerFile: number): Promise<number>;
|
|
113
|
+
rotatePDF(rotationDegrees: number, outputFile: string): Promise<boolean>;
|
|
114
|
+
scalePDF(scaleFactor: number, outputFile: string): Promise<boolean>;
|
|
115
|
+
addWatermark(text: string, opacity?: number, rotation?: number): Promise<boolean>;
|
|
116
|
+
addPageNumbers(formatStr?: string, startPage?: number): Promise<boolean>;
|
|
117
|
+
removePages(pageIndices: number[]): Promise<boolean>;
|
|
118
|
+
reorderPages(newOrder: number[]): Promise<boolean>;
|
|
119
|
+
duplicatePages(pageIndex: number, count: number): Promise<boolean>;
|
|
120
|
+
blankPages(pageIndices: number[]): Promise<boolean>;
|
|
121
|
+
getDocumentStatistics(): Promise<Record<string, any> | null>;
|
|
122
|
+
}
|