/** * MicroPDF - High-performance PDF manipulation library for Node.js * * MicroPDF provides comprehensive PDF manipulation capabilities with a clean, type-safe * API. Built on top of MicroPDF, it offers excellent performance and extensive PDF support. * * This library provides 100% API compatibility with the Rust MicroPDF library and includes * native N-API bindings for optimal performance. * * ## Features * * - **PDF Reading & Writing**: Open, modify, and save PDF documents * - **Page Rendering**: Render pages to images with custom resolution and colorspace * - **Text Extraction**: Extract text with layout information, search capabilities * - **Annotations**: Read and modify PDF annotations * - **Forms**: Interactive form field support * - **Security**: Password protection and permission checking * - **Metadata**: Read and write document metadata * - **Vector Graphics**: Path construction and manipulation * - **Image Processing**: Pixmap manipulation and colorspace conversion * * ## Quick Start * * ```typescript * import { Document, Matrix } from 'micropdf'; * * // Open a PDF * const doc = Document.open('document.pdf'); * * // Get basic info * console.log(`Pages: ${doc.pageCount}`); * console.log(`Title: ${doc.getMetadata('Title')}`); * * // Render first page * const page = doc.loadPage(0); * const matrix = Matrix.scale(2, 2); // 2x zoom * const pixmap = page.toPixmap(matrix); * * // Extract text * const text = page.extractText(); * console.log(text); * * // Search for text * const hits = page.searchText('hello'); * console.log(`Found ${hits.length} occurrences`); * * // Clean up * page.drop(); * doc.close(); * ``` * * ## Core Modules * * - {@link document} - PDF document handling and page access * - {@link geometry} - 2D geometry primitives (Point, Rect, Matrix) * - {@link buffer} - Binary data handling * - {@link path} - Vector graphics path construction * - {@link pixmap} - Raster image manipulation * - {@link text} - Text layout and glyph rendering * - {@link colorspace} - Color space management * * ## Resource Management * * MicroPDF uses manual resource management for optimal performance. Objects that * allocate native resources (Document, Page, Pixmap, etc.) must be explicitly * freed using `drop()` or `close()` methods. * * ```typescript * // Always clean up resources * const doc = Document.open('document.pdf'); * try { * // Work with document * } finally { * doc.close(); * } * ``` * * ## Type Safety * * MicroPDF is written in TypeScript and provides comprehensive type definitions * for excellent IDE support and compile-time type checking. * * ## Performance * * - Native C bindings to MicroPDF for optimal performance * - Zero-copy operations where possible * - Efficient memory management * - Suitable for production workloads * * @packageDocumentation * @module micropdf * @preferred */ export { ErrorCode, MicroPDFError, type PointLike, type RectLike, type IRectLike, type MatrixLike, type QuadLike, type ColorspaceLike, type PixmapLike, SeekOrigin, type StreamLike, type BufferLike, isBufferLike, DocumentPermission, type PageLocation, LinkDestType, type OutlineItem as OutlineItemType, PdfObjectType, type PdfIndirectRef as PdfIndirectRefType, FilterName, type FilterType, type FlateDecodeParams, type CCITTFaxDecodeParams, type DCTDecodeParams, type JBIG2DecodeParams, type RenderOptions, type TextExtractionOptions, type AnnotationLike, FormFieldType, type FormFieldLike } from './types.js'; export { Point, Rect, IRect, Matrix, Quad } from './geometry.js'; export { Buffer, BufferReader, BufferWriter } from './buffer.js'; export { Stream, AsyncStream } from './stream.js'; export { Document, Page, OutlineItem } from './document.js'; export { PdfObject, PdfArray, PdfDict, PdfStream, PdfIndirectRef, pdfNull, pdfBool, pdfInt, pdfReal, pdfString, pdfName, pdfArray, pdfDict, pdfObjectCompare, pdfNameEquals, pdfDeepCopy, pdfCopyArray, pdfCopyDict, isNull, isBool, isInt, isReal, isNumber, isName, isString, isArray, isDict, isStream, isIndirect, toBoolDefault, toIntDefault, toRealDefault, toObjNum, toGenNum, pdfKeepObj, pdfDropObj, pdfObjRefs, pdfObjMarked, pdfMarkObj, pdfUnmarkObj, pdfSetObjParent, pdfObjParentNum, pdfNewPoint, pdfNewRect, pdfNewMatrix, pdfNewDate, pdfDictGetKey, pdfDictGetVal, pdfObjIsResolved, pdfResolveIndirect, pdfLoadObject } from './pdf/object.js'; export { flateEncode, flateDecode, asciiHexEncode, asciiHexDecode, ascii85Encode, ascii85Decode, runLengthEncode, runLengthDecode, lzwDecode, decodeFilter, encodeFilter } from './filter.js'; export { Path, StrokeState, LineCap, LineJoin, type PathWalker } from './path.js'; export { Form, FormField, TextField, CheckboxField, PushButtonField, ComboBoxField, SignatureField, FieldType, FieldAlignment, FieldFlags, TextFormat, type ChoiceOption } from './form.js'; export { Annotation, AnnotationList, AnnotationType, AnnotationFlags, LineEndingStyle } from './annot.js'; export { Device, DrawDevice, BBoxDevice, TraceDevice, ListDevice, DeviceType, DeviceHint, BlendMode } from './device.js'; export { Colorspace, ColorspaceType } from './colorspace.js'; export { type ExtendedRenderOptions, type RenderProgressCallback, type RenderErrorCallback, AntiAliasLevel, getDefaultRenderOptions, dpiToScale, scaleToDpi, validateRenderOptions, mergeRenderOptions } from './render-options.js'; export { Pixmap, type PixmapInfo } from './pixmap.js'; export { Text, Language, type TextSpan, type TextItem, type TextWalker } from './text.js'; export { STextPage, STextBlockType, WritingMode, type STextCharData, type STextLineData, type STextBlockData, quadToRect, quadsOverlap } from './stext.js'; export { DisplayList } from './display-list.js'; export { Link, LinkList, LinkDestinationType } from './link.js'; export { Cookie, CookieOperation } from './cookie.js'; export { Font, FontManager, FontFlags, StandardFonts, type GlyphInfo } from './font.js'; export { Image, ImageDecoder, ImageFormat, ImageOrientation, type ImageInfo } from './image.js'; export { Output } from './output.js'; export { Archive, ArchiveFormat, type ArchiveEntry } from './archive.js'; export { Context, getDefaultContext, setDefaultContext, resetDefaultContext, type ErrorCallback, type WarningCallback, type ContextInfo } from './context.js'; export { create2Up, create4Up, create9Up, createNup, createBooklet, createSaddleStitchBooklet, createPoster, getPosterTileCount, createPageBoxManager, freePageBoxManager, getPageBoxPageCount, getPageBox, setPageBox, addBleed, savePageBox, isEncrypted, createEncryptionOptions, freeEncryptionOptions, setUserPassword, setOwnerPassword, setPermissions, setAlgorithm, encryptPdf, decryptPdf, loadCertificatePem, loadCertificatePkcs12, freeCertificate, isCertificateValid, getCertificateSubject, getCertificateIssuer, createSignature, createInvisibleSignature, verifySignature, countSignatures, createHtmlOptions, freeHtmlOptions, setHtmlPageSize, setHtmlCustomPageSize, setHtmlMargins, setHtmlLandscape, setHtmlScale, setHtmlPrintBackground, setHtmlHeader, setHtmlFooter, setHtmlJavaScript, setHtmlBaseUrl, setHtmlStylesheet, htmlToPdf, htmlFileToPdf, createDocTemplate, freeDocTemplate, setDocTemplatePageSize, setDocTemplateMargins, createFrame, freeFrame, getFrameAvailableWidth, getFrameAvailableHeight, createParagraph, freeParagraph, setParagraphFontSize, setParagraphLeading, createParagraphStyle, freeParagraphStyle, setParagraphStyleFontSize, setParagraphStyleLeading, setParagraphStyleAlignment, createSpacer, freeSpacer, createHorizontalRule, freeHorizontalRule, setHorizontalRuleThickness, createImage, freeImage, setImageWidth, setImageHeight, createBulletListItem, createNumberedListItem, freeListItem, createTable, freeTable, getTableRowCount, getTableColCount, createTableStyle, freeTableStyle, addTableGrid, addTableBackground, createToc, freeToc, setTocTitle, addTocEntry, createTocBuilder, freeTocBuilder, addTocHeading, createStory, freeStory, getStoryLength, createStyleSheet, freeStyleSheet, addStyleToSheet, validatePdf, quickValidatePdf, repairPdf, mergePdfs, splitPdf, optimizePdf, linearizePdf, addBlankPage, addWatermark, drawLine, drawRectangle, drawCircle, freeString, PageSize as EnhancedPageSize, BindingMethod, PageBoxType, Unit, EncryptionAlgorithm, DocumentPermission as EnhancedDocumentPermission, TextAlign, ValidationMode, type EncryptionOptions, type Certificate, type SignatureVerifyResult, type HtmlOptions, type DocTemplate, type Frame, type ParagraphStyle, type StyleSheet, type Paragraph, type Spacer, type HorizontalRule, type Image as EnhancedImage, type ListItem, type Table, type TableStyle, type TableOfContents, type TocBuilder, type Story, type PageBoxManager, type ValidationResult, type Rectangle, Enhanced } from './enhanced.js'; export { MicroPDF, getVersion, type MicroPDFOptions } from './micropdf.js'; /** * Resource tracking utilities for leak detection and memory optimization. * * @example * ```typescript * import { * enableTracking, * handleRegistry, * generateLeakReport, * getPoolStats * } from 'micropdf'; * * // Enable tracking in development * enableTracking(true); * * // ... use MicroPDF ... * * // Check for leaks * console.log(generateLeakReport()); * ``` */ export { ResourceType, handleRegistry, enableTracking, enableStackTraces, isTrackingEnabled, acquirePoint, releasePoint, acquireRect, releaseRect, acquireMatrix, releaseMatrix, acquireQuad, releaseQuad, getPoolStats, clearPools, byteArrayPool, uint8ArrayToString, bufferToString, numberArrayPool, generateLeakReport, printLeakReport, type AllocationInfo, type TypeStats, type GlobalStats } from './resource-tracking.js'; /** * TypedArray utilities for batch numeric operations. * * Use these functions for performance-critical code that processes * large amounts of coordinate, color, or pixel data. * * @example * ```typescript * import { * pointsFromCoords, * transformPointsInPlace, * colorFromRGB, * matrixRotate * } from 'micropdf'; * * // Create points as Float32Array * const points = pointsFromCoords(0, 0, 100, 0, 100, 100, 0, 100); * * // Transform in-place (no allocation) * const m = matrixRotate(45); * transformPointsInPlace(points, m[0], m[1], m[2], m[3], m[4], m[5]); * * // Create colors as Float32Array * const red = colorFromRGB(255, 0, 0); // Normalized to [1, 0, 0] * ``` */ export { colorFromRGB, colorFromRGBA, colorFromGray, colorFromCMYK, pointsFromCoords, pointsFromObjects, transformPointsInPlace, transformPoints, rectsFromCoords, rectsFromObjects, transformRectsInPlace, matrixIdentity, matrixTranslate, matrixScale, matrixRotate, matrixConcatInPlace, matrixConcat, pointDistances, pointDistancesSquared, rectContainsPoints, countPointsInRect, convertPixelFormat, premultiplyAlpha, unpremultiplyAlpha } from './typed-arrays.js'; /** Library version */ export declare const VERSION = "0.9.1"; //# sourceMappingURL=index.d.ts.map