/** * Simple API - Ultra-simplified functions for common PDF tasks * * This module provides the simplest possible API for basic PDF operations. * Perfect for beginners or quick scripts. * * @example * ```typescript * import * as pdf from 'micropdf/simple'; * * // Extract all text * const text = await pdf.extractText('document.pdf'); * * // Render first page to PNG * await pdf.renderToPNG('document.pdf', 'output.png'); * * // Get page count * const pages = await pdf.getPageCount('document.pdf'); * ``` */ import { type PdfMetadata, type DocumentInfo } from './easy.js'; /** * Extract all text from a PDF * * @param pdfPath - Path to PDF file * @param password - Optional password for encrypted PDFs * @returns All text from the PDF * * @example * ```typescript * const text = await extractText('document.pdf'); * console.log(text); * ``` */ export declare function extractText(pdfPath: string, password?: string): Promise; /** * Extract text from a specific page * * @param pdfPath - Path to PDF file * @param pageNumber - Page number (0-indexed) * @param password - Optional password for encrypted PDFs * @returns Text from the specified page * * @example * ```typescript * const text = await extractPageText('document.pdf', 0); * console.log(text); * ``` */ export declare function extractPageText(pdfPath: string, pageNumber: number, password?: string): Promise; /** * Get the number of pages in a PDF * * @param pdfPath - Path to PDF file * @param password - Optional password for encrypted PDFs * @returns Number of pages * * @example * ```typescript * const count = await getPageCount('document.pdf'); * console.log(`Document has ${count} pages`); * ``` */ export declare function getPageCount(pdfPath: string, password?: string): Promise; /** * Get PDF metadata (title, author, etc.) * * @param pdfPath - Path to PDF file * @param password - Optional password for encrypted PDFs * @returns PDF metadata * * @example * ```typescript * const meta = await getMetadata('document.pdf'); * console.log(meta.title); * console.log(meta.author); * ``` */ export declare function getMetadata(pdfPath: string, password?: string): Promise; /** * Get complete document information * * @param pdfPath - Path to PDF file * @param password - Optional password for encrypted PDFs * @returns Document information including metadata and page details * * @example * ```typescript * const info = await getInfo('document.pdf'); * console.log(`Pages: ${info.pageCount}`); * console.log(`Title: ${info.metadata.title}`); * info.pages.forEach((page, i) => { * console.log(`Page ${i}: ${page.width}x${page.height}`); * }); * ``` */ export declare function getInfo(pdfPath: string, password?: string): Promise; /** * Render a page to PNG * * @param pdfPath - Path to PDF file * @param outputPath - Output PNG file path * @param pageNumber - Page number (0-indexed, default: 0) * @param dpi - DPI for rendering (default: 150) * @param password - Optional password for encrypted PDFs * * @example * ```typescript * // Render first page at 150 DPI * await renderToPNG('document.pdf', 'output.png'); * * // Render second page at 300 DPI * await renderToPNG('document.pdf', 'output.png', 1, 300); * ``` */ export declare function renderToPNG(pdfPath: string, outputPath: string, pageNumber?: number, dpi?: number, password?: string): Promise; /** * Render all pages to PNG files * * @param pdfPath - Path to PDF file * @param outputPattern - Output file pattern (use {page} for page number) * @param dpi - DPI for rendering (default: 150) * @param password - Optional password for encrypted PDFs * * @example * ```typescript * // Render all pages * await renderAllToPNG('document.pdf', 'output/page-{page}.png'); * * // High quality rendering * await renderAllToPNG('document.pdf', 'output/page-{page}.png', 300); * ``` */ export declare function renderAllToPNG(pdfPath: string, outputPattern: string, dpi?: number, password?: string): Promise; /** * Get a page as a PNG buffer * * @param pdfPath - Path to PDF file * @param pageNumber - Page number (0-indexed, default: 0) * @param dpi - DPI for rendering (default: 150) * @param password - Optional password for encrypted PDFs * @returns PNG buffer * * @example * ```typescript * const buffer = await getPageAsPNG('document.pdf', 0, 300); * await fs.writeFile('output.png', buffer); * ``` */ export declare function getPageAsPNG(pdfPath: string, pageNumber?: number, dpi?: number, password?: string): Promise; /** * Search for text in a PDF * * @param pdfPath - Path to PDF file * @param query - Text to search for * @param password - Optional password for encrypted PDFs * @returns Array of page numbers where text was found * * @example * ```typescript * const pages = await searchText('document.pdf', 'important'); * console.log(`Found on pages: ${pages.join(', ')}`); * ``` */ export declare function searchText(pdfPath: string, query: string, password?: string): Promise; /** * Check if a PDF is encrypted * * @param pdfPath - Path to PDF file * @returns True if the PDF is encrypted * * @example * ```typescript * if (await isEncrypted('document.pdf')) { * console.log('This PDF requires a password'); * } * ``` */ export declare function isEncrypted(pdfPath: string): Promise; /** * Save text extraction to a file * * @param pdfPath - Path to PDF file * @param outputPath - Output text file path * @param password - Optional password for encrypted PDFs * * @example * ```typescript * await saveTextToFile('document.pdf', 'output.txt'); * ``` */ export declare function saveTextToFile(pdfPath: string, outputPath: string, password?: string): Promise; /** * Convert PDF to images (one per page) * * @param pdfPath - Path to PDF file * @param outputDir - Output directory for images * @param options - Rendering options * @returns Array of output file paths * * @example * ```typescript * const files = await convertToImages('document.pdf', 'output/', { * dpi: 300, * format: 'png' * }); * console.log(`Created ${files.length} images`); * ``` */ export declare function convertToImages(pdfPath: string, outputDir: string, options?: { dpi?: number; format?: 'png' | 'pnm' | 'pam'; password?: string; }): Promise; /** * Quick info summary for a PDF * * @param pdfPath - Path to PDF file * @param password - Optional password for encrypted PDFs * @returns Human-readable summary string * * @example * ```typescript * const summary = await quickSummary('document.pdf'); * console.log(summary); * // Output: * // Document: document.pdf * // Pages: 42 * // Title: My Document * // Author: John Doe * // Encrypted: No * ``` */ export declare function quickSummary(pdfPath: string, password?: string): Promise; /** * Merge multiple PDF files into a single output file * * This is the simplest way to merge PDFs - just provide the input paths and output path. * Handles large documents (5000+ pages) and corrupted PDFs robustly. * * @param inputPaths - Array of PDF file paths to merge (in order) * @param outputPath - Path where the merged PDF will be saved * @returns Promise that resolves to the number of pages in the merged PDF * @throws Error if any input file is invalid, not found, or merge fails * * @example Basic merge * ```typescript * import { mergePDF } from 'micropdf/simple'; * * const pageCount = await mergePDF( * ['document1.pdf', 'document2.pdf', 'document3.pdf'], * 'merged.pdf' * ); * console.log(`Merged ${pageCount} pages`); * ``` * * @example Large documents * ```typescript * // Works with large documents (5000+ pages) * const pageCount = await mergePDF( * ['large_doc1.pdf', 'large_doc2.pdf'], * 'combined.pdf' * ); * ``` * * @example Error handling * ```typescript * try { * await mergePDF(['doc1.pdf', 'doc2.pdf'], 'output.pdf'); * } catch (error) { * console.error('Merge failed:', error.message); * } * ``` */ export declare function mergePDF(inputPaths: string[], outputPath: string): Promise; //# sourceMappingURL=simple.d.ts.map