pdf-oxide-fips 0.3.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSE-APACHE +176 -0
  2. package/LICENSE-MIT +25 -0
  3. package/README.md +218 -0
  4. package/lib/builders/annotation-builder.d.ts +198 -0
  5. package/lib/builders/annotation-builder.js +317 -0
  6. package/lib/builders/conversion-options-builder.d.ts +106 -0
  7. package/lib/builders/conversion-options-builder.js +214 -0
  8. package/lib/builders/document-builder.d.ts +381 -0
  9. package/lib/builders/document-builder.js +770 -0
  10. package/lib/builders/index.d.ts +13 -0
  11. package/lib/builders/index.js +13 -0
  12. package/lib/builders/metadata-builder.d.ts +201 -0
  13. package/lib/builders/metadata-builder.js +285 -0
  14. package/lib/builders/pdf-builder.d.ts +216 -0
  15. package/lib/builders/pdf-builder.js +350 -0
  16. package/lib/builders/search-options-builder.d.ts +73 -0
  17. package/lib/builders/search-options-builder.js +129 -0
  18. package/lib/builders/streaming-table.d.ts +64 -0
  19. package/lib/builders/streaming-table.js +140 -0
  20. package/lib/document-editor-manager.d.ts +139 -0
  21. package/lib/document-editor-manager.js +256 -0
  22. package/lib/document-editor.d.ts +124 -0
  23. package/lib/document-editor.js +318 -0
  24. package/lib/errors.d.ts +382 -0
  25. package/lib/errors.js +1115 -0
  26. package/lib/form-field-manager.d.ts +299 -0
  27. package/lib/form-field-manager.js +568 -0
  28. package/lib/hybrid-ml-manager.d.ts +142 -0
  29. package/lib/hybrid-ml-manager.js +208 -0
  30. package/lib/index.d.ts +205 -0
  31. package/lib/index.js +693 -0
  32. package/lib/managers/accessibility-manager.d.ts +148 -0
  33. package/lib/managers/accessibility-manager.js +234 -0
  34. package/lib/managers/annotation-manager.d.ts +219 -0
  35. package/lib/managers/annotation-manager.js +359 -0
  36. package/lib/managers/barcode-manager.d.ts +82 -0
  37. package/lib/managers/barcode-manager.js +263 -0
  38. package/lib/managers/batch-manager.d.ts +185 -0
  39. package/lib/managers/batch-manager.js +385 -0
  40. package/lib/managers/cache-manager.d.ts +181 -0
  41. package/lib/managers/cache-manager.js +384 -0
  42. package/lib/managers/compliance-manager.d.ts +103 -0
  43. package/lib/managers/compliance-manager.js +453 -0
  44. package/lib/managers/content-manager.d.ts +120 -0
  45. package/lib/managers/content-manager.js +294 -0
  46. package/lib/managers/document-utility-manager.d.ts +369 -0
  47. package/lib/managers/document-utility-manager.js +730 -0
  48. package/lib/managers/dom-pdf-creator.d.ts +104 -0
  49. package/lib/managers/dom-pdf-creator.js +299 -0
  50. package/lib/managers/editing-manager.d.ts +248 -0
  51. package/lib/managers/editing-manager.js +387 -0
  52. package/lib/managers/enterprise-manager.d.ts +192 -0
  53. package/lib/managers/enterprise-manager.js +307 -0
  54. package/lib/managers/extended-managers.d.ts +122 -0
  55. package/lib/managers/extended-managers.js +664 -0
  56. package/lib/managers/extraction-manager.d.ts +246 -0
  57. package/lib/managers/extraction-manager.js +482 -0
  58. package/lib/managers/final-utilities.d.ts +127 -0
  59. package/lib/managers/final-utilities.js +657 -0
  60. package/lib/managers/hybrid-ml-advanced.d.ts +136 -0
  61. package/lib/managers/hybrid-ml-advanced.js +722 -0
  62. package/lib/managers/index.d.ts +64 -0
  63. package/lib/managers/index.js +69 -0
  64. package/lib/managers/layer-manager.d.ts +203 -0
  65. package/lib/managers/layer-manager.js +401 -0
  66. package/lib/managers/metadata-manager.d.ts +148 -0
  67. package/lib/managers/metadata-manager.js +280 -0
  68. package/lib/managers/ocr-manager.d.ts +194 -0
  69. package/lib/managers/ocr-manager.js +582 -0
  70. package/lib/managers/optimization-manager.d.ts +102 -0
  71. package/lib/managers/optimization-manager.js +213 -0
  72. package/lib/managers/outline-manager.d.ts +101 -0
  73. package/lib/managers/outline-manager.js +169 -0
  74. package/lib/managers/page-manager.d.ts +142 -0
  75. package/lib/managers/page-manager.js +235 -0
  76. package/lib/managers/pattern-detection.d.ts +169 -0
  77. package/lib/managers/pattern-detection.js +322 -0
  78. package/lib/managers/rendering-manager.d.ts +353 -0
  79. package/lib/managers/rendering-manager.js +679 -0
  80. package/lib/managers/search-manager.d.ts +235 -0
  81. package/lib/managers/search-manager.js +329 -0
  82. package/lib/managers/security-manager.d.ts +161 -0
  83. package/lib/managers/security-manager.js +292 -0
  84. package/lib/managers/signature-manager.d.ts +738 -0
  85. package/lib/managers/signature-manager.js +1509 -0
  86. package/lib/managers/streams.d.ts +262 -0
  87. package/lib/managers/streams.js +477 -0
  88. package/lib/managers/xfa-manager.d.ts +227 -0
  89. package/lib/managers/xfa-manager.js +539 -0
  90. package/lib/native-loader.d.ts +7 -0
  91. package/lib/native-loader.js +62 -0
  92. package/lib/native.d.ts +16 -0
  93. package/lib/native.js +69 -0
  94. package/lib/pdf-creator-manager.d.ts +200 -0
  95. package/lib/pdf-creator-manager.js +381 -0
  96. package/lib/properties.d.ts +79 -0
  97. package/lib/properties.js +454 -0
  98. package/lib/result-accessors-manager.d.ts +346 -0
  99. package/lib/result-accessors-manager.js +706 -0
  100. package/lib/thumbnail-manager.d.ts +121 -0
  101. package/lib/thumbnail-manager.js +205 -0
  102. package/lib/timestamp.d.ts +54 -0
  103. package/lib/timestamp.js +115 -0
  104. package/lib/tsa-client.d.ts +44 -0
  105. package/lib/tsa-client.js +67 -0
  106. package/lib/types/common.d.ts +189 -0
  107. package/lib/types/common.js +17 -0
  108. package/lib/types/document-types.d.ts +352 -0
  109. package/lib/types/document-types.js +82 -0
  110. package/lib/types/index.d.ts +5 -0
  111. package/lib/types/index.js +5 -0
  112. package/lib/types/manager-types.d.ts +179 -0
  113. package/lib/types/manager-types.js +100 -0
  114. package/lib/types/native-bindings.d.ts +439 -0
  115. package/lib/types/native-bindings.js +7 -0
  116. package/lib/workers/index.d.ts +6 -0
  117. package/lib/workers/index.js +5 -0
  118. package/lib/workers/pool.d.ts +64 -0
  119. package/lib/workers/pool.js +192 -0
  120. package/lib/workers/worker.d.ts +5 -0
  121. package/lib/workers/worker.js +99 -0
  122. package/package.json +79 -0
  123. package/prebuilds/darwin-arm64/pdf_oxide.node +0 -0
  124. package/prebuilds/darwin-x64/pdf_oxide.node +0 -0
  125. package/prebuilds/linux-arm64/pdf_oxide.node +0 -0
  126. package/prebuilds/linux-x64/pdf_oxide.node +0 -0
  127. package/prebuilds/win32-x64/pdf_oxide.node +0 -0
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Fluent builder for creating PDF documents with configuration
3
+ *
4
+ * Provides a fluent API for configuring PDF document metadata and options
5
+ * before document creation.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { PdfBuilder } from 'pdf_oxide';
10
+ *
11
+ * const pdf = PdfBuilder.create()
12
+ * .title('My Document')
13
+ * .author('John Doe')
14
+ * .subject('PDF Creation')
15
+ * .keywords(['pdf', 'document', 'example'])
16
+ * .fromMarkdown('# Content\n\nMarkdown text here');
17
+ *
18
+ * pdf.save('output.pdf');
19
+ * ```
20
+ */
21
+ export declare class PdfBuilder {
22
+ private _title?;
23
+ private _author?;
24
+ private _subject?;
25
+ private _keywords;
26
+ private _pageSize?;
27
+ private _margins;
28
+ /**
29
+ * Creates a new PdfBuilder instance
30
+ * @private
31
+ */
32
+ private constructor();
33
+ /**
34
+ * Creates a new PdfBuilder instance
35
+ * @returns New builder instance
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const builder = PdfBuilder.create();
40
+ * ```
41
+ */
42
+ static create(): PdfBuilder;
43
+ /**
44
+ * Sets the document title
45
+ * @param title - The document title
46
+ * @returns This builder for chaining
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * builder.title('My Document Title');
51
+ * ```
52
+ */
53
+ title(title: string): this;
54
+ /**
55
+ * Sets the document author
56
+ * @param author - The author name
57
+ * @returns This builder for chaining
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * builder.author('Jane Doe');
62
+ * ```
63
+ */
64
+ author(author: string): this;
65
+ /**
66
+ * Sets the document subject
67
+ * @param subject - The document subject
68
+ * @returns This builder for chaining
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * builder.subject('Technical Documentation');
73
+ * ```
74
+ */
75
+ subject(subject: string): this;
76
+ /**
77
+ * Sets the document keywords
78
+ * @param keywords - Array of keywords
79
+ * @returns This builder for chaining
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * builder.keywords(['PDF', 'Document', 'Generation']);
84
+ * ```
85
+ */
86
+ keywords(keywords: string[]): this;
87
+ /**
88
+ * Adds a single keyword to the document
89
+ * @param keyword - A keyword to add
90
+ * @returns This builder for chaining
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * builder.addKeyword('Important').addKeyword('Urgent');
95
+ * ```
96
+ */
97
+ addKeyword(keyword: string): this;
98
+ /**
99
+ * Sets the default page size
100
+ * @param pageSize - Page size name (e.g., 'Letter', 'A4', 'Legal')
101
+ * @returns This builder for chaining
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * builder.pageSize('A4');
106
+ * ```
107
+ */
108
+ pageSize(pageSize: string): this;
109
+ /**
110
+ * Sets page margins
111
+ * @param top - Top margin in points
112
+ * @param right - Right margin in points
113
+ * @param bottom - Bottom margin in points
114
+ * @param left - Left margin in points
115
+ * @returns This builder for chaining
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * builder.margins(36, 36, 36, 36); // 0.5 inches on all sides
120
+ * ```
121
+ */
122
+ margins(top: number, right: number, bottom: number, left: number): this;
123
+ /**
124
+ * Creates a PDF document from Markdown content
125
+ * @param markdown - Markdown formatted content
126
+ * @returns The created PDF document
127
+ * @throws PdfError if PDF creation fails
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const pdf = builder.fromMarkdown('# Title\n\nContent here');
132
+ * ```
133
+ */
134
+ fromMarkdown(markdown: string): any;
135
+ /**
136
+ * Creates a PDF document from HTML content
137
+ * @param html - HTML formatted content
138
+ * @returns The created PDF document
139
+ * @throws PdfError if PDF creation fails
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const pdf = builder.fromHtml('<h1>Title</h1><p>Content</p>');
144
+ * ```
145
+ */
146
+ fromHtml(html: string): any;
147
+ /**
148
+ * Creates a PDF document from plain text content
149
+ * @param text - Plain text content
150
+ * @returns The created PDF document
151
+ * @throws PdfError if PDF creation fails
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const pdf = builder.fromText('Plain text content');
156
+ * ```
157
+ */
158
+ fromText(text: string): any;
159
+ fromHtmlCss(html: string, css: string, fontBytes: Buffer | Uint8Array): any;
160
+ fromHtmlCssWithFonts(html: string, css: string, families: string[], fonts: (Buffer | Uint8Array)[]): any;
161
+ /**
162
+ * Asynchronously creates a PDF document from Markdown content
163
+ * @param markdown - Markdown formatted content
164
+ * @returns Promise that resolves to the created PDF document
165
+ * @throws PdfError if PDF creation fails
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * const pdf = await builder.fromMarkdownAsync('# Title\n\nContent');
170
+ * ```
171
+ */
172
+ fromMarkdownAsync(markdown: string): Promise<any>;
173
+ /**
174
+ * Asynchronously creates a PDF document from HTML content
175
+ * @param html - HTML formatted content
176
+ * @returns Promise that resolves to the created PDF document
177
+ * @throws PdfError if PDF creation fails
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const pdf = await builder.fromHtmlAsync('<h1>Title</h1>');
182
+ * ```
183
+ */
184
+ fromHtmlAsync(html: string): Promise<any>;
185
+ /**
186
+ * Asynchronously creates a PDF document from plain text content
187
+ * @param text - Plain text content
188
+ * @returns Promise that resolves to the created PDF document
189
+ * @throws PdfError if PDF creation fails
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * const pdf = await builder.fromTextAsync('Plain text');
194
+ * ```
195
+ */
196
+ fromTextAsync(text: string): Promise<any>;
197
+ /**
198
+ * Gets the current configuration as a plain object
199
+ * @returns Configuration object with title, author, subject, keywords
200
+ *
201
+ * @private
202
+ */
203
+ private _getConfiguration;
204
+ /**
205
+ * Applies builder configuration to a PDF document
206
+ * @param pdf - The PDF document to configure
207
+ * @private
208
+ */
209
+ private _applyConfiguration;
210
+ }
211
+ /**
212
+ * Create a new PdfBuilder with static factory
213
+ * @deprecated Use PdfBuilder.create() instead
214
+ * @returns New builder instance
215
+ */
216
+ export declare function createPdfBuilder(): PdfBuilder;
@@ -0,0 +1,350 @@
1
+ /**
2
+ * Fluent builder for creating PDF documents with configuration
3
+ *
4
+ * Provides a fluent API for configuring PDF document metadata and options
5
+ * before document creation.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { PdfBuilder } from 'pdf_oxide';
10
+ *
11
+ * const pdf = PdfBuilder.create()
12
+ * .title('My Document')
13
+ * .author('John Doe')
14
+ * .subject('PDF Creation')
15
+ * .keywords(['pdf', 'document', 'example'])
16
+ * .fromMarkdown('# Content\n\nMarkdown text here');
17
+ *
18
+ * pdf.save('output.pdf');
19
+ * ```
20
+ */
21
+ export class PdfBuilder {
22
+ /**
23
+ * Creates a new PdfBuilder instance
24
+ * @private
25
+ */
26
+ constructor() {
27
+ this._keywords = [];
28
+ this._margins = {
29
+ top: 36,
30
+ bottom: 36,
31
+ left: 36,
32
+ right: 36,
33
+ };
34
+ }
35
+ /**
36
+ * Creates a new PdfBuilder instance
37
+ * @returns New builder instance
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const builder = PdfBuilder.create();
42
+ * ```
43
+ */
44
+ static create() {
45
+ return new PdfBuilder();
46
+ }
47
+ /**
48
+ * Sets the document title
49
+ * @param title - The document title
50
+ * @returns This builder for chaining
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * builder.title('My Document Title');
55
+ * ```
56
+ */
57
+ title(title) {
58
+ if (typeof title !== 'string' || title.length === 0) {
59
+ throw new Error('Title must be a non-empty string');
60
+ }
61
+ this._title = title;
62
+ return this;
63
+ }
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) {
75
+ if (typeof author !== 'string' || author.length === 0) {
76
+ throw new Error('Author must be a non-empty string');
77
+ }
78
+ this._author = author;
79
+ return this;
80
+ }
81
+ /**
82
+ * Sets the document subject
83
+ * @param subject - The document subject
84
+ * @returns This builder for chaining
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * builder.subject('Technical Documentation');
89
+ * ```
90
+ */
91
+ subject(subject) {
92
+ if (typeof subject !== 'string' || subject.length === 0) {
93
+ throw new Error('Subject must be a non-empty string');
94
+ }
95
+ this._subject = subject;
96
+ return this;
97
+ }
98
+ /**
99
+ * Sets the document keywords
100
+ * @param keywords - Array of keywords
101
+ * @returns This builder for chaining
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * builder.keywords(['PDF', 'Document', 'Generation']);
106
+ * ```
107
+ */
108
+ keywords(keywords) {
109
+ if (!Array.isArray(keywords)) {
110
+ throw new Error('Keywords must be an array');
111
+ }
112
+ if (!keywords.every((k) => typeof k === 'string')) {
113
+ throw new Error('All keywords must be strings');
114
+ }
115
+ this._keywords = keywords;
116
+ return this;
117
+ }
118
+ /**
119
+ * Adds a single keyword to the document
120
+ * @param keyword - A keyword to add
121
+ * @returns This builder for chaining
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * builder.addKeyword('Important').addKeyword('Urgent');
126
+ * ```
127
+ */
128
+ addKeyword(keyword) {
129
+ if (typeof keyword !== 'string' || keyword.length === 0) {
130
+ throw new Error('Keyword must be a non-empty string');
131
+ }
132
+ this._keywords.push(keyword);
133
+ return this;
134
+ }
135
+ /**
136
+ * Sets the default page size
137
+ * @param pageSize - Page size name (e.g., 'Letter', 'A4', 'Legal')
138
+ * @returns This builder for chaining
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * builder.pageSize('A4');
143
+ * ```
144
+ */
145
+ pageSize(pageSize) {
146
+ const validSizes = ['Letter', 'Legal', 'A4', 'A3', 'A5', 'B4', 'B5'];
147
+ if (!validSizes.includes(pageSize)) {
148
+ throw new Error(`Invalid page size. Must be one of: ${validSizes.join(', ')}`);
149
+ }
150
+ this._pageSize = pageSize;
151
+ return this;
152
+ }
153
+ /**
154
+ * Sets page margins
155
+ * @param top - Top margin in points
156
+ * @param right - Right margin in points
157
+ * @param bottom - Bottom margin in points
158
+ * @param left - Left margin in points
159
+ * @returns This builder for chaining
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * builder.margins(36, 36, 36, 36); // 0.5 inches on all sides
164
+ * ```
165
+ */
166
+ margins(top, right, bottom, left) {
167
+ if (![top, right, bottom, left].every((m) => typeof m === 'number' && m >= 0)) {
168
+ throw new Error('All margins must be non-negative numbers');
169
+ }
170
+ this._margins = { top, right, bottom, left };
171
+ return this;
172
+ }
173
+ /**
174
+ * Creates a PDF document from Markdown content
175
+ * @param markdown - Markdown formatted content
176
+ * @returns The created PDF document
177
+ * @throws PdfError if PDF creation fails
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const pdf = builder.fromMarkdown('# Title\n\nContent here');
182
+ * ```
183
+ */
184
+ fromMarkdown(markdown) {
185
+ // Note: Using any for Pdf type to avoid circular dependency
186
+ const { Pdf } = require('../index.js');
187
+ if (typeof markdown !== 'string') {
188
+ throw new Error('Markdown must be a string');
189
+ }
190
+ const pdf = Pdf.fromMarkdown(markdown);
191
+ this._applyConfiguration(pdf);
192
+ return pdf;
193
+ }
194
+ /**
195
+ * Creates a PDF document from HTML content
196
+ * @param html - HTML formatted content
197
+ * @returns The created PDF document
198
+ * @throws PdfError if PDF creation fails
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const pdf = builder.fromHtml('<h1>Title</h1><p>Content</p>');
203
+ * ```
204
+ */
205
+ fromHtml(html) {
206
+ const { Pdf } = require('../index.js');
207
+ if (typeof html !== 'string') {
208
+ throw new Error('HTML must be a string');
209
+ }
210
+ const pdf = Pdf.fromHtml(html);
211
+ this._applyConfiguration(pdf);
212
+ return pdf;
213
+ }
214
+ /**
215
+ * Creates a PDF document from plain text content
216
+ * @param text - Plain text content
217
+ * @returns The created PDF document
218
+ * @throws PdfError if PDF creation fails
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * const pdf = builder.fromText('Plain text content');
223
+ * ```
224
+ */
225
+ fromText(text) {
226
+ const { Pdf } = require('../index.js');
227
+ if (typeof text !== 'string') {
228
+ throw new Error('Text must be a string');
229
+ }
230
+ const pdf = Pdf.fromText(text);
231
+ this._applyConfiguration(pdf);
232
+ return pdf;
233
+ }
234
+ fromHtmlCss(html, css, fontBytes) {
235
+ const { Pdf } = require('../index.js');
236
+ const pdf = Pdf.fromHtmlCss(html, css, fontBytes);
237
+ this._applyConfiguration(pdf);
238
+ return pdf;
239
+ }
240
+ fromHtmlCssWithFonts(html, css, families, fonts) {
241
+ const { Pdf } = require('../index.js');
242
+ const pdf = Pdf.fromHtmlCssWithFonts(html, css, families, fonts);
243
+ this._applyConfiguration(pdf);
244
+ return pdf;
245
+ }
246
+ /**
247
+ * Asynchronously creates a PDF document from Markdown content
248
+ * @param markdown - Markdown formatted content
249
+ * @returns Promise that resolves to the created PDF document
250
+ * @throws PdfError if PDF creation fails
251
+ *
252
+ * @example
253
+ * ```typescript
254
+ * const pdf = await builder.fromMarkdownAsync('# Title\n\nContent');
255
+ * ```
256
+ */
257
+ async fromMarkdownAsync(markdown) {
258
+ const { Pdf } = require('../index.js');
259
+ if (typeof markdown !== 'string') {
260
+ throw new Error('Markdown must be a string');
261
+ }
262
+ const pdf = await Pdf.fromMarkdownAsync(markdown);
263
+ this._applyConfiguration(pdf);
264
+ return pdf;
265
+ }
266
+ /**
267
+ * Asynchronously creates a PDF document from HTML content
268
+ * @param html - HTML formatted content
269
+ * @returns Promise that resolves to the created PDF document
270
+ * @throws PdfError if PDF creation fails
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const pdf = await builder.fromHtmlAsync('<h1>Title</h1>');
275
+ * ```
276
+ */
277
+ async fromHtmlAsync(html) {
278
+ const { Pdf } = require('../index.js');
279
+ if (typeof html !== 'string') {
280
+ throw new Error('HTML must be a string');
281
+ }
282
+ const pdf = await Pdf.fromHtmlAsync(html);
283
+ this._applyConfiguration(pdf);
284
+ return pdf;
285
+ }
286
+ /**
287
+ * Asynchronously creates a PDF document from plain text content
288
+ * @param text - Plain text content
289
+ * @returns Promise that resolves to the created PDF document
290
+ * @throws PdfError if PDF creation fails
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * const pdf = await builder.fromTextAsync('Plain text');
295
+ * ```
296
+ */
297
+ async fromTextAsync(text) {
298
+ const { Pdf } = require('../index.js');
299
+ if (typeof text !== 'string') {
300
+ throw new Error('Text must be a string');
301
+ }
302
+ const pdf = await Pdf.fromTextAsync(text);
303
+ this._applyConfiguration(pdf);
304
+ return pdf;
305
+ }
306
+ /**
307
+ * Gets the current configuration as a plain object
308
+ * @returns Configuration object with title, author, subject, keywords
309
+ *
310
+ * @private
311
+ */
312
+ _getConfiguration() {
313
+ return {
314
+ title: this._title,
315
+ author: this._author,
316
+ subject: this._subject,
317
+ keywords: this._keywords,
318
+ pageSize: this._pageSize,
319
+ margins: this._margins,
320
+ };
321
+ }
322
+ /**
323
+ * Applies builder configuration to a PDF document
324
+ * @param pdf - The PDF document to configure
325
+ * @private
326
+ */
327
+ _applyConfiguration(pdf) {
328
+ // Apply metadata properties if set
329
+ if (this._title !== undefined) {
330
+ pdf.title = this._title;
331
+ }
332
+ if (this._author !== undefined) {
333
+ pdf.author = this._author;
334
+ }
335
+ if (this._subject !== undefined) {
336
+ pdf.subject = this._subject;
337
+ }
338
+ if (this._keywords.length > 0) {
339
+ pdf.keywords = [...this._keywords];
340
+ }
341
+ }
342
+ }
343
+ /**
344
+ * Create a new PdfBuilder with static factory
345
+ * @deprecated Use PdfBuilder.create() instead
346
+ * @returns New builder instance
347
+ */
348
+ export function createPdfBuilder() {
349
+ return PdfBuilder.create();
350
+ }
@@ -0,0 +1,73 @@
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 interface SearchOptions {
21
+ caseSensitive: boolean;
22
+ wholeWords: boolean;
23
+ useRegex: boolean;
24
+ ignoreAccents: boolean;
25
+ maxResults: number;
26
+ searchAnnotations: boolean;
27
+ }
28
+ export declare class SearchOptionsBuilder {
29
+ private _caseSensitive;
30
+ private _wholeWords;
31
+ private _useRegex;
32
+ private _ignoreAccents;
33
+ private _maxResults;
34
+ private _searchAnnotations;
35
+ /**
36
+ * Creates a new SearchOptionsBuilder instance
37
+ * @private
38
+ */
39
+ private constructor();
40
+ /**
41
+ * Creates a new SearchOptionsBuilder instance
42
+ * @returns New builder instance
43
+ */
44
+ static create(): SearchOptionsBuilder;
45
+ /**
46
+ * Creates options with default search settings (case-insensitive, no regex)
47
+ * @returns Search options with default preset
48
+ */
49
+ static default(): SearchOptions;
50
+ /**
51
+ * Creates options with strict search settings (case-sensitive, whole words, no regex)
52
+ * @returns Search options with strict preset
53
+ */
54
+ static strict(): SearchOptions;
55
+ /**
56
+ * Creates options with regex search settings
57
+ * @returns Search options with regex preset
58
+ */
59
+ static regex(): SearchOptions;
60
+ caseSensitive(sensitive: boolean): this;
61
+ wholeWords(wholeOnly: boolean): this;
62
+ useRegex(regex: boolean): this;
63
+ ignoreAccents(ignore: boolean): this;
64
+ maxResults(max: number): this;
65
+ searchAnnotations(search: boolean): this;
66
+ build(): SearchOptions;
67
+ }
68
+ /**
69
+ * Create a new SearchOptionsBuilder with static factory
70
+ * @deprecated Use SearchOptionsBuilder.create() instead
71
+ * @returns New builder instance
72
+ */
73
+ export declare function createSearchOptionsBuilder(): SearchOptionsBuilder;