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,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common type definitions and utilities
|
|
3
|
+
*/
|
|
4
|
+
/** A table extracted from a PDF page. */
|
|
5
|
+
export interface Table {
|
|
6
|
+
/** Number of rows. */
|
|
7
|
+
rows: number;
|
|
8
|
+
/** Number of columns. */
|
|
9
|
+
cols: number;
|
|
10
|
+
/** True if the first row is a header row. */
|
|
11
|
+
hasHeader: boolean;
|
|
12
|
+
/** Cell text: cells[row][col]. Individual cells may be `null` when the
|
|
13
|
+
* native binding has no text for that position (missing cell, decoding
|
|
14
|
+
* failure, etc.). */
|
|
15
|
+
cells: (string | null)[][];
|
|
16
|
+
}
|
|
17
|
+
export type { Annotation, CircleAnnotation, Color, DocumentInfo, EmbeddedFile, HighlightAnnotation, InkAnnotation, LineAnnotation, LinkAnnotation, Metadata, NativePdf, NativePdfDocument, NativePdfPage, PdfElement, PdfImage, PdfPath, PdfTable, PdfTableCell, PdfText, Point, PolygonAnnotation, Rect, SearchOptions, SearchResult, SquareAnnotation, TextAnnotation, } from './native-bindings';
|
|
18
|
+
/**
|
|
19
|
+
* Page range specification for document operations
|
|
20
|
+
*/
|
|
21
|
+
export interface PageRange {
|
|
22
|
+
startPage?: number;
|
|
23
|
+
endPage?: number;
|
|
24
|
+
pages?: number[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generic extraction result with metadata
|
|
28
|
+
*/
|
|
29
|
+
export interface ExtractionResult<T> {
|
|
30
|
+
data: T;
|
|
31
|
+
pageIndex: number;
|
|
32
|
+
timestamp: Date;
|
|
33
|
+
processingTimeMs?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Async operation callback function type
|
|
37
|
+
*/
|
|
38
|
+
export type AsyncOperationCallback<T> = (err: Error | null, result?: T) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Manager configuration interface for all managers
|
|
41
|
+
*/
|
|
42
|
+
export interface ManagerConfig {
|
|
43
|
+
maxCacheSize?: number;
|
|
44
|
+
cacheExpirationMs?: number;
|
|
45
|
+
enableCaching?: boolean;
|
|
46
|
+
timeout?: number;
|
|
47
|
+
retryAttempts?: number;
|
|
48
|
+
retryDelayMs?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Batch operation options
|
|
52
|
+
*/
|
|
53
|
+
export interface BatchOptions {
|
|
54
|
+
batchSize?: number;
|
|
55
|
+
parallel?: boolean;
|
|
56
|
+
maxParallel?: number;
|
|
57
|
+
progressCallback?: (processed: number, total: number) => void;
|
|
58
|
+
continueOnError?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Error details for exception context
|
|
62
|
+
*/
|
|
63
|
+
export interface PdfErrorDetails {
|
|
64
|
+
timestamp?: string;
|
|
65
|
+
operation?: string;
|
|
66
|
+
context?: Record<string, any>;
|
|
67
|
+
originalError?: Error;
|
|
68
|
+
stack?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Optional content (layers) information
|
|
72
|
+
*/
|
|
73
|
+
export interface OptionalContent {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
visible: boolean;
|
|
77
|
+
locked?: boolean;
|
|
78
|
+
printable?: boolean;
|
|
79
|
+
exportable?: boolean;
|
|
80
|
+
viewState?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Form field value map for filling forms
|
|
84
|
+
*/
|
|
85
|
+
export type FormFieldValues = Record<string, string | number | boolean | string[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Type for validation result
|
|
88
|
+
*/
|
|
89
|
+
export interface ValidationResult {
|
|
90
|
+
isValid: boolean;
|
|
91
|
+
errors: string[];
|
|
92
|
+
warnings: string[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Stream operation callback
|
|
96
|
+
*/
|
|
97
|
+
export type StreamCallback<T> = (data: T) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Stream error callback
|
|
100
|
+
*/
|
|
101
|
+
export type StreamErrorCallback = (error: Error) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Stream end callback
|
|
104
|
+
*/
|
|
105
|
+
export type StreamEndCallback = () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Horizontal alignment for wrapped text and table cells.
|
|
108
|
+
* Matches the C FFI integer encoding used by
|
|
109
|
+
* `pdf_page_builder_text_in_rect` and `pdf_page_builder_table`.
|
|
110
|
+
*/
|
|
111
|
+
export declare enum Align {
|
|
112
|
+
Left = 0,
|
|
113
|
+
Center = 1,
|
|
114
|
+
Right = 2
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Column descriptor for {@link TableSpec} / {@link StreamingTableConfig}.
|
|
118
|
+
*/
|
|
119
|
+
export interface Column {
|
|
120
|
+
/** Header label rendered in bold (used only when `hasHeader`/`repeatHeader`). */
|
|
121
|
+
header: string;
|
|
122
|
+
/** Column width in PDF points. */
|
|
123
|
+
width: number;
|
|
124
|
+
/** Cell alignment (default {@link Align.Left}). */
|
|
125
|
+
align?: Align;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Buffered-table spec passed to `PageBuilder.table(...)`.
|
|
129
|
+
*
|
|
130
|
+
* All rows are held in JS memory and flushed to the native
|
|
131
|
+
* `pdf_page_builder_table` call in a single step.
|
|
132
|
+
*/
|
|
133
|
+
export interface TableSpec {
|
|
134
|
+
/** Column layout — widths, alignments, and header labels. */
|
|
135
|
+
columns: Column[];
|
|
136
|
+
/** Body rows, each row has `columns.length` cells (nullable = empty). */
|
|
137
|
+
rows: Array<Array<string | null | undefined>>;
|
|
138
|
+
/** Promote the column headers to a styled first row. Defaults to true. */
|
|
139
|
+
hasHeader?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Column-sizing strategy for streaming tables (issue #400).
|
|
143
|
+
*
|
|
144
|
+
* - `fixed` — use the `width` from each `Column` as-is (default).
|
|
145
|
+
* - `sample` — buffer the first N rows, measure content, then freeze
|
|
146
|
+
* column widths automatically. Supply `sampleRows`, `minColWidth`,
|
|
147
|
+
* and `maxColWidth` to tune.
|
|
148
|
+
*/
|
|
149
|
+
export type TableMode = {
|
|
150
|
+
kind: 'fixed';
|
|
151
|
+
} | {
|
|
152
|
+
kind: 'sample';
|
|
153
|
+
sampleRows?: number;
|
|
154
|
+
minColWidthPt?: number;
|
|
155
|
+
maxColWidthPt?: number;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Configuration for the managed streaming-table adapter.
|
|
159
|
+
*/
|
|
160
|
+
export interface StreamingTableConfig {
|
|
161
|
+
/** Column layout — widths, alignments, and header labels. */
|
|
162
|
+
columns: Column[];
|
|
163
|
+
/**
|
|
164
|
+
* Whether to repeat the header row on every page break. Defaults to true.
|
|
165
|
+
*/
|
|
166
|
+
repeatHeader?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Column-sizing mode. Defaults to `{ kind: 'fixed' }`.
|
|
169
|
+
*/
|
|
170
|
+
mode?: TableMode;
|
|
171
|
+
/**
|
|
172
|
+
* Maximum rowspan a cell may carry. 0 or 1 (default) disables rowspan.
|
|
173
|
+
* Set to ≥2 to allow `pushRowSpan` cells to span multiple rows.
|
|
174
|
+
*/
|
|
175
|
+
maxRowspan?: number;
|
|
176
|
+
/**
|
|
177
|
+
* Maximum rows to buffer before an automatic batch flush in the native
|
|
178
|
+
* layer. 0 or unset defaults to 256.
|
|
179
|
+
*/
|
|
180
|
+
batchSize?: number;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A single cell value for `StreamingTable.pushRowSpan`.
|
|
184
|
+
* `rowspan == 1` is equivalent to a normal cell.
|
|
185
|
+
*/
|
|
186
|
+
export interface SpanCell {
|
|
187
|
+
text: string;
|
|
188
|
+
rowspan: number;
|
|
189
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common type definitions and utilities
|
|
3
|
+
*/
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// DocumentBuilder — table primitives (v0.3.39, issue #393)
|
|
6
|
+
// ============================================================================
|
|
7
|
+
/**
|
|
8
|
+
* Horizontal alignment for wrapped text and table cells.
|
|
9
|
+
* Matches the C FFI integer encoding used by
|
|
10
|
+
* `pdf_page_builder_text_in_rect` and `pdf_page_builder_table`.
|
|
11
|
+
*/
|
|
12
|
+
export var Align;
|
|
13
|
+
(function (Align) {
|
|
14
|
+
Align[Align["Left"] = 0] = "Left";
|
|
15
|
+
Align[Align["Center"] = 1] = "Center";
|
|
16
|
+
Align[Align["Right"] = 2] = "Right";
|
|
17
|
+
})(Align || (Align = {}));
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PdfDocument - TypeScript type definitions for pdf_oxide
|
|
3
|
+
*
|
|
4
|
+
* Provides complete type definitions for the PdfDocument class and related types.
|
|
5
|
+
* These types ensure type safety when using the pdf_oxide library in TypeScript.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { PdfDocument } from 'pdf_oxide';
|
|
10
|
+
*
|
|
11
|
+
* const doc = await PdfDocument.open('document.pdf');
|
|
12
|
+
* const pageCount = await doc.pageCount();
|
|
13
|
+
* const text = await doc.extractText(0);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Represents a rectangle in PDF coordinate space (origin at bottom-left)
|
|
18
|
+
*/
|
|
19
|
+
export interface Rect {
|
|
20
|
+
readonly x: number;
|
|
21
|
+
readonly y: number;
|
|
22
|
+
readonly width: number;
|
|
23
|
+
readonly height: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents a point in PDF coordinate space
|
|
27
|
+
*/
|
|
28
|
+
export interface Point {
|
|
29
|
+
readonly x: number;
|
|
30
|
+
readonly y: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Represents a color (RGBA)
|
|
34
|
+
*/
|
|
35
|
+
export interface Color {
|
|
36
|
+
readonly r: number;
|
|
37
|
+
readonly g: number;
|
|
38
|
+
readonly b: number;
|
|
39
|
+
readonly a?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Standard page sizes
|
|
43
|
+
*/
|
|
44
|
+
export declare enum PageSizeType {
|
|
45
|
+
LETTER = "letter",
|
|
46
|
+
LEGAL = "legal",
|
|
47
|
+
A4 = "a4",
|
|
48
|
+
A3 = "a3",
|
|
49
|
+
A5 = "a5",
|
|
50
|
+
B4 = "b4",
|
|
51
|
+
TABLOID = "tabloid"
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Page size dimensions
|
|
55
|
+
*/
|
|
56
|
+
export interface PageSize {
|
|
57
|
+
readonly type?: PageSizeType;
|
|
58
|
+
readonly width: number;
|
|
59
|
+
readonly height: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* PDF document metadata
|
|
63
|
+
*/
|
|
64
|
+
export interface DocumentMetadata {
|
|
65
|
+
readonly title?: string;
|
|
66
|
+
readonly author?: string;
|
|
67
|
+
readonly subject?: string;
|
|
68
|
+
readonly keywords?: string;
|
|
69
|
+
readonly creator?: string;
|
|
70
|
+
readonly producer?: string;
|
|
71
|
+
readonly creationDate?: Date;
|
|
72
|
+
readonly modificationDate?: Date;
|
|
73
|
+
readonly pageCount: number;
|
|
74
|
+
readonly format?: string;
|
|
75
|
+
readonly version?: string;
|
|
76
|
+
readonly isEncrypted?: boolean;
|
|
77
|
+
readonly hasXfa?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Form field type enumeration
|
|
81
|
+
*/
|
|
82
|
+
export declare enum FormFieldType {
|
|
83
|
+
TEXT = "text",
|
|
84
|
+
CHECKBOX = "checkbox",
|
|
85
|
+
RADIO = "radio",
|
|
86
|
+
COMBOBOX = "combobox",
|
|
87
|
+
LISTBOX = "listbox",
|
|
88
|
+
SIGNATURE = "signature",
|
|
89
|
+
DATE = "date",
|
|
90
|
+
BUTTON = "button"
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Form field information
|
|
94
|
+
*/
|
|
95
|
+
export interface FormField {
|
|
96
|
+
readonly name: string;
|
|
97
|
+
readonly type: FormFieldType;
|
|
98
|
+
readonly value: string;
|
|
99
|
+
readonly pageIndex: number;
|
|
100
|
+
readonly x: number;
|
|
101
|
+
readonly y: number;
|
|
102
|
+
readonly width: number;
|
|
103
|
+
readonly height: number;
|
|
104
|
+
readonly required?: boolean;
|
|
105
|
+
readonly readonly?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Text content on a page
|
|
109
|
+
*/
|
|
110
|
+
export interface TextContent {
|
|
111
|
+
readonly text: string;
|
|
112
|
+
readonly x: number;
|
|
113
|
+
readonly y: number;
|
|
114
|
+
readonly width: number;
|
|
115
|
+
readonly height: number;
|
|
116
|
+
readonly fontName?: string;
|
|
117
|
+
readonly fontSize?: number;
|
|
118
|
+
readonly confidence?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Image content on a page
|
|
122
|
+
*/
|
|
123
|
+
export interface ImageContent {
|
|
124
|
+
readonly x: number;
|
|
125
|
+
readonly y: number;
|
|
126
|
+
readonly width: number;
|
|
127
|
+
readonly height: number;
|
|
128
|
+
readonly imageType?: string;
|
|
129
|
+
readonly bitsPerComponent?: number;
|
|
130
|
+
readonly colorSpace?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Annotation type enumeration
|
|
134
|
+
*/
|
|
135
|
+
export declare enum AnnotationType {
|
|
136
|
+
TEXT = "text",
|
|
137
|
+
LINK = "link",
|
|
138
|
+
HIGHLIGHT = "highlight",
|
|
139
|
+
UNDERLINE = "underline",
|
|
140
|
+
STRIKEOUT = "strikeout",
|
|
141
|
+
SQUIGGLY = "squiggly",
|
|
142
|
+
STAMP = "stamp",
|
|
143
|
+
CARET = "caret",
|
|
144
|
+
INK = "ink",
|
|
145
|
+
POPUP = "popup",
|
|
146
|
+
FILE_ATTACHMENT = "file_attachment",
|
|
147
|
+
SOUND = "sound",
|
|
148
|
+
MOVIE = "movie",
|
|
149
|
+
WIDGET = "widget",
|
|
150
|
+
SCREEN = "screen",
|
|
151
|
+
PRINTER_MARK = "printer_mark",
|
|
152
|
+
TRAP_NET = "trap_net",
|
|
153
|
+
WATERMARK = "watermark",
|
|
154
|
+
REDACT = "redact"
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Annotation information
|
|
158
|
+
*/
|
|
159
|
+
export interface Annotation {
|
|
160
|
+
readonly type: AnnotationType;
|
|
161
|
+
readonly x: number;
|
|
162
|
+
readonly y: number;
|
|
163
|
+
readonly width: number;
|
|
164
|
+
readonly height: number;
|
|
165
|
+
readonly contents?: string;
|
|
166
|
+
readonly author?: string;
|
|
167
|
+
readonly creationDate?: Date;
|
|
168
|
+
readonly modificationDate?: Date;
|
|
169
|
+
readonly color?: Color;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Search options
|
|
173
|
+
*/
|
|
174
|
+
export interface SearchOptions {
|
|
175
|
+
readonly caseSensitive?: boolean;
|
|
176
|
+
readonly wholeWord?: boolean;
|
|
177
|
+
readonly regex?: boolean;
|
|
178
|
+
readonly maxResults?: number;
|
|
179
|
+
readonly pageRange?: {
|
|
180
|
+
start: number;
|
|
181
|
+
end: number;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Search result
|
|
186
|
+
*/
|
|
187
|
+
export interface SearchResult {
|
|
188
|
+
readonly pageIndex: number;
|
|
189
|
+
readonly text: string;
|
|
190
|
+
readonly x: number;
|
|
191
|
+
readonly y: number;
|
|
192
|
+
readonly width: number;
|
|
193
|
+
readonly height: number;
|
|
194
|
+
readonly context?: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Markdown conversion options
|
|
198
|
+
*/
|
|
199
|
+
export interface MarkdownOptions {
|
|
200
|
+
readonly includeImages?: boolean;
|
|
201
|
+
readonly includeLinks?: boolean;
|
|
202
|
+
readonly preserveLayout?: boolean;
|
|
203
|
+
readonly pageRange?: {
|
|
204
|
+
start: number;
|
|
205
|
+
end: number;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* HTML conversion options
|
|
210
|
+
*/
|
|
211
|
+
export interface HtmlOptions {
|
|
212
|
+
readonly includeStyles?: boolean;
|
|
213
|
+
readonly includeImages?: boolean;
|
|
214
|
+
readonly embedImages?: boolean;
|
|
215
|
+
readonly pageRange?: {
|
|
216
|
+
start: number;
|
|
217
|
+
end: number;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Represents a single page in a PDF document
|
|
222
|
+
*/
|
|
223
|
+
export interface PdfPage {
|
|
224
|
+
readonly index: number;
|
|
225
|
+
readonly width: number;
|
|
226
|
+
readonly height: number;
|
|
227
|
+
readonly rotation: number;
|
|
228
|
+
readonly mediaBox: Rect;
|
|
229
|
+
readonly cropBox?: Rect;
|
|
230
|
+
readonly bleedBox?: Rect;
|
|
231
|
+
readonly trimBox?: Rect;
|
|
232
|
+
readonly artBox?: Rect;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Main PDF document class
|
|
236
|
+
*
|
|
237
|
+
* Provides access to PDF document content, metadata, and structure.
|
|
238
|
+
* All operations are async to support non-blocking I/O.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* // Open a document
|
|
243
|
+
* const doc = await PdfDocument.open('file.pdf');
|
|
244
|
+
*
|
|
245
|
+
* // Get page count
|
|
246
|
+
* const pages = await doc.pageCount();
|
|
247
|
+
*
|
|
248
|
+
* // Extract text from first page
|
|
249
|
+
* const text = await doc.extractText(0);
|
|
250
|
+
*
|
|
251
|
+
* // Get metadata
|
|
252
|
+
* const metadata = await doc.getMetadata();
|
|
253
|
+
*
|
|
254
|
+
* // Convert to markdown
|
|
255
|
+
* const markdown = await doc.toMarkdown();
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
export interface PdfDocument {
|
|
259
|
+
/**
|
|
260
|
+
* Open a PDF document from a file path
|
|
261
|
+
*/
|
|
262
|
+
/**
|
|
263
|
+
* Open a PDF document from a buffer
|
|
264
|
+
*/
|
|
265
|
+
/**
|
|
266
|
+
* Get the number of pages in the document
|
|
267
|
+
*/
|
|
268
|
+
pageCount(): Promise<number>;
|
|
269
|
+
/**
|
|
270
|
+
* Get document metadata
|
|
271
|
+
*/
|
|
272
|
+
getMetadata(): Promise<DocumentMetadata>;
|
|
273
|
+
/**
|
|
274
|
+
* Get page information
|
|
275
|
+
*/
|
|
276
|
+
getPage(pageIndex: number): Promise<PdfPage>;
|
|
277
|
+
/**
|
|
278
|
+
* Extract text from a specific page
|
|
279
|
+
*/
|
|
280
|
+
extractText(pageIndex: number): Promise<string>;
|
|
281
|
+
/**
|
|
282
|
+
* Extract text from a range of pages
|
|
283
|
+
*/
|
|
284
|
+
extractTextRange(startPage: number, endPage: number): Promise<string[]>;
|
|
285
|
+
/**
|
|
286
|
+
* Extract all text from the document
|
|
287
|
+
*/
|
|
288
|
+
extractAllText(): Promise<string>;
|
|
289
|
+
/**
|
|
290
|
+
* Get all form fields in the document
|
|
291
|
+
*/
|
|
292
|
+
extractFormFields(): Promise<FormField[]>;
|
|
293
|
+
/**
|
|
294
|
+
* Get form field by name
|
|
295
|
+
*/
|
|
296
|
+
getFormField(fieldName: string): Promise<FormField | undefined>;
|
|
297
|
+
/**
|
|
298
|
+
* Set form field value
|
|
299
|
+
*/
|
|
300
|
+
setFormFieldValue(fieldName: string, value: string): Promise<boolean>;
|
|
301
|
+
/**
|
|
302
|
+
* Get annotations on a specific page
|
|
303
|
+
*/
|
|
304
|
+
getAnnotations(pageIndex: number): Promise<Annotation[]>;
|
|
305
|
+
/**
|
|
306
|
+
* Get all annotations in the document
|
|
307
|
+
*/
|
|
308
|
+
getAllAnnotations(): Promise<Annotation[]>;
|
|
309
|
+
/**
|
|
310
|
+
* Search for text in the document
|
|
311
|
+
*/
|
|
312
|
+
search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
|
|
313
|
+
/**
|
|
314
|
+
* Convert document to markdown
|
|
315
|
+
*/
|
|
316
|
+
toMarkdown(options?: MarkdownOptions): Promise<string>;
|
|
317
|
+
/**
|
|
318
|
+
* Convert document to HTML
|
|
319
|
+
*/
|
|
320
|
+
toHtml(options?: HtmlOptions): Promise<string>;
|
|
321
|
+
/**
|
|
322
|
+
* Close the document and release resources
|
|
323
|
+
*/
|
|
324
|
+
close(): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Check if document is open
|
|
327
|
+
*/
|
|
328
|
+
isOpen(): boolean;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* PdfDocument static methods (factory pattern)
|
|
332
|
+
*/
|
|
333
|
+
export interface PdfDocumentStatic {
|
|
334
|
+
/**
|
|
335
|
+
* Open a PDF document from a file path
|
|
336
|
+
*/
|
|
337
|
+
open(path: string, password?: string): Promise<PdfDocument>;
|
|
338
|
+
/**
|
|
339
|
+
* Open a PDF document from a buffer
|
|
340
|
+
*/
|
|
341
|
+
openBuffer(buffer: Buffer, password?: string): Promise<PdfDocument>;
|
|
342
|
+
/**
|
|
343
|
+
* Create a new empty PDF document
|
|
344
|
+
*/
|
|
345
|
+
create(): Promise<PdfDocument>;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Re-export PdfDocument from the main nodejs module
|
|
349
|
+
* This provides the actual implementation with full type safety
|
|
350
|
+
*/
|
|
351
|
+
export { PdfDocument } from '../index.js';
|
|
352
|
+
export default PdfDocument;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PdfDocument - TypeScript type definitions for pdf_oxide
|
|
3
|
+
*
|
|
4
|
+
* Provides complete type definitions for the PdfDocument class and related types.
|
|
5
|
+
* These types ensure type safety when using the pdf_oxide library in TypeScript.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { PdfDocument } from 'pdf_oxide';
|
|
10
|
+
*
|
|
11
|
+
* const doc = await PdfDocument.open('document.pdf');
|
|
12
|
+
* const pageCount = await doc.pageCount();
|
|
13
|
+
* const text = await doc.extractText(0);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Standard page sizes
|
|
18
|
+
*/
|
|
19
|
+
export var PageSizeType;
|
|
20
|
+
(function (PageSizeType) {
|
|
21
|
+
PageSizeType["LETTER"] = "letter";
|
|
22
|
+
PageSizeType["LEGAL"] = "legal";
|
|
23
|
+
PageSizeType["A4"] = "a4";
|
|
24
|
+
PageSizeType["A3"] = "a3";
|
|
25
|
+
PageSizeType["A5"] = "a5";
|
|
26
|
+
PageSizeType["B4"] = "b4";
|
|
27
|
+
PageSizeType["TABLOID"] = "tabloid";
|
|
28
|
+
})(PageSizeType || (PageSizeType = {}));
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Form Fields
|
|
31
|
+
// ============================================================================
|
|
32
|
+
/**
|
|
33
|
+
* Form field type enumeration
|
|
34
|
+
*/
|
|
35
|
+
export var FormFieldType;
|
|
36
|
+
(function (FormFieldType) {
|
|
37
|
+
FormFieldType["TEXT"] = "text";
|
|
38
|
+
FormFieldType["CHECKBOX"] = "checkbox";
|
|
39
|
+
FormFieldType["RADIO"] = "radio";
|
|
40
|
+
FormFieldType["COMBOBOX"] = "combobox";
|
|
41
|
+
FormFieldType["LISTBOX"] = "listbox";
|
|
42
|
+
FormFieldType["SIGNATURE"] = "signature";
|
|
43
|
+
FormFieldType["DATE"] = "date";
|
|
44
|
+
FormFieldType["BUTTON"] = "button";
|
|
45
|
+
})(FormFieldType || (FormFieldType = {}));
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Annotations
|
|
48
|
+
// ============================================================================
|
|
49
|
+
/**
|
|
50
|
+
* Annotation type enumeration
|
|
51
|
+
*/
|
|
52
|
+
export var AnnotationType;
|
|
53
|
+
(function (AnnotationType) {
|
|
54
|
+
AnnotationType["TEXT"] = "text";
|
|
55
|
+
AnnotationType["LINK"] = "link";
|
|
56
|
+
AnnotationType["HIGHLIGHT"] = "highlight";
|
|
57
|
+
AnnotationType["UNDERLINE"] = "underline";
|
|
58
|
+
AnnotationType["STRIKEOUT"] = "strikeout";
|
|
59
|
+
AnnotationType["SQUIGGLY"] = "squiggly";
|
|
60
|
+
AnnotationType["STAMP"] = "stamp";
|
|
61
|
+
AnnotationType["CARET"] = "caret";
|
|
62
|
+
AnnotationType["INK"] = "ink";
|
|
63
|
+
AnnotationType["POPUP"] = "popup";
|
|
64
|
+
AnnotationType["FILE_ATTACHMENT"] = "file_attachment";
|
|
65
|
+
AnnotationType["SOUND"] = "sound";
|
|
66
|
+
AnnotationType["MOVIE"] = "movie";
|
|
67
|
+
AnnotationType["WIDGET"] = "widget";
|
|
68
|
+
AnnotationType["SCREEN"] = "screen";
|
|
69
|
+
AnnotationType["PRINTER_MARK"] = "printer_mark";
|
|
70
|
+
AnnotationType["TRAP_NET"] = "trap_net";
|
|
71
|
+
AnnotationType["WATERMARK"] = "watermark";
|
|
72
|
+
AnnotationType["REDACT"] = "redact";
|
|
73
|
+
})(AnnotationType || (AnnotationType = {}));
|
|
74
|
+
// ============================================================================
|
|
75
|
+
// Export PdfDocument (dynamically loaded from native module)
|
|
76
|
+
// ============================================================================
|
|
77
|
+
/**
|
|
78
|
+
* Re-export PdfDocument from the main nodejs module
|
|
79
|
+
* This provides the actual implementation with full type safety
|
|
80
|
+
*/
|
|
81
|
+
export { PdfDocument } from '../index.js';
|
|
82
|
+
export default PdfDocument;
|