/** * Enhanced MicroPDF Functions (mp_* prefix) * * This module provides TypeScript bindings for all 120+ enhanced MicroPDF * functions including: * - Print Production (N-Up, Booklet, Poster) * - Digital Signatures & Encryption * - HTML to PDF Conversion * - Document Composition (Platypus-like) * - PDF Validation & Repair */ import type { NativeContext, NativeDocument, NativePage } from './native.js'; /** Page size presets */ export declare enum PageSize { A4 = 0, Letter = 1, Legal = 2, A3 = 3, A5 = 4, B4 = 5, B5 = 6, Executive = 7, Ledger = 8, Tabloid = 9 } /** Binding methods for booklet creation */ export declare enum BindingMethod { SaddleStitch = 0, PerfectBinding = 1, SideStitch = 2, WireO = 3, CaseBinding = 4 } /** Page box types */ export declare enum PageBoxType { MediaBox = 0, CropBox = 1, BleedBox = 2, TrimBox = 3, ArtBox = 4 } /** Unit types for measurements */ export declare enum Unit { Points = 0, Millimeters = 1, Inches = 2, Centimeters = 3 } /** Encryption algorithms */ export declare enum EncryptionAlgorithm { RC4_40 = 0, RC4_128 = 1, AES_128 = 2, AES_256 = 3 } /** Document permissions */ export declare enum DocumentPermission { Print = 4, ModifyContents = 8, Copy = 16, ModifyAnnotations = 32, FillForms = 256, ExtractForAccessibility = 512, Assemble = 1024, PrintHighQuality = 2048 } /** Text alignment */ export declare enum TextAlign { Left = 0, Center = 1, Right = 2, Justify = 3 } /** Validation modes */ export declare enum ValidationMode { Quick = 0, Standard = 1, Strict = 2 } export interface EncryptionOptions { _handle: number; } export interface Certificate { _handle: number; } export interface SignatureVerifyResult { valid: boolean; signerName?: string; signedAt?: Date; reason?: string; location?: string; modifiedAfterSigning: boolean; } export interface HtmlOptions { _handle: number; } export interface DocTemplate { _handle: number; } export interface Frame { _handle: number; } export interface ParagraphStyle { _handle: number; } export interface StyleSheet { _handle: number; } export interface Paragraph { _handle: number; } export interface Spacer { _handle: number; } export interface HorizontalRule { _handle: number; } export interface Image { _handle: number; } export interface ListItem { _handle: number; } export interface Table { _handle: number; } export interface TableStyle { _handle: number; } export interface TableOfContents { _handle: number; } export interface TocBuilder { _handle: number; } export interface Story { _handle: number; } export interface PageBoxManager { _handle: number; } export interface ValidationResult { valid: boolean; errors: string[]; warnings: string[]; } export interface Rectangle { llx: number; lly: number; urx: number; ury: number; } /** * Create a 2-up layout (2 pages per sheet) */ export declare function create2Up(inputPath: string, outputPath: string, pageSize?: PageSize): void; /** * Create a 4-up layout (4 pages per sheet) */ export declare function create4Up(inputPath: string, outputPath: string, pageSize?: PageSize): void; /** * Create a 9-up layout (9 pages per sheet) */ export declare function create9Up(inputPath: string, outputPath: string, pageSize?: PageSize): void; /** * Create a custom N-up layout */ export declare function createNup(inputPath: string, outputPath: string, cols: number, rows: number, pageSize?: PageSize): void; /** * Create a booklet for printing */ export declare function createBooklet(inputPath: string, outputPath: string, bindingType?: BindingMethod, pageSize?: PageSize, addBlanks?: boolean): void; /** * Create a saddle-stitch booklet (simplified) */ export declare function createSaddleStitchBooklet(inputPath: string, outputPath: string): void; /** * Create a poster by tiling pages */ export declare function createPoster(inputPath: string, outputPath: string, tileSize: number, overlapMm?: number, cutMarks?: boolean): void; /** * Get the number of tiles for a poster */ export declare function getPosterTileCount(pdfPath: string, tileSize: number, overlapMm?: number): number; /** * Create a page box manager for a PDF */ export declare function createPageBoxManager(pdfPath: string): PageBoxManager; /** * Free a page box manager */ export declare function freePageBoxManager(manager: PageBoxManager): void; /** * Get the page count from a page box manager */ export declare function getPageBoxPageCount(manager: PageBoxManager): number; /** * Get a page box */ export declare function getPageBox(manager: PageBoxManager, page: number, boxType: PageBoxType): Rectangle; /** * Set a page box */ export declare function setPageBox(manager: PageBoxManager, page: number, boxType: PageBoxType, rect: Rectangle): void; /** * Add bleed to all pages */ export declare function addBleed(manager: PageBoxManager, bleed: number, unit?: Unit): void; /** * Save page box changes */ export declare function savePageBox(manager: PageBoxManager, outputPath: string): void; /** * Check if a PDF is encrypted */ export declare function isEncrypted(pdfPath: string): boolean; /** * Create encryption options */ export declare function createEncryptionOptions(): EncryptionOptions; /** * Free encryption options */ export declare function freeEncryptionOptions(options: EncryptionOptions): void; /** * Set user password for encryption */ export declare function setUserPassword(options: EncryptionOptions, password: string): void; /** * Set owner password for encryption */ export declare function setOwnerPassword(options: EncryptionOptions, password: string): void; /** * Set document permissions */ export declare function setPermissions(options: EncryptionOptions, permissions: number): void; /** * Set encryption algorithm */ export declare function setAlgorithm(options: EncryptionOptions, algorithm: EncryptionAlgorithm): void; /** * Encrypt a PDF */ export declare function encryptPdf(inputPath: string, outputPath: string, options: EncryptionOptions): void; /** * Decrypt a PDF */ export declare function decryptPdf(inputPath: string, outputPath: string, password: string): void; /** * Load a certificate from PEM files */ export declare function loadCertificatePem(certPath: string, keyPath: string, keyPassword?: string): Certificate; /** * Load a certificate from PKCS#12 file */ export declare function loadCertificatePkcs12(path: string, password: string): Certificate; /** * Free a certificate */ export declare function freeCertificate(cert: Certificate): void; /** * Check if a certificate is valid */ export declare function isCertificateValid(cert: Certificate): boolean; /** * Get certificate subject */ export declare function getCertificateSubject(cert: Certificate): string; /** * Get certificate issuer */ export declare function getCertificateIssuer(cert: Certificate): string; /** * Create a digital signature with appearance */ 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; /** * Create an invisible digital signature */ export declare function createInvisibleSignature(inputPath: string, outputPath: string, cert: Certificate, fieldName: string, reason?: string, location?: string): void; /** * Verify a signature */ export declare function verifySignature(pdfPath: string, fieldName: string): SignatureVerifyResult; /** * Count signatures in a PDF */ export declare function countSignatures(pdfPath: string): number; /** * Create HTML conversion options */ export declare function createHtmlOptions(): HtmlOptions; /** * Free HTML options */ export declare function freeHtmlOptions(options: HtmlOptions): void; /** * Set page size for HTML conversion */ export declare function setHtmlPageSize(options: HtmlOptions, pageSize: PageSize): void; /** * Set custom page size for HTML conversion */ export declare function setHtmlCustomPageSize(options: HtmlOptions, width: number, height: number): void; /** * Set margins for HTML conversion */ export declare function setHtmlMargins(options: HtmlOptions, top: number, right: number, bottom: number, left: number): void; /** * Set landscape mode for HTML conversion */ export declare function setHtmlLandscape(options: HtmlOptions, landscape: boolean): void; /** * Set scale for HTML conversion */ export declare function setHtmlScale(options: HtmlOptions, scale: number): void; /** * Set print background for HTML conversion */ export declare function setHtmlPrintBackground(options: HtmlOptions, enabled: boolean): void; /** * Set header HTML */ export declare function setHtmlHeader(options: HtmlOptions, html: string): void; /** * Set footer HTML */ export declare function setHtmlFooter(options: HtmlOptions, html: string): void; /** * Enable/disable JavaScript */ export declare function setHtmlJavaScript(options: HtmlOptions, enabled: boolean): void; /** * Set base URL for relative paths */ export declare function setHtmlBaseUrl(options: HtmlOptions, url: string): void; /** * Set custom stylesheet */ export declare function setHtmlStylesheet(options: HtmlOptions, css: string): void; /** * Convert HTML string to PDF */ export declare function htmlToPdf(html: string, outputPath: string, options?: HtmlOptions): void; /** * Convert HTML file to PDF */ export declare function htmlFileToPdf(htmlPath: string, outputPath: string, options?: HtmlOptions): void; /** * Create a document template */ export declare function createDocTemplate(filename: string): DocTemplate; /** * Free a document template */ export declare function freeDocTemplate(template: DocTemplate): void; /** * Set page size for document template */ export declare function setDocTemplatePageSize(template: DocTemplate, width: number, height: number): void; /** * Set margins for document template */ export declare function setDocTemplateMargins(template: DocTemplate, left: number, right: number, top: number, bottom: number): void; /** * Create a frame */ export declare function createFrame(id: string, x: number, y: number, width: number, height: number): Frame; /** * Free a frame */ export declare function freeFrame(frame: Frame): void; /** * Get frame available width */ export declare function getFrameAvailableWidth(frame: Frame): number; /** * Get frame available height */ export declare function getFrameAvailableHeight(frame: Frame): number; /** * Create a paragraph */ export declare function createParagraph(text: string): Paragraph; /** * Free a paragraph */ export declare function freeParagraph(paragraph: Paragraph): void; /** * Set paragraph font size */ export declare function setParagraphFontSize(paragraph: Paragraph, size: number): void; /** * Set paragraph leading */ export declare function setParagraphLeading(paragraph: Paragraph, leading: number): void; /** * Create a paragraph style */ export declare function createParagraphStyle(name: string): ParagraphStyle; /** * Free a paragraph style */ export declare function freeParagraphStyle(style: ParagraphStyle): void; /** * Set paragraph style font size */ export declare function setParagraphStyleFontSize(style: ParagraphStyle, size: number): void; /** * Set paragraph style leading */ export declare function setParagraphStyleLeading(style: ParagraphStyle, leading: number): void; /** * Set paragraph style alignment */ export declare function setParagraphStyleAlignment(style: ParagraphStyle, align: TextAlign): void; /** * Create a spacer */ export declare function createSpacer(height: number): Spacer; /** * Free a spacer */ export declare function freeSpacer(spacer: Spacer): void; /** * Create a horizontal rule */ export declare function createHorizontalRule(): HorizontalRule; /** * Free a horizontal rule */ export declare function freeHorizontalRule(hr: HorizontalRule): void; /** * Set horizontal rule thickness */ export declare function setHorizontalRuleThickness(hr: HorizontalRule, thickness: number): void; /** * Create an image flowable */ export declare function createImage(path: string): Image; /** * Free an image */ export declare function freeImage(image: Image): void; /** * Set image width */ export declare function setImageWidth(image: Image, width: number): void; /** * Set image height */ export declare function setImageHeight(image: Image, height: number): void; /** * Create a bullet list item */ export declare function createBulletListItem(text: string): ListItem; /** * Create a numbered list item */ export declare function createNumberedListItem(number: number, text: string): ListItem; /** * Free a list item */ export declare function freeListItem(item: ListItem): void; /** * Create a table */ export declare function createTable(rows: number, cols: number): Table; /** * Free a table */ export declare function freeTable(table: Table): void; /** * Get table row count */ export declare function getTableRowCount(table: Table): number; /** * Get table column count */ export declare function getTableColCount(table: Table): number; /** * Create a table style */ export declare function createTableStyle(): TableStyle; /** * Free a table style */ export declare function freeTableStyle(style: TableStyle): void; /** * Add grid to table style */ export declare function addTableGrid(style: TableStyle, weight: number, r: number, g: number, b: number): void; /** * Add background to table style */ export declare function addTableBackground(style: TableStyle, startCol: number, startRow: number, endCol: number, endRow: number, r: number, g: number, b: number): void; /** * Create a table of contents */ export declare function createToc(): TableOfContents; /** * Free a table of contents */ export declare function freeToc(toc: TableOfContents): void; /** * Set TOC title */ export declare function setTocTitle(toc: TableOfContents, title: string): void; /** * Add TOC entry */ export declare function addTocEntry(toc: TableOfContents, title: string, level: number, page: number): void; /** * Create a TOC builder */ export declare function createTocBuilder(): TocBuilder; /** * Free a TOC builder */ export declare function freeTocBuilder(builder: TocBuilder): void; /** * Add heading to TOC builder */ export declare function addTocHeading(builder: TocBuilder, title: string, level: number, page: number): void; /** * Create a story */ export declare function createStory(): Story; /** * Free a story */ export declare function freeStory(story: Story): void; /** * Get story length (number of flowables) */ export declare function getStoryLength(story: Story): number; /** * Create a stylesheet */ export declare function createStyleSheet(): StyleSheet; /** * Free a stylesheet */ export declare function freeStyleSheet(sheet: StyleSheet): void; /** * Add style to stylesheet */ export declare function addStyleToSheet(sheet: StyleSheet, style: ParagraphStyle): void; /** * Validate a PDF */ export declare function validatePdf(pdfPath: string, mode?: ValidationMode): ValidationResult; /** * Quick validate a PDF (basic structure check) */ export declare function quickValidatePdf(pdfPath: string): boolean; /** * Repair a PDF */ export declare function repairPdf(inputPath: string, outputPath: string): void; /** * Merge multiple PDFs */ export declare function mergePdfs(ctx: NativeContext, paths: string[], outputPath: string): void; /** * Split a PDF into individual pages */ export declare function splitPdf(ctx: NativeContext, inputPath: string, outputDir: string): string[]; /** * Optimize a PDF (compress, remove unused objects) */ export declare function optimizePdf(ctx: NativeContext, path: string): void; /** * Linearize a PDF for fast web viewing */ export declare function linearizePdf(ctx: NativeContext, inputPath: string, outputPath: string): void; /** * Add a blank page to a document */ export declare function addBlankPage(ctx: NativeContext, doc: NativeDocument, width: number, height: number): number; /** * Add a watermark to a document */ export declare function addWatermark(ctx: NativeContext, doc: NativeDocument, text: string, fontSize: number, opacity: number): void; /** * Draw a line on a page */ 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; /** * Draw a rectangle on a page */ 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; /** * Draw a circle on a page */ export declare function drawCircle(ctx: NativeContext, page: NativePage, x: number, y: number, radius: number, color: [number, number, number], alpha: number, fill: boolean): void; /** * Free a string allocated by the native library */ export declare function freeString(s: string): void; /** * Static helper class that wraps common enhanced PDF operations. * * Each method delegates to the underlying native bindings and returns a * boolean indicating success so callers don't need to deal with error * codes directly. */ export declare class Enhanced { /** * Add a blank page to a document. */ static addBlankPage(ctx: NativeContext, pageIndex: number, width: number, height: number): boolean; /** * Add a watermark to a specific page. */ static addWatermark(ctx: NativeContext, page: number, text: string, _x: number, _y: number, fontSize: number, opacity: number, _color: number[]): boolean; /** * Draw a circle on a page. */ static drawCircle(ctx: NativeContext, page: number, cx: number, cy: number, radius: number, strokeColor: number[], fillColor: number[] | null, _lineWidth: number): boolean; /** * Draw a line on a page. */ static drawLine(ctx: NativeContext, page: number, x0: number, y0: number, x1: number, y1: number, color: number[], lineWidth: number): boolean; /** * Draw a rectangle on a page. */ static drawRectangle(ctx: NativeContext, page: number, x: number, y: number, width: number, height: number, strokeColor: number[], fillColor: number[] | null, _lineWidth: number): boolean; /** * Linearize a PDF for fast web viewing. */ static linearizePdf(ctx: NativeContext, outputPath: string): boolean; /** * Merge multiple PDF files into one. */ static mergePdfs(ctx: NativeContext, paths: string[], outputPath: string): boolean; /** * Optimize a PDF (compress, remove unused objects). */ static optimizePdf(ctx: NativeContext, outputPath: string): boolean; /** * Split a PDF into individual pages. */ static splitPdf(ctx: NativeContext, outputDir: string): boolean; /** * Write (save) a PDF to the specified path. */ static writePdf(ctx: NativeContext, outputPath: string): boolean; } export * from './native.js'; //# sourceMappingURL=enhanced.d.ts.map