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,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder for text search options
|
|
3
|
+
*
|
|
4
|
+
* Configures how text search is performed in PDF documents,
|
|
5
|
+
* including case sensitivity, whole word matching, and regex support.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { SearchOptionsBuilder } from 'pdf_oxide';
|
|
10
|
+
*
|
|
11
|
+
* const options = SearchOptionsBuilder.create()
|
|
12
|
+
* .caseSensitive(false)
|
|
13
|
+
* .wholeWords(true)
|
|
14
|
+
* .useRegex(false)
|
|
15
|
+
* .build();
|
|
16
|
+
*
|
|
17
|
+
* const results = doc.search('pattern', 0, options);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class SearchOptionsBuilder {
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new SearchOptionsBuilder instance
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
constructor() {
|
|
26
|
+
this._caseSensitive = false;
|
|
27
|
+
this._wholeWords = false;
|
|
28
|
+
this._useRegex = false;
|
|
29
|
+
this._ignoreAccents = false;
|
|
30
|
+
this._maxResults = 1000;
|
|
31
|
+
this._searchAnnotations = false;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new SearchOptionsBuilder instance
|
|
35
|
+
* @returns New builder instance
|
|
36
|
+
*/
|
|
37
|
+
static create() {
|
|
38
|
+
return new SearchOptionsBuilder();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates options with default search settings (case-insensitive, no regex)
|
|
42
|
+
* @returns Search options with default preset
|
|
43
|
+
*/
|
|
44
|
+
static default() {
|
|
45
|
+
return SearchOptionsBuilder.create().build();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates options with strict search settings (case-sensitive, whole words, no regex)
|
|
49
|
+
* @returns Search options with strict preset
|
|
50
|
+
*/
|
|
51
|
+
static strict() {
|
|
52
|
+
return SearchOptionsBuilder.create()
|
|
53
|
+
.caseSensitive(true)
|
|
54
|
+
.wholeWords(true)
|
|
55
|
+
.useRegex(false)
|
|
56
|
+
.build();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates options with regex search settings
|
|
60
|
+
* @returns Search options with regex preset
|
|
61
|
+
*/
|
|
62
|
+
static regex() {
|
|
63
|
+
return SearchOptionsBuilder.create()
|
|
64
|
+
.useRegex(true)
|
|
65
|
+
.caseSensitive(false)
|
|
66
|
+
.wholeWords(false)
|
|
67
|
+
.build();
|
|
68
|
+
}
|
|
69
|
+
caseSensitive(sensitive) {
|
|
70
|
+
if (typeof sensitive !== 'boolean') {
|
|
71
|
+
throw new Error('caseSensitive must be a boolean');
|
|
72
|
+
}
|
|
73
|
+
this._caseSensitive = sensitive;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
wholeWords(wholeOnly) {
|
|
77
|
+
if (typeof wholeOnly !== 'boolean') {
|
|
78
|
+
throw new Error('wholeWords must be a boolean');
|
|
79
|
+
}
|
|
80
|
+
this._wholeWords = wholeOnly;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
useRegex(regex) {
|
|
84
|
+
if (typeof regex !== 'boolean') {
|
|
85
|
+
throw new Error('useRegex must be a boolean');
|
|
86
|
+
}
|
|
87
|
+
this._useRegex = regex;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
ignoreAccents(ignore) {
|
|
91
|
+
if (typeof ignore !== 'boolean') {
|
|
92
|
+
throw new Error('ignoreAccents must be a boolean');
|
|
93
|
+
}
|
|
94
|
+
this._ignoreAccents = ignore;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
maxResults(max) {
|
|
98
|
+
if (typeof max !== 'number' || max <= 0) {
|
|
99
|
+
throw new Error('maxResults must be a positive number');
|
|
100
|
+
}
|
|
101
|
+
this._maxResults = Math.floor(max);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
searchAnnotations(search) {
|
|
105
|
+
if (typeof search !== 'boolean') {
|
|
106
|
+
throw new Error('searchAnnotations must be a boolean');
|
|
107
|
+
}
|
|
108
|
+
this._searchAnnotations = search;
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
build() {
|
|
112
|
+
return {
|
|
113
|
+
caseSensitive: this._caseSensitive,
|
|
114
|
+
wholeWords: this._wholeWords,
|
|
115
|
+
useRegex: this._useRegex,
|
|
116
|
+
ignoreAccents: this._ignoreAccents,
|
|
117
|
+
maxResults: this._maxResults,
|
|
118
|
+
searchAnnotations: this._searchAnnotations,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a new SearchOptionsBuilder with static factory
|
|
124
|
+
* @deprecated Use SearchOptionsBuilder.create() instead
|
|
125
|
+
* @returns New builder instance
|
|
126
|
+
*/
|
|
127
|
+
export function createSearchOptionsBuilder() {
|
|
128
|
+
return SearchOptionsBuilder.create();
|
|
129
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming-table adapter backed by the native row-at-a-time FFI
|
|
3
|
+
* (`pdf_page_builder_streaming_table_begin_v2` / `_push_row` / `_finish`).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const t = page.streamingTable({
|
|
8
|
+
* columns: [
|
|
9
|
+
* { header: 'SKU', width: 72 },
|
|
10
|
+
* { header: 'Item', width: 200 },
|
|
11
|
+
* { header: 'Qty', width: 48, align: Align.Right },
|
|
12
|
+
* ],
|
|
13
|
+
* repeatHeader: true,
|
|
14
|
+
* mode: { kind: 'sample', sampleRows: 30 },
|
|
15
|
+
* });
|
|
16
|
+
* for await (const row of readRowsFromDb()) {
|
|
17
|
+
* t.pushRow([row.sku, row.item, String(row.qty)]);
|
|
18
|
+
* }
|
|
19
|
+
* await t.finish();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { SpanCell, StreamingTableConfig } from '../types/common.js';
|
|
23
|
+
import type { PageBuilder } from './document-builder.js';
|
|
24
|
+
export declare class StreamingTable {
|
|
25
|
+
private _page;
|
|
26
|
+
private _columns;
|
|
27
|
+
private _opened;
|
|
28
|
+
private _finished;
|
|
29
|
+
private _rowCount;
|
|
30
|
+
/** @internal — constructed via `PageBuilder.streamingTable(...)`. */
|
|
31
|
+
constructor(page: PageBuilder, config: StreamingTableConfig);
|
|
32
|
+
/**
|
|
33
|
+
* Number of rows pushed since the last batch boundary.
|
|
34
|
+
* Backed by the Rust FFI layer.
|
|
35
|
+
*/
|
|
36
|
+
get pendingRowCount(): number;
|
|
37
|
+
/** Number of complete batches recorded by the native layer so far. */
|
|
38
|
+
get batchCount(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Explicitly mark a batch boundary in the native layer.
|
|
41
|
+
* Also triggered automatically when the configured batch size is reached.
|
|
42
|
+
*/
|
|
43
|
+
flush(): this;
|
|
44
|
+
/** Total rows pushed so far (monotonically increasing). */
|
|
45
|
+
get rowCount(): number;
|
|
46
|
+
/** Push a single row (all rowspan=1). Throws if `cells.length !== columns.length`. */
|
|
47
|
+
pushRow(cells: Array<string | null | undefined>): this;
|
|
48
|
+
/**
|
|
49
|
+
* Push a single row with per-cell rowspan values. Each element is either
|
|
50
|
+
* a `SpanCell` (`{ text, rowspan }`) or a plain string (rowspan=1).
|
|
51
|
+
* Requires `maxRowspan ≥ 2` in the `StreamingTableConfig`.
|
|
52
|
+
*/
|
|
53
|
+
pushRowSpan(cells: Array<SpanCell | string | null | undefined>): this;
|
|
54
|
+
/**
|
|
55
|
+
* Convenience: consume a sync or async iterable and push each row.
|
|
56
|
+
*/
|
|
57
|
+
pushAll(rows: Iterable<Array<string | null | undefined>> | AsyncIterable<Array<string | null | undefined>>): Promise<this>;
|
|
58
|
+
/**
|
|
59
|
+
* Close the streaming table and return the parent PageBuilder for chaining.
|
|
60
|
+
*/
|
|
61
|
+
finish(): Promise<PageBuilder>;
|
|
62
|
+
/** Number of the columns this table was opened with. */
|
|
63
|
+
get columnCount(): number;
|
|
64
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming-table adapter backed by the native row-at-a-time FFI
|
|
3
|
+
* (`pdf_page_builder_streaming_table_begin_v2` / `_push_row` / `_finish`).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const t = page.streamingTable({
|
|
8
|
+
* columns: [
|
|
9
|
+
* { header: 'SKU', width: 72 },
|
|
10
|
+
* { header: 'Item', width: 200 },
|
|
11
|
+
* { header: 'Qty', width: 48, align: Align.Right },
|
|
12
|
+
* ],
|
|
13
|
+
* repeatHeader: true,
|
|
14
|
+
* mode: { kind: 'sample', sampleRows: 30 },
|
|
15
|
+
* });
|
|
16
|
+
* for await (const row of readRowsFromDb()) {
|
|
17
|
+
* t.pushRow([row.sku, row.item, String(row.qty)]);
|
|
18
|
+
* }
|
|
19
|
+
* await t.finish();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class StreamingTable {
|
|
23
|
+
/** @internal — constructed via `PageBuilder.streamingTable(...)`. */
|
|
24
|
+
constructor(page, config) {
|
|
25
|
+
this._opened = false;
|
|
26
|
+
this._finished = false;
|
|
27
|
+
this._rowCount = 0;
|
|
28
|
+
if (!config || !Array.isArray(config.columns) || config.columns.length === 0) {
|
|
29
|
+
throw new Error('StreamingTable requires at least one column');
|
|
30
|
+
}
|
|
31
|
+
this._page = page;
|
|
32
|
+
this._columns = config.columns;
|
|
33
|
+
const headers = config.columns.map((c) => c.header ?? '');
|
|
34
|
+
const widths = config.columns.map((c) => c.width);
|
|
35
|
+
const aligns = config.columns.map((c) => (c.align ?? 0));
|
|
36
|
+
const repeat = config.repeatHeader !== false;
|
|
37
|
+
const maxRowspan = config.maxRowspan != null && config.maxRowspan >= 2 ? config.maxRowspan : 1;
|
|
38
|
+
this._page._streamingTableBeginV2(headers, widths, aligns, repeat, config.mode, maxRowspan);
|
|
39
|
+
this._opened = true;
|
|
40
|
+
const batchSize = config.batchSize != null && config.batchSize > 0 ? config.batchSize : 256;
|
|
41
|
+
this._page._streamingTableSetBatchSize(batchSize);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Number of rows pushed since the last batch boundary.
|
|
45
|
+
* Backed by the Rust FFI layer.
|
|
46
|
+
*/
|
|
47
|
+
get pendingRowCount() {
|
|
48
|
+
return this._page._streamingTablePendingRowCount();
|
|
49
|
+
}
|
|
50
|
+
/** Number of complete batches recorded by the native layer so far. */
|
|
51
|
+
get batchCount() {
|
|
52
|
+
return this._page._streamingTableBatchCount();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Explicitly mark a batch boundary in the native layer.
|
|
56
|
+
* Also triggered automatically when the configured batch size is reached.
|
|
57
|
+
*/
|
|
58
|
+
flush() {
|
|
59
|
+
if (this._finished)
|
|
60
|
+
throw new Error('StreamingTable already finished');
|
|
61
|
+
this._page._streamingTableFlush();
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/** Total rows pushed so far (monotonically increasing). */
|
|
65
|
+
get rowCount() {
|
|
66
|
+
return this._rowCount;
|
|
67
|
+
}
|
|
68
|
+
/** Push a single row (all rowspan=1). Throws if `cells.length !== columns.length`. */
|
|
69
|
+
pushRow(cells) {
|
|
70
|
+
if (this._finished) {
|
|
71
|
+
throw new Error('StreamingTable already finished');
|
|
72
|
+
}
|
|
73
|
+
if (cells.length !== this._columns.length) {
|
|
74
|
+
throw new Error(`row width ${cells.length} does not match column count ${this._columns.length}`);
|
|
75
|
+
}
|
|
76
|
+
this._page._streamingTablePushRow(cells.map((c) => (c == null ? null : String(c))));
|
|
77
|
+
this._rowCount++;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Push a single row with per-cell rowspan values. Each element is either
|
|
82
|
+
* a `SpanCell` (`{ text, rowspan }`) or a plain string (rowspan=1).
|
|
83
|
+
* Requires `maxRowspan ≥ 2` in the `StreamingTableConfig`.
|
|
84
|
+
*/
|
|
85
|
+
pushRowSpan(cells) {
|
|
86
|
+
if (this._finished) {
|
|
87
|
+
throw new Error('StreamingTable already finished');
|
|
88
|
+
}
|
|
89
|
+
if (cells.length !== this._columns.length) {
|
|
90
|
+
throw new Error(`row width ${cells.length} does not match column count ${this._columns.length}`);
|
|
91
|
+
}
|
|
92
|
+
const normalized = cells.map((c) => {
|
|
93
|
+
if (c == null)
|
|
94
|
+
return [null, 1];
|
|
95
|
+
if (typeof c === 'string')
|
|
96
|
+
return [c, 1];
|
|
97
|
+
return [c.text, c.rowspan];
|
|
98
|
+
});
|
|
99
|
+
this._page._streamingTablePushRowV2(normalized);
|
|
100
|
+
this._rowCount++;
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Convenience: consume a sync or async iterable and push each row.
|
|
105
|
+
*/
|
|
106
|
+
async pushAll(rows) {
|
|
107
|
+
if (this._finished) {
|
|
108
|
+
throw new Error('StreamingTable already finished');
|
|
109
|
+
}
|
|
110
|
+
const anyRows = rows;
|
|
111
|
+
if (typeof anyRows[Symbol.asyncIterator] === 'function') {
|
|
112
|
+
for await (const row of rows) {
|
|
113
|
+
this.pushRow(row);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
for (const row of rows) {
|
|
118
|
+
this.pushRow(row);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Close the streaming table and return the parent PageBuilder for chaining.
|
|
125
|
+
*/
|
|
126
|
+
async finish() {
|
|
127
|
+
if (this._finished) {
|
|
128
|
+
throw new Error('StreamingTable already finished');
|
|
129
|
+
}
|
|
130
|
+
this._finished = true;
|
|
131
|
+
if (this._opened) {
|
|
132
|
+
this._page._streamingTableFinish();
|
|
133
|
+
}
|
|
134
|
+
return this._page;
|
|
135
|
+
}
|
|
136
|
+
/** Number of the columns this table was opened with. */
|
|
137
|
+
get columnCount() {
|
|
138
|
+
return this._columns.length;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DocumentEditorManager for PDF document editing operations
|
|
3
|
+
*
|
|
4
|
+
* Provides methods to edit and modify PDF documents including page operations,
|
|
5
|
+
* content manipulation, and document merging. API is consistent with Python,
|
|
6
|
+
* Java, C#, Go, and Swift implementations.
|
|
7
|
+
*/
|
|
8
|
+
import { EventEmitter } from 'events';
|
|
9
|
+
/**
|
|
10
|
+
* Page rotation options
|
|
11
|
+
*/
|
|
12
|
+
export declare enum PageRotation {
|
|
13
|
+
None = 0,
|
|
14
|
+
Rotate90 = 90,
|
|
15
|
+
Rotate180 = 180,
|
|
16
|
+
Rotate270 = 270
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for page insertion
|
|
20
|
+
*/
|
|
21
|
+
export interface InsertConfig {
|
|
22
|
+
pageIndex: number;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
content?: Buffer;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for page extraction
|
|
29
|
+
*/
|
|
30
|
+
export interface ExtractConfig {
|
|
31
|
+
startPage: number;
|
|
32
|
+
endPage: number;
|
|
33
|
+
outputPath?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for document merging
|
|
37
|
+
*/
|
|
38
|
+
export interface MergeConfig {
|
|
39
|
+
documents: any[];
|
|
40
|
+
outputPath?: string;
|
|
41
|
+
preserveOutlines?: boolean;
|
|
42
|
+
preserveAnnotations?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Edit operation record
|
|
46
|
+
*/
|
|
47
|
+
export interface EditOperation {
|
|
48
|
+
type: string;
|
|
49
|
+
timestamp: Date;
|
|
50
|
+
details: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Document Editor Manager for document manipulation
|
|
54
|
+
*
|
|
55
|
+
* Provides methods to:
|
|
56
|
+
* - Delete, insert, and reorder pages
|
|
57
|
+
* - Rotate pages
|
|
58
|
+
* - Extract page ranges to new documents
|
|
59
|
+
* - Merge multiple documents
|
|
60
|
+
* - Track edit history
|
|
61
|
+
*/
|
|
62
|
+
export declare class DocumentEditorManager extends EventEmitter {
|
|
63
|
+
private document;
|
|
64
|
+
private editHistory;
|
|
65
|
+
private hasUnsavedChanges;
|
|
66
|
+
constructor(document: any);
|
|
67
|
+
/**
|
|
68
|
+
* Deletes a page from the document
|
|
69
|
+
* Matches: Python deletePage(), Java deletePage(), C# DeletePage()
|
|
70
|
+
*/
|
|
71
|
+
deletePage(pageIndex: number): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Deletes multiple pages from the document
|
|
74
|
+
* Matches: Python deletePages(), Java deletePages(), C# DeletePages()
|
|
75
|
+
*/
|
|
76
|
+
deletePages(pageIndices: number[]): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Inserts a blank page at the specified position
|
|
79
|
+
* Matches: Python insertBlankPage(), Java insertBlankPage(), C# InsertBlankPage()
|
|
80
|
+
*/
|
|
81
|
+
insertBlankPage(pageIndex: number, width?: number, height?: number): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Rotates a page by the specified angle
|
|
84
|
+
* Matches: Python rotatePage(), Java rotatePage(), C# RotatePage()
|
|
85
|
+
*/
|
|
86
|
+
rotatePage(pageIndex: number, rotation: PageRotation): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Rotates multiple pages
|
|
89
|
+
* Matches: Python rotatePages(), Java rotatePages(), C# RotatePages()
|
|
90
|
+
*/
|
|
91
|
+
rotatePages(pageIndices: number[], rotation: PageRotation): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Moves a page to a new position
|
|
94
|
+
* Matches: Python movePage(), Java movePage(), C# MovePage()
|
|
95
|
+
*/
|
|
96
|
+
movePage(fromIndex: number, toIndex: number): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Extracts pages to a new document
|
|
99
|
+
* Matches: Python extractPages(), Java extractPages(), C# ExtractPages()
|
|
100
|
+
*/
|
|
101
|
+
extractPages(config: ExtractConfig): Promise<any>;
|
|
102
|
+
/**
|
|
103
|
+
* Merges multiple documents into one
|
|
104
|
+
* Matches: Python mergeDocuments(), Java mergeDocuments(), C# MergeDocuments()
|
|
105
|
+
*/
|
|
106
|
+
static mergeDocuments(config: MergeConfig): Promise<any>;
|
|
107
|
+
/**
|
|
108
|
+
* Saves the document with all modifications
|
|
109
|
+
* Matches: Python save(), Java save(), C# Save()
|
|
110
|
+
*/
|
|
111
|
+
save(outputPath?: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Gets the edit history
|
|
114
|
+
* Matches: Python getEditHistory(), Java getEditHistory(), C# GetEditHistory()
|
|
115
|
+
*/
|
|
116
|
+
getEditHistory(): EditOperation[];
|
|
117
|
+
/**
|
|
118
|
+
* Checks if there are unsaved changes
|
|
119
|
+
* Matches: Python hasUnsavedChanges(), Java hasUnsavedChanges(), C# HasUnsavedChanges()
|
|
120
|
+
*/
|
|
121
|
+
hasChanges(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Undoes the last operation (if supported)
|
|
124
|
+
* Matches: Python undo(), Java undo(), C# Undo()
|
|
125
|
+
*/
|
|
126
|
+
undo(): Promise<boolean>;
|
|
127
|
+
/**
|
|
128
|
+
* Clears the edit history
|
|
129
|
+
* Matches: Python clearHistory(), Java clearHistory(), C# ClearHistory()
|
|
130
|
+
*/
|
|
131
|
+
clearHistory(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Gets the page count after modifications
|
|
134
|
+
*/
|
|
135
|
+
getPageCount(): number;
|
|
136
|
+
private validatePageIndex;
|
|
137
|
+
private recordOperation;
|
|
138
|
+
}
|
|
139
|
+
export default DocumentEditorManager;
|