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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF Oxide Builders - Fluent APIs for configuring PDF operations
|
|
3
|
+
*
|
|
4
|
+
* This module exports builder classes that implement the fluent builder pattern
|
|
5
|
+
* for configuring PDF documents, annotations, search options, metadata, and conversion.
|
|
6
|
+
*/
|
|
7
|
+
export * from './annotation-builder';
|
|
8
|
+
export * from './conversion-options-builder';
|
|
9
|
+
export * from './document-builder';
|
|
10
|
+
export * from './metadata-builder';
|
|
11
|
+
export * from './pdf-builder';
|
|
12
|
+
export * from './search-options-builder';
|
|
13
|
+
export * from './streaming-table';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF Oxide Builders - Fluent APIs for configuring PDF operations
|
|
3
|
+
*
|
|
4
|
+
* This module exports builder classes that implement the fluent builder pattern
|
|
5
|
+
* for configuring PDF documents, annotations, search options, metadata, and conversion.
|
|
6
|
+
*/
|
|
7
|
+
export * from './annotation-builder.js';
|
|
8
|
+
export * from './conversion-options-builder.js';
|
|
9
|
+
export * from './document-builder.js';
|
|
10
|
+
export * from './metadata-builder.js';
|
|
11
|
+
export * from './pdf-builder.js';
|
|
12
|
+
export * from './search-options-builder.js';
|
|
13
|
+
export * from './streaming-table.js';
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder for document metadata configuration
|
|
3
|
+
*
|
|
4
|
+
* Configures document information like title, author, subject, keywords,
|
|
5
|
+
* creation date, and custom properties.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { MetadataBuilder } from 'pdf_oxide';
|
|
10
|
+
*
|
|
11
|
+
* const metadata = MetadataBuilder.create()
|
|
12
|
+
* .title('My Document')
|
|
13
|
+
* .author('John Doe')
|
|
14
|
+
* .subject('Important Information')
|
|
15
|
+
* .keywords(['document', 'important', 'example'])
|
|
16
|
+
* .creator('MyApp v1.0')
|
|
17
|
+
* .build();
|
|
18
|
+
*
|
|
19
|
+
* pdf.setMetadata(metadata);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export interface Metadata {
|
|
23
|
+
title?: string;
|
|
24
|
+
author?: string;
|
|
25
|
+
subject?: string;
|
|
26
|
+
keywords: string[];
|
|
27
|
+
creator?: string;
|
|
28
|
+
producer: string;
|
|
29
|
+
creationDate: Date;
|
|
30
|
+
modificationDate: Date;
|
|
31
|
+
customProperties: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
export declare class MetadataBuilder {
|
|
34
|
+
private _title?;
|
|
35
|
+
private _author?;
|
|
36
|
+
private _subject?;
|
|
37
|
+
private _keywords;
|
|
38
|
+
private _creator?;
|
|
39
|
+
private _producer;
|
|
40
|
+
private _creationDate;
|
|
41
|
+
private _modificationDate;
|
|
42
|
+
private _customProperties;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new MetadataBuilder instance
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
private constructor();
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new MetadataBuilder instance
|
|
50
|
+
* @returns New builder instance
|
|
51
|
+
*/
|
|
52
|
+
static create(): MetadataBuilder;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the document title
|
|
55
|
+
* @param title - The document title
|
|
56
|
+
* @returns This builder for chaining
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* builder.title('Project Report 2024');
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
title(title: string): this;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the document author
|
|
66
|
+
* @param author - The author name
|
|
67
|
+
* @returns This builder for chaining
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* builder.author('Jane Doe');
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
author(author: string): this;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the document subject
|
|
77
|
+
* @param subject - The document subject
|
|
78
|
+
* @returns This builder for chaining
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* builder.subject('Annual Report');
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
subject(subject: string): this;
|
|
86
|
+
/**
|
|
87
|
+
* Sets document keywords
|
|
88
|
+
* @param keywords - Array of keywords
|
|
89
|
+
* @returns This builder for chaining
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* builder.keywords(['report', 'annual', 'financial']);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
keywords(keywords: string[]): this;
|
|
97
|
+
/**
|
|
98
|
+
* Adds a single keyword
|
|
99
|
+
* @param keyword - A keyword to add
|
|
100
|
+
* @returns This builder for chaining
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* builder.addKeyword('Important').addKeyword('Urgent');
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
addKeyword(keyword: string): this;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the creator application name
|
|
110
|
+
* @param creator - Name of the application that created the document
|
|
111
|
+
* @returns This builder for chaining
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* builder.creator('MyApp v2.1.0');
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
creator(creator: string): this;
|
|
119
|
+
/**
|
|
120
|
+
* Sets the PDF producer (usually the library/tool that saved it)
|
|
121
|
+
* @param producer - Name of the PDF producer
|
|
122
|
+
* @returns This builder for chaining
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* builder.producer('PDF Oxide v0.3.2');
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
producer(producer: string): this;
|
|
130
|
+
/**
|
|
131
|
+
* Sets the document creation date
|
|
132
|
+
* @param date - The creation date
|
|
133
|
+
* @returns This builder for chaining
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* builder.creationDate(new Date('2024-01-15'));
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
creationDate(date: Date): this;
|
|
141
|
+
/**
|
|
142
|
+
* Sets the document modification date
|
|
143
|
+
* @param date - The modification date
|
|
144
|
+
* @returns This builder for chaining
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* builder.modificationDate(new Date());
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
modificationDate(date: Date): this;
|
|
152
|
+
/**
|
|
153
|
+
* Sets a custom metadata property
|
|
154
|
+
* @param key - Property key
|
|
155
|
+
* @param value - Property value
|
|
156
|
+
* @returns This builder for chaining
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* builder.customProperty('Department', 'Engineering');
|
|
161
|
+
* builder.customProperty('Classification', 'Confidential');
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
customProperty(key: string, value: string): this;
|
|
165
|
+
/**
|
|
166
|
+
* Sets multiple custom metadata properties
|
|
167
|
+
* @param properties - Object with key-value pairs
|
|
168
|
+
* @returns This builder for chaining
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* builder.customProperties({
|
|
173
|
+
* Department: 'Engineering',
|
|
174
|
+
* Classification: 'Confidential',
|
|
175
|
+
* ProjectCode: 'PROJ-2024-001'
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
customProperties(properties: Record<string, string>): this;
|
|
180
|
+
/**
|
|
181
|
+
* Builds and returns the metadata object
|
|
182
|
+
* @returns Immutable metadata object
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* const metadata = builder.build();
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
build(): Metadata;
|
|
190
|
+
/**
|
|
191
|
+
* Creates metadata with current timestamp
|
|
192
|
+
* @returns This builder with current modification date
|
|
193
|
+
*/
|
|
194
|
+
withCurrentDate(): this;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Create a new MetadataBuilder with static factory
|
|
198
|
+
* @deprecated Use MetadataBuilder.create() instead
|
|
199
|
+
* @returns New builder instance
|
|
200
|
+
*/
|
|
201
|
+
export declare function createMetadataBuilder(): MetadataBuilder;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder for document metadata configuration
|
|
3
|
+
*
|
|
4
|
+
* Configures document information like title, author, subject, keywords,
|
|
5
|
+
* creation date, and custom properties.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { MetadataBuilder } from 'pdf_oxide';
|
|
10
|
+
*
|
|
11
|
+
* const metadata = MetadataBuilder.create()
|
|
12
|
+
* .title('My Document')
|
|
13
|
+
* .author('John Doe')
|
|
14
|
+
* .subject('Important Information')
|
|
15
|
+
* .keywords(['document', 'important', 'example'])
|
|
16
|
+
* .creator('MyApp v1.0')
|
|
17
|
+
* .build();
|
|
18
|
+
*
|
|
19
|
+
* pdf.setMetadata(metadata);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class MetadataBuilder {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new MetadataBuilder instance
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
constructor() {
|
|
28
|
+
this._keywords = [];
|
|
29
|
+
this._producer = 'PDF Oxide';
|
|
30
|
+
this._creationDate = new Date();
|
|
31
|
+
this._modificationDate = new Date();
|
|
32
|
+
this._customProperties = {};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new MetadataBuilder instance
|
|
36
|
+
* @returns New builder instance
|
|
37
|
+
*/
|
|
38
|
+
static create() {
|
|
39
|
+
return new MetadataBuilder();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sets the document title
|
|
43
|
+
* @param title - The document title
|
|
44
|
+
* @returns This builder for chaining
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* builder.title('Project Report 2024');
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
title(title) {
|
|
52
|
+
if (typeof title !== 'string') {
|
|
53
|
+
throw new Error('Title must be a string');
|
|
54
|
+
}
|
|
55
|
+
this._title = title.length > 0 ? title : undefined;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sets the document author
|
|
60
|
+
* @param author - The author name
|
|
61
|
+
* @returns This builder for chaining
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* builder.author('Jane Doe');
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
author(author) {
|
|
69
|
+
if (typeof author !== 'string') {
|
|
70
|
+
throw new Error('Author must be a string');
|
|
71
|
+
}
|
|
72
|
+
this._author = author.length > 0 ? author : undefined;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Sets the document subject
|
|
77
|
+
* @param subject - The document subject
|
|
78
|
+
* @returns This builder for chaining
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* builder.subject('Annual Report');
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
subject(subject) {
|
|
86
|
+
if (typeof subject !== 'string') {
|
|
87
|
+
throw new Error('Subject must be a string');
|
|
88
|
+
}
|
|
89
|
+
this._subject = subject.length > 0 ? subject : undefined;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Sets document keywords
|
|
94
|
+
* @param keywords - Array of keywords
|
|
95
|
+
* @returns This builder for chaining
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* builder.keywords(['report', 'annual', 'financial']);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
keywords(keywords) {
|
|
103
|
+
if (!Array.isArray(keywords)) {
|
|
104
|
+
throw new Error('Keywords must be an array');
|
|
105
|
+
}
|
|
106
|
+
if (!keywords.every((k) => typeof k === 'string')) {
|
|
107
|
+
throw new Error('All keywords must be strings');
|
|
108
|
+
}
|
|
109
|
+
this._keywords = [...keywords];
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Adds a single keyword
|
|
114
|
+
* @param keyword - A keyword to add
|
|
115
|
+
* @returns This builder for chaining
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* builder.addKeyword('Important').addKeyword('Urgent');
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
addKeyword(keyword) {
|
|
123
|
+
if (typeof keyword !== 'string' || keyword.length === 0) {
|
|
124
|
+
throw new Error('Keyword must be a non-empty string');
|
|
125
|
+
}
|
|
126
|
+
if (!this._keywords.includes(keyword)) {
|
|
127
|
+
this._keywords.push(keyword);
|
|
128
|
+
}
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Sets the creator application name
|
|
133
|
+
* @param creator - Name of the application that created the document
|
|
134
|
+
* @returns This builder for chaining
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* builder.creator('MyApp v2.1.0');
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
creator(creator) {
|
|
142
|
+
if (typeof creator !== 'string') {
|
|
143
|
+
throw new Error('Creator must be a string');
|
|
144
|
+
}
|
|
145
|
+
this._creator = creator.length > 0 ? creator : undefined;
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Sets the PDF producer (usually the library/tool that saved it)
|
|
150
|
+
* @param producer - Name of the PDF producer
|
|
151
|
+
* @returns This builder for chaining
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* builder.producer('PDF Oxide v0.3.2');
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
producer(producer) {
|
|
159
|
+
if (typeof producer !== 'string') {
|
|
160
|
+
throw new Error('Producer must be a string');
|
|
161
|
+
}
|
|
162
|
+
this._producer = producer.length > 0 ? producer : 'PDF Oxide';
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Sets the document creation date
|
|
167
|
+
* @param date - The creation date
|
|
168
|
+
* @returns This builder for chaining
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* builder.creationDate(new Date('2024-01-15'));
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
creationDate(date) {
|
|
176
|
+
if (!(date instanceof Date)) {
|
|
177
|
+
throw new Error('creationDate must be a Date object');
|
|
178
|
+
}
|
|
179
|
+
this._creationDate = new Date(date);
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Sets the document modification date
|
|
184
|
+
* @param date - The modification date
|
|
185
|
+
* @returns This builder for chaining
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* builder.modificationDate(new Date());
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
modificationDate(date) {
|
|
193
|
+
if (!(date instanceof Date)) {
|
|
194
|
+
throw new Error('modificationDate must be a Date object');
|
|
195
|
+
}
|
|
196
|
+
this._modificationDate = new Date(date);
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Sets a custom metadata property
|
|
201
|
+
* @param key - Property key
|
|
202
|
+
* @param value - Property value
|
|
203
|
+
* @returns This builder for chaining
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* builder.customProperty('Department', 'Engineering');
|
|
208
|
+
* builder.customProperty('Classification', 'Confidential');
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
customProperty(key, value) {
|
|
212
|
+
if (typeof key !== 'string' || key.length === 0) {
|
|
213
|
+
throw new Error('Property key must be a non-empty string');
|
|
214
|
+
}
|
|
215
|
+
if (typeof value !== 'string') {
|
|
216
|
+
throw new Error('Property value must be a string');
|
|
217
|
+
}
|
|
218
|
+
this._customProperties[key] = value;
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Sets multiple custom metadata properties
|
|
223
|
+
* @param properties - Object with key-value pairs
|
|
224
|
+
* @returns This builder for chaining
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* builder.customProperties({
|
|
229
|
+
* Department: 'Engineering',
|
|
230
|
+
* Classification: 'Confidential',
|
|
231
|
+
* ProjectCode: 'PROJ-2024-001'
|
|
232
|
+
* });
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
customProperties(properties) {
|
|
236
|
+
if (typeof properties !== 'object' || properties === null) {
|
|
237
|
+
throw new Error('customProperties must be an object');
|
|
238
|
+
}
|
|
239
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
240
|
+
if (typeof value !== 'string') {
|
|
241
|
+
throw new Error(`Custom property "${key}" value must be a string`);
|
|
242
|
+
}
|
|
243
|
+
this._customProperties[key] = value;
|
|
244
|
+
}
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Builds and returns the metadata object
|
|
249
|
+
* @returns Immutable metadata object
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const metadata = builder.build();
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
build() {
|
|
257
|
+
return {
|
|
258
|
+
title: this._title,
|
|
259
|
+
author: this._author,
|
|
260
|
+
subject: this._subject,
|
|
261
|
+
keywords: [...this._keywords],
|
|
262
|
+
creator: this._creator,
|
|
263
|
+
producer: this._producer,
|
|
264
|
+
creationDate: new Date(this._creationDate),
|
|
265
|
+
modificationDate: new Date(this._modificationDate),
|
|
266
|
+
customProperties: { ...this._customProperties },
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates metadata with current timestamp
|
|
271
|
+
* @returns This builder with current modification date
|
|
272
|
+
*/
|
|
273
|
+
withCurrentDate() {
|
|
274
|
+
this._modificationDate = new Date();
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Create a new MetadataBuilder with static factory
|
|
280
|
+
* @deprecated Use MetadataBuilder.create() instead
|
|
281
|
+
* @returns New builder instance
|
|
282
|
+
*/
|
|
283
|
+
export function createMetadataBuilder() {
|
|
284
|
+
return MetadataBuilder.create();
|
|
285
|
+
}
|