/** * ┌─────────────────────────────────────────────────────────────────────────┐ * │ PDF UTILITIES - Core PDF Processing Functions │ * ├─────────────────────────────────────────────────────────────────────────┤ * │ Filename: pdf-utils.ts │ * │ Language: TypeScript │ * │ MCP Server: PDF Operations Server │ * │ │ * │ Purpose: │ * │ Provides core utility functions for PDF operations including file │ * │ validation, path security checks, PDF reading, and data extraction. │ * │ All PDF tools depend on these utilities. │ * │ │ * │ Why this file exists: │ * │ - Centralizes PDF processing logic to avoid duplication │ * │ - Provides security validation for file paths │ * │ - Handles errors consistently across all PDF operations │ * │ - Ensures efficient and safe PDF parsing │ * │ │ * │ Security Considerations: │ * │ - Validates file exists and is readable │ * │ - Prevents path traversal attacks │ * │ - Enforces file size limits (default 50MB) │ * │ - Validates PDF file format │ * │ │ * │ Dependencies: │ * │ - pdf-parse: PDF text extraction │ * │ - fs/promises: Async file operations │ * │ - path: Path manipulation and validation │ * │ │ * │ Author: PDF MCP Team │ * │ Created: 2025-10-29 │ * │ Version: 1.0.0 │ * └─────────────────────────────────────────────────────────────────────────┘ */ import type { PDFData } from '../types.js'; /** * Validates that a file path is safe and accessible * Now uses intelligent path resolution to find files * * @param filePath - Path to validate (can be relative, absolute, or just filename) * @returns Resolved absolute path to the PDF file * @throws Error if path is invalid, inaccessible, or too large */ export declare function validatePDFPath(filePath: string): Promise; /** * Reads and parses a PDF file * * @param filePath - Path to the PDF file (can be relative, absolute, or just filename) * @returns Parsed PDF data including text, metadata, and page count * @throws Error if file cannot be read or parsed */ export declare function parsePDF(filePath: string): Promise; /** * Extracts a clean summary of PDF information * * @param pdfData - Parsed PDF data * @returns Human-readable summary string */ export declare function formatPDFInfo(pdfData: PDFData): string; /** * Truncates text to a maximum length with ellipsis * * @param text - Text to truncate * @param maxLength - Maximum length (default: 5000 characters) * @returns Truncated text */ export declare function truncateText(text: string, maxLength?: number): string; /** * Cleans and normalizes extracted PDF text * Removes excessive whitespace and control characters * * @param text - Raw text from PDF * @returns Cleaned text */ export declare function cleanPDFText(text: string): string; //# sourceMappingURL=pdf-utils.d.ts.map