@lexmata/micropdf 0.4.0 → 0.5.0

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.
@@ -1,226 +1,602 @@
1
1
  /**
2
- * Enhanced - MicroPDF high-level convenience API
2
+ * Enhanced MicroPDF Functions (mp_* prefix)
3
3
  *
4
- * This module provides MicroPDF-specific high-level functions for common PDF operations.
5
- * These are convenience wrappers that simplify complex workflows and provide a more
6
- * user-friendly API for common tasks.
7
- *
8
- * The Enhanced API includes operations like:
9
- * - Adding blank pages
10
- * - Adding watermarks
11
- * - Drawing shapes (rectangles, circles, lines)
12
- * - Merging and splitting PDFs
13
- * - Optimizing and linearizing PDFs
14
- *
15
- * @module enhanced
16
- * @example
17
- * ```typescript
18
- * import { Enhanced, Document } from 'micropdf';
19
- *
20
- * const enhanced = new Enhanced();
21
- * const doc = Document.open('document.pdf');
22
- *
23
- * // Add a blank page
24
- * enhanced.addBlankPage(doc, 612, 792); // US Letter size
25
- *
26
- * // Add a watermark
27
- * enhanced.addWatermark(
28
- * doc,
29
- * 'CONFIDENTIAL',
30
- * { x: 300, y: 400 },
31
- * 12,
32
- * 0.3 // 30% opacity
33
- * );
34
- *
35
- * // Draw shapes
36
- * enhanced.drawRectangle(
37
- * doc,
38
- * 0, // page index
39
- * { x0: 100, y0: 100, x1: 200, y1: 200 },
40
- * [255, 0, 0], // red
41
- * 0.5, // opacity
42
- * 2, // line width
43
- * true // fill
44
- * );
45
- *
46
- * // Save
47
- * doc.save('output.pdf');
48
- * doc.close();
49
- * ```
50
- *
51
- * @example
52
- * ```typescript
53
- * // Merge multiple PDFs
54
- * const enhanced = new Enhanced();
55
- * enhanced.mergePdfs(
56
- * ['doc1.pdf', 'doc2.pdf', 'doc3.pdf'],
57
- * 'merged.pdf'
58
- * );
59
- *
60
- * // Split a PDF
61
- * enhanced.splitPdf(
62
- * 'document.pdf',
63
- * 'output-dir',
64
- * { startPage: 0, endPage: 10 }
65
- * );
66
- *
67
- * // Optimize a PDF
68
- * enhanced.optimizePdf('large.pdf', 'optimized.pdf');
69
- *
70
- * // Linearize for web viewing
71
- * enhanced.linearizePdf('document.pdf', 'web-optimized.pdf');
72
- * ```
4
+ * This module provides TypeScript bindings for all 120+ enhanced MicroPDF
5
+ * functions including:
6
+ * - Print Production (N-Up, Booklet, Poster)
7
+ * - Digital Signatures & Encryption
8
+ * - HTML to PDF Conversion
9
+ * - Document Composition (Platypus-like)
10
+ * - PDF Validation & Repair
73
11
  */
74
- import { Context } from './context.js';
75
- import { Document } from './document.js';
76
- import { type ColorLike } from './geometry.js';
12
+ import type { NativeContext, NativeDocument, NativePage } from './native.js';
13
+ /** Page size presets */
14
+ export declare enum PageSize {
15
+ A4 = 0,
16
+ Letter = 1,
17
+ Legal = 2,
18
+ A3 = 3,
19
+ A5 = 4,
20
+ B4 = 5,
21
+ B5 = 6,
22
+ Executive = 7,
23
+ Ledger = 8,
24
+ Tabloid = 9
25
+ }
26
+ /** Binding methods for booklet creation */
27
+ export declare enum BindingMethod {
28
+ SaddleStitch = 0,
29
+ PerfectBinding = 1,
30
+ SideStitch = 2,
31
+ WireO = 3,
32
+ CaseBinding = 4
33
+ }
34
+ /** Page box types */
35
+ export declare enum PageBoxType {
36
+ MediaBox = 0,
37
+ CropBox = 1,
38
+ BleedBox = 2,
39
+ TrimBox = 3,
40
+ ArtBox = 4
41
+ }
42
+ /** Unit types for measurements */
43
+ export declare enum Unit {
44
+ Points = 0,
45
+ Millimeters = 1,
46
+ Inches = 2,
47
+ Centimeters = 3
48
+ }
49
+ /** Encryption algorithms */
50
+ export declare enum EncryptionAlgorithm {
51
+ RC4_40 = 0,
52
+ RC4_128 = 1,
53
+ AES_128 = 2,
54
+ AES_256 = 3
55
+ }
56
+ /** Document permissions */
57
+ export declare enum DocumentPermission {
58
+ Print = 4,
59
+ ModifyContents = 8,
60
+ Copy = 16,
61
+ ModifyAnnotations = 32,
62
+ FillForms = 256,
63
+ ExtractForAccessibility = 512,
64
+ Assemble = 1024,
65
+ PrintHighQuality = 2048
66
+ }
67
+ /** Text alignment */
68
+ export declare enum TextAlign {
69
+ Left = 0,
70
+ Center = 1,
71
+ Right = 2,
72
+ Justify = 3
73
+ }
74
+ /** Validation modes */
75
+ export declare enum ValidationMode {
76
+ Quick = 0,
77
+ Standard = 1,
78
+ Strict = 2
79
+ }
80
+ export interface EncryptionOptions {
81
+ _handle: number;
82
+ }
83
+ export interface Certificate {
84
+ _handle: number;
85
+ }
86
+ export interface SignatureVerifyResult {
87
+ valid: boolean;
88
+ signerName?: string;
89
+ signedAt?: Date;
90
+ reason?: string;
91
+ location?: string;
92
+ modifiedAfterSigning: boolean;
93
+ }
94
+ export interface HtmlOptions {
95
+ _handle: number;
96
+ }
97
+ export interface DocTemplate {
98
+ _handle: number;
99
+ }
100
+ export interface Frame {
101
+ _handle: number;
102
+ }
103
+ export interface ParagraphStyle {
104
+ _handle: number;
105
+ }
106
+ export interface StyleSheet {
107
+ _handle: number;
108
+ }
109
+ export interface Paragraph {
110
+ _handle: number;
111
+ }
112
+ export interface Spacer {
113
+ _handle: number;
114
+ }
115
+ export interface HorizontalRule {
116
+ _handle: number;
117
+ }
118
+ export interface Image {
119
+ _handle: number;
120
+ }
121
+ export interface ListItem {
122
+ _handle: number;
123
+ }
124
+ export interface Table {
125
+ _handle: number;
126
+ }
127
+ export interface TableStyle {
128
+ _handle: number;
129
+ }
130
+ export interface TableOfContents {
131
+ _handle: number;
132
+ }
133
+ export interface TocBuilder {
134
+ _handle: number;
135
+ }
136
+ export interface Story {
137
+ _handle: number;
138
+ }
139
+ export interface PageBoxManager {
140
+ _handle: number;
141
+ }
142
+ export interface ValidationResult {
143
+ valid: boolean;
144
+ errors: string[];
145
+ warnings: string[];
146
+ }
147
+ export interface Rectangle {
148
+ llx: number;
149
+ lly: number;
150
+ urx: number;
151
+ ury: number;
152
+ }
77
153
  /**
78
- * Enhanced MicroPDF API for high-level PDF operations.
79
- *
80
- * Provides convenient methods for common PDF manipulation tasks that would
81
- * otherwise require multiple lower-level API calls.
82
- *
83
- * @class Enhanced
84
- * @example
85
- * ```typescript
86
- * const enhanced = new Enhanced();
87
- * const doc = Document.open('document.pdf');
88
- *
89
- * // Add a watermark to all pages
90
- * for (let i = 0; i < doc.pageCount; i++) {
91
- * enhanced.addWatermark(
92
- * doc,
93
- * 'DRAFT',
94
- * { x: 300, y: 400 },
95
- * 48,
96
- * 0.2
97
- * );
98
- * }
99
- *
100
- * doc.save('watermarked.pdf');
101
- * doc.close();
102
- * ```
103
- */
104
- export declare class Enhanced {
105
- private _ctx;
106
- constructor(ctx?: Context);
107
- /**
108
- * Get the context
109
- */
110
- get context(): Context;
111
- /**
112
- * Add a blank page to a document using FFI
113
- * @returns Page number of newly added page
114
- * @throws Error when native bindings are not available
115
- */
116
- addBlankPage(_doc: Document, width: number, height: number): number;
117
- /**
118
- * Draw a line on a page using FFI
119
- * @throws Error when native bindings are not available
120
- */
121
- drawLine(page: unknown, x0: number, y0: number, x1: number, y1: number, color: ColorLike, alpha?: number, lineWidth?: number): void;
122
- /**
123
- * Draw a rectangle on a page using FFI
124
- * @throws Error when native bindings are not available
125
- */
126
- drawRectangle(page: unknown, x: number, y: number, width: number, height: number, color: ColorLike, alpha?: number, fill?: boolean): void;
127
- /**
128
- * Draw a circle on a page using FFI
129
- * @throws Error when native bindings are not available
130
- */
131
- drawCircle(page: unknown, x: number, y: number, radius: number, color: ColorLike, alpha?: number, fill?: boolean): void;
132
- /**
133
- * Add watermark to PDF using FFI
134
- * @throws Error when native bindings are not available
135
- */
136
- addWatermark(inputPath: string, _outputPath: string, text: string, _x?: number, _y?: number, fontSize?: number, opacity?: number): Promise<void>;
137
- /**
138
- * Merge multiple PDFs into one using FFI
139
- * @throws Error when native bindings are not available
140
- */
141
- mergePDFs(inputPaths: string[], outputPath: string): Promise<void>;
142
- /**
143
- * Split PDF into separate files using FFI
144
- * @returns Array of output file paths
145
- * @throws Error when native bindings are not available
146
- */
147
- splitPDF(inputPath: string, outputDir: string): Promise<string[]>;
148
- /**
149
- * Optimize PDF (compress, remove unused objects) using FFI
150
- * @throws Error when native bindings are not available
151
- */
152
- optimizePDF(path: string): Promise<void>;
153
- /**
154
- * Linearize PDF for fast web viewing using FFI
155
- * @throws Error when native bindings are not available
156
- */
157
- linearizePDF(inputPath: string, outputPath: string): Promise<void>;
158
- /**
159
- * Write document to PDF file using FFI
160
- * @throws Error when native bindings are not available
161
- */
162
- writePDF(doc: Document, path: string): Promise<void>;
163
- /**
164
- * Merge multiple PDF files into a single output file
165
- *
166
- * @param inputPaths Array of PDF file paths to merge (in order)
167
- * @param outputPath Path where the merged PDF will be saved
168
- * @returns Promise that resolves to the number of pages in the merged PDF
169
- * @throws Error if any input file is invalid, not found, or merge fails
170
- * @throws Error when native bindings are not available
171
- *
172
- * @example
173
- * ```typescript
174
- * import { Enhanced } from 'micropdf';
175
- *
176
- * const enhanced = new Enhanced();
177
- * const pageCount = await enhanced.mergePDF(
178
- * ['document1.pdf', 'document2.pdf', 'document3.pdf'],
179
- * 'merged.pdf'
180
- * );
181
- * console.log(`Merged ${pageCount} pages`);
182
- * ```
183
- *
184
- * @example Large document handling
185
- * ```typescript
186
- * // Works with large documents (5000+ pages)
187
- * const pageCount = await enhanced.mergePDF(
188
- * ['large_doc1.pdf', 'large_doc2.pdf'],
189
- * 'combined.pdf'
190
- * );
191
- * ```
192
- */
193
- mergePDF(inputPaths: string[], outputPath: string): Promise<number>;
194
- /**
195
- * Create a new blank PDF document
196
- * @param width Page width in points (default A4 width: 595)
197
- * @param height Page height in points (default A4 height: 842)
198
- * @throws Error This is a static method that requires instance context
199
- */
200
- static createBlankDocument(_width?: number, _height?: number): Document;
201
- /**
202
- * Quick create PDF with text
203
- * @throws Error This is a static method that requires instance context
204
- */
205
- static createTextPDF(_text: string, _outputPath: string, _options?: {
206
- fontSize?: number;
207
- fontName?: string;
208
- pageWidth?: number;
209
- pageHeight?: number;
210
- }): Promise<void>;
211
- }
212
- /**
213
- * Get global enhanced API
214
- */
215
- export declare function getEnhanced(): Enhanced;
216
- /**
217
- * Convenience functions (use global instance)
218
- */
219
- export declare function addWatermark(inputPath: string, outputPath: string, text: string, x?: number, y?: number, fontSize?: number, opacity?: number): Promise<void>;
220
- export declare function mergePDFs(inputPaths: string[], outputPath: string): Promise<void>;
221
- export declare function splitPDF(inputPath: string, outputDir: string): Promise<string[]>;
222
- export declare function optimizePDF(path: string): Promise<void>;
223
- export declare function linearizePDF(inputPath: string, outputPath: string): Promise<void>;
224
- export declare function createBlankDocument(width?: number, height?: number): Document;
225
- export declare function createTextPDF(text: string, outputPath: string, options?: Parameters<typeof Enhanced.createTextPDF>[2]): Promise<void>;
154
+ * Create a 2-up layout (2 pages per sheet)
155
+ */
156
+ export declare function create2Up(inputPath: string, outputPath: string, pageSize?: PageSize): void;
157
+ /**
158
+ * Create a 4-up layout (4 pages per sheet)
159
+ */
160
+ export declare function create4Up(inputPath: string, outputPath: string, pageSize?: PageSize): void;
161
+ /**
162
+ * Create a 9-up layout (9 pages per sheet)
163
+ */
164
+ export declare function create9Up(inputPath: string, outputPath: string, pageSize?: PageSize): void;
165
+ /**
166
+ * Create a custom N-up layout
167
+ */
168
+ export declare function createNup(inputPath: string, outputPath: string, cols: number, rows: number, pageSize?: PageSize): void;
169
+ /**
170
+ * Create a booklet for printing
171
+ */
172
+ export declare function createBooklet(inputPath: string, outputPath: string, bindingType?: BindingMethod, pageSize?: PageSize, addBlanks?: boolean): void;
173
+ /**
174
+ * Create a saddle-stitch booklet (simplified)
175
+ */
176
+ export declare function createSaddleStitchBooklet(inputPath: string, outputPath: string): void;
177
+ /**
178
+ * Create a poster by tiling pages
179
+ */
180
+ export declare function createPoster(inputPath: string, outputPath: string, tileSize: number, overlapMm?: number, cutMarks?: boolean): void;
181
+ /**
182
+ * Get the number of tiles for a poster
183
+ */
184
+ export declare function getPosterTileCount(pdfPath: string, tileSize: number, overlapMm?: number): number;
185
+ /**
186
+ * Create a page box manager for a PDF
187
+ */
188
+ export declare function createPageBoxManager(pdfPath: string): PageBoxManager;
189
+ /**
190
+ * Free a page box manager
191
+ */
192
+ export declare function freePageBoxManager(manager: PageBoxManager): void;
193
+ /**
194
+ * Get the page count from a page box manager
195
+ */
196
+ export declare function getPageBoxPageCount(manager: PageBoxManager): number;
197
+ /**
198
+ * Get a page box
199
+ */
200
+ export declare function getPageBox(manager: PageBoxManager, page: number, boxType: PageBoxType): Rectangle;
201
+ /**
202
+ * Set a page box
203
+ */
204
+ export declare function setPageBox(manager: PageBoxManager, page: number, boxType: PageBoxType, rect: Rectangle): void;
205
+ /**
206
+ * Add bleed to all pages
207
+ */
208
+ export declare function addBleed(manager: PageBoxManager, bleed: number, unit?: Unit): void;
209
+ /**
210
+ * Save page box changes
211
+ */
212
+ export declare function savePageBox(manager: PageBoxManager, outputPath: string): void;
213
+ /**
214
+ * Check if a PDF is encrypted
215
+ */
216
+ export declare function isEncrypted(pdfPath: string): boolean;
217
+ /**
218
+ * Create encryption options
219
+ */
220
+ export declare function createEncryptionOptions(): EncryptionOptions;
221
+ /**
222
+ * Free encryption options
223
+ */
224
+ export declare function freeEncryptionOptions(options: EncryptionOptions): void;
225
+ /**
226
+ * Set user password for encryption
227
+ */
228
+ export declare function setUserPassword(options: EncryptionOptions, password: string): void;
229
+ /**
230
+ * Set owner password for encryption
231
+ */
232
+ export declare function setOwnerPassword(options: EncryptionOptions, password: string): void;
233
+ /**
234
+ * Set document permissions
235
+ */
236
+ export declare function setPermissions(options: EncryptionOptions, permissions: number): void;
237
+ /**
238
+ * Set encryption algorithm
239
+ */
240
+ export declare function setAlgorithm(options: EncryptionOptions, algorithm: EncryptionAlgorithm): void;
241
+ /**
242
+ * Encrypt a PDF
243
+ */
244
+ export declare function encryptPdf(inputPath: string, outputPath: string, options: EncryptionOptions): void;
245
+ /**
246
+ * Decrypt a PDF
247
+ */
248
+ export declare function decryptPdf(inputPath: string, outputPath: string, password: string): void;
249
+ /**
250
+ * Load a certificate from PEM files
251
+ */
252
+ export declare function loadCertificatePem(certPath: string, keyPath: string, keyPassword?: string): Certificate;
253
+ /**
254
+ * Load a certificate from PKCS#12 file
255
+ */
256
+ export declare function loadCertificatePkcs12(path: string, password: string): Certificate;
257
+ /**
258
+ * Free a certificate
259
+ */
260
+ export declare function freeCertificate(cert: Certificate): void;
261
+ /**
262
+ * Check if a certificate is valid
263
+ */
264
+ export declare function isCertificateValid(cert: Certificate): boolean;
265
+ /**
266
+ * Get certificate subject
267
+ */
268
+ export declare function getCertificateSubject(cert: Certificate): string;
269
+ /**
270
+ * Get certificate issuer
271
+ */
272
+ export declare function getCertificateIssuer(cert: Certificate): string;
273
+ /**
274
+ * Create a digital signature with appearance
275
+ */
276
+ export declare function createSignature(inputPath: string, outputPath: string, cert: Certificate, fieldName: string, page: number, x: number, y: number, width: number, height: number, reason?: string, location?: string): void;
277
+ /**
278
+ * Create an invisible digital signature
279
+ */
280
+ export declare function createInvisibleSignature(inputPath: string, outputPath: string, cert: Certificate, fieldName: string, reason?: string, location?: string): void;
281
+ /**
282
+ * Verify a signature
283
+ */
284
+ export declare function verifySignature(pdfPath: string, fieldName: string): SignatureVerifyResult;
285
+ /**
286
+ * Count signatures in a PDF
287
+ */
288
+ export declare function countSignatures(pdfPath: string): number;
289
+ /**
290
+ * Create HTML conversion options
291
+ */
292
+ export declare function createHtmlOptions(): HtmlOptions;
293
+ /**
294
+ * Free HTML options
295
+ */
296
+ export declare function freeHtmlOptions(options: HtmlOptions): void;
297
+ /**
298
+ * Set page size for HTML conversion
299
+ */
300
+ export declare function setHtmlPageSize(options: HtmlOptions, pageSize: PageSize): void;
301
+ /**
302
+ * Set custom page size for HTML conversion
303
+ */
304
+ export declare function setHtmlCustomPageSize(options: HtmlOptions, width: number, height: number): void;
305
+ /**
306
+ * Set margins for HTML conversion
307
+ */
308
+ export declare function setHtmlMargins(options: HtmlOptions, top: number, right: number, bottom: number, left: number): void;
309
+ /**
310
+ * Set landscape mode for HTML conversion
311
+ */
312
+ export declare function setHtmlLandscape(options: HtmlOptions, landscape: boolean): void;
313
+ /**
314
+ * Set scale for HTML conversion
315
+ */
316
+ export declare function setHtmlScale(options: HtmlOptions, scale: number): void;
317
+ /**
318
+ * Set print background for HTML conversion
319
+ */
320
+ export declare function setHtmlPrintBackground(options: HtmlOptions, enabled: boolean): void;
321
+ /**
322
+ * Set header HTML
323
+ */
324
+ export declare function setHtmlHeader(options: HtmlOptions, html: string): void;
325
+ /**
326
+ * Set footer HTML
327
+ */
328
+ export declare function setHtmlFooter(options: HtmlOptions, html: string): void;
329
+ /**
330
+ * Enable/disable JavaScript
331
+ */
332
+ export declare function setHtmlJavaScript(options: HtmlOptions, enabled: boolean): void;
333
+ /**
334
+ * Set base URL for relative paths
335
+ */
336
+ export declare function setHtmlBaseUrl(options: HtmlOptions, url: string): void;
337
+ /**
338
+ * Set custom stylesheet
339
+ */
340
+ export declare function setHtmlStylesheet(options: HtmlOptions, css: string): void;
341
+ /**
342
+ * Convert HTML string to PDF
343
+ */
344
+ export declare function htmlToPdf(html: string, outputPath: string, options?: HtmlOptions): void;
345
+ /**
346
+ * Convert HTML file to PDF
347
+ */
348
+ export declare function htmlFileToPdf(htmlPath: string, outputPath: string, options?: HtmlOptions): void;
349
+ /**
350
+ * Create a document template
351
+ */
352
+ export declare function createDocTemplate(filename: string): DocTemplate;
353
+ /**
354
+ * Free a document template
355
+ */
356
+ export declare function freeDocTemplate(template: DocTemplate): void;
357
+ /**
358
+ * Set page size for document template
359
+ */
360
+ export declare function setDocTemplatePageSize(template: DocTemplate, width: number, height: number): void;
361
+ /**
362
+ * Set margins for document template
363
+ */
364
+ export declare function setDocTemplateMargins(template: DocTemplate, left: number, right: number, top: number, bottom: number): void;
365
+ /**
366
+ * Create a frame
367
+ */
368
+ export declare function createFrame(id: string, x: number, y: number, width: number, height: number): Frame;
369
+ /**
370
+ * Free a frame
371
+ */
372
+ export declare function freeFrame(frame: Frame): void;
373
+ /**
374
+ * Get frame available width
375
+ */
376
+ export declare function getFrameAvailableWidth(frame: Frame): number;
377
+ /**
378
+ * Get frame available height
379
+ */
380
+ export declare function getFrameAvailableHeight(frame: Frame): number;
381
+ /**
382
+ * Create a paragraph
383
+ */
384
+ export declare function createParagraph(text: string): Paragraph;
385
+ /**
386
+ * Free a paragraph
387
+ */
388
+ export declare function freeParagraph(paragraph: Paragraph): void;
389
+ /**
390
+ * Set paragraph font size
391
+ */
392
+ export declare function setParagraphFontSize(paragraph: Paragraph, size: number): void;
393
+ /**
394
+ * Set paragraph leading
395
+ */
396
+ export declare function setParagraphLeading(paragraph: Paragraph, leading: number): void;
397
+ /**
398
+ * Create a paragraph style
399
+ */
400
+ export declare function createParagraphStyle(name: string): ParagraphStyle;
401
+ /**
402
+ * Free a paragraph style
403
+ */
404
+ export declare function freeParagraphStyle(style: ParagraphStyle): void;
405
+ /**
406
+ * Set paragraph style font size
407
+ */
408
+ export declare function setParagraphStyleFontSize(style: ParagraphStyle, size: number): void;
409
+ /**
410
+ * Set paragraph style leading
411
+ */
412
+ export declare function setParagraphStyleLeading(style: ParagraphStyle, leading: number): void;
413
+ /**
414
+ * Set paragraph style alignment
415
+ */
416
+ export declare function setParagraphStyleAlignment(style: ParagraphStyle, align: TextAlign): void;
417
+ /**
418
+ * Create a spacer
419
+ */
420
+ export declare function createSpacer(height: number): Spacer;
421
+ /**
422
+ * Free a spacer
423
+ */
424
+ export declare function freeSpacer(spacer: Spacer): void;
425
+ /**
426
+ * Create a horizontal rule
427
+ */
428
+ export declare function createHorizontalRule(): HorizontalRule;
429
+ /**
430
+ * Free a horizontal rule
431
+ */
432
+ export declare function freeHorizontalRule(hr: HorizontalRule): void;
433
+ /**
434
+ * Set horizontal rule thickness
435
+ */
436
+ export declare function setHorizontalRuleThickness(hr: HorizontalRule, thickness: number): void;
437
+ /**
438
+ * Create an image flowable
439
+ */
440
+ export declare function createImage(path: string): Image;
441
+ /**
442
+ * Free an image
443
+ */
444
+ export declare function freeImage(image: Image): void;
445
+ /**
446
+ * Set image width
447
+ */
448
+ export declare function setImageWidth(image: Image, width: number): void;
449
+ /**
450
+ * Set image height
451
+ */
452
+ export declare function setImageHeight(image: Image, height: number): void;
453
+ /**
454
+ * Create a bullet list item
455
+ */
456
+ export declare function createBulletListItem(text: string): ListItem;
457
+ /**
458
+ * Create a numbered list item
459
+ */
460
+ export declare function createNumberedListItem(number: number, text: string): ListItem;
461
+ /**
462
+ * Free a list item
463
+ */
464
+ export declare function freeListItem(item: ListItem): void;
465
+ /**
466
+ * Create a table
467
+ */
468
+ export declare function createTable(rows: number, cols: number): Table;
469
+ /**
470
+ * Free a table
471
+ */
472
+ export declare function freeTable(table: Table): void;
473
+ /**
474
+ * Get table row count
475
+ */
476
+ export declare function getTableRowCount(table: Table): number;
477
+ /**
478
+ * Get table column count
479
+ */
480
+ export declare function getTableColCount(table: Table): number;
481
+ /**
482
+ * Create a table style
483
+ */
484
+ export declare function createTableStyle(): TableStyle;
485
+ /**
486
+ * Free a table style
487
+ */
488
+ export declare function freeTableStyle(style: TableStyle): void;
489
+ /**
490
+ * Add grid to table style
491
+ */
492
+ export declare function addTableGrid(style: TableStyle, weight: number, r: number, g: number, b: number): void;
493
+ /**
494
+ * Add background to table style
495
+ */
496
+ export declare function addTableBackground(style: TableStyle, startCol: number, startRow: number, endCol: number, endRow: number, r: number, g: number, b: number): void;
497
+ /**
498
+ * Create a table of contents
499
+ */
500
+ export declare function createToc(): TableOfContents;
501
+ /**
502
+ * Free a table of contents
503
+ */
504
+ export declare function freeToc(toc: TableOfContents): void;
505
+ /**
506
+ * Set TOC title
507
+ */
508
+ export declare function setTocTitle(toc: TableOfContents, title: string): void;
509
+ /**
510
+ * Add TOC entry
511
+ */
512
+ export declare function addTocEntry(toc: TableOfContents, title: string, level: number, page: number): void;
513
+ /**
514
+ * Create a TOC builder
515
+ */
516
+ export declare function createTocBuilder(): TocBuilder;
517
+ /**
518
+ * Free a TOC builder
519
+ */
520
+ export declare function freeTocBuilder(builder: TocBuilder): void;
521
+ /**
522
+ * Add heading to TOC builder
523
+ */
524
+ export declare function addTocHeading(builder: TocBuilder, title: string, level: number, page: number): void;
525
+ /**
526
+ * Create a story
527
+ */
528
+ export declare function createStory(): Story;
529
+ /**
530
+ * Free a story
531
+ */
532
+ export declare function freeStory(story: Story): void;
533
+ /**
534
+ * Get story length (number of flowables)
535
+ */
536
+ export declare function getStoryLength(story: Story): number;
537
+ /**
538
+ * Create a stylesheet
539
+ */
540
+ export declare function createStyleSheet(): StyleSheet;
541
+ /**
542
+ * Free a stylesheet
543
+ */
544
+ export declare function freeStyleSheet(sheet: StyleSheet): void;
545
+ /**
546
+ * Add style to stylesheet
547
+ */
548
+ export declare function addStyleToSheet(sheet: StyleSheet, style: ParagraphStyle): void;
549
+ /**
550
+ * Validate a PDF
551
+ */
552
+ export declare function validatePdf(pdfPath: string, mode?: ValidationMode): ValidationResult;
553
+ /**
554
+ * Quick validate a PDF (basic structure check)
555
+ */
556
+ export declare function quickValidatePdf(pdfPath: string): boolean;
557
+ /**
558
+ * Repair a PDF
559
+ */
560
+ export declare function repairPdf(inputPath: string, outputPath: string): void;
561
+ /**
562
+ * Merge multiple PDFs
563
+ */
564
+ export declare function mergePdfs(ctx: NativeContext, paths: string[], outputPath: string): void;
565
+ /**
566
+ * Split a PDF into individual pages
567
+ */
568
+ export declare function splitPdf(ctx: NativeContext, inputPath: string, outputDir: string): string[];
569
+ /**
570
+ * Optimize a PDF (compress, remove unused objects)
571
+ */
572
+ export declare function optimizePdf(ctx: NativeContext, path: string): void;
573
+ /**
574
+ * Linearize a PDF for fast web viewing
575
+ */
576
+ export declare function linearizePdf(ctx: NativeContext, inputPath: string, outputPath: string): void;
577
+ /**
578
+ * Add a blank page to a document
579
+ */
580
+ export declare function addBlankPage(ctx: NativeContext, doc: NativeDocument, width: number, height: number): number;
581
+ /**
582
+ * Add a watermark to a document
583
+ */
584
+ export declare function addWatermark(ctx: NativeContext, doc: NativeDocument, text: string, fontSize: number, opacity: number): void;
585
+ /**
586
+ * Draw a line on a page
587
+ */
588
+ export declare function drawLine(ctx: NativeContext, page: NativePage, x0: number, y0: number, x1: number, y1: number, color: [number, number, number], alpha: number, lineWidth: number): void;
589
+ /**
590
+ * Draw a rectangle on a page
591
+ */
592
+ export declare function drawRectangle(ctx: NativeContext, page: NativePage, x: number, y: number, width: number, height: number, color: [number, number, number], alpha: number, fill: boolean): void;
593
+ /**
594
+ * Draw a circle on a page
595
+ */
596
+ export declare function drawCircle(ctx: NativeContext, page: NativePage, x: number, y: number, radius: number, color: [number, number, number], alpha: number, fill: boolean): void;
597
+ /**
598
+ * Free a string allocated by the native library
599
+ */
600
+ export declare function freeString(s: string): void;
601
+ export * from './native.js';
226
602
  //# sourceMappingURL=enhanced.d.ts.map