@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
83 lines (82 loc) • 3.46 kB
TypeScript
/**
* PDF Processor with Image Fallback Support
*
* Handles PDF processing for all providers:
* - Native PDF support for providers that accept PDF directly (Google AI, Vertex, OpenAI, Anthropic, Bedrock)
* - PDF → Image conversion for providers that don't support native PDF (Azure, Mistral, Ollama)
*
* The conversion uses pdf-to-img package (MuPDF-based) for high-quality conversion.
*/
import type { FileProcessingResult, PDFProcessorOptions, PDFProviderConfig, PDFImageConversionOptions, PDFImageConversionResult } from "../types/index.js";
export declare class PDFProcessor {
private static readonly PDF_SIGNATURE;
static process(content: Buffer, options?: PDFProcessorOptions): Promise<FileProcessingResult>;
/**
* Check if a provider supports native PDF input
* @param provider - Provider name
* @returns true if provider can accept PDF directly, false if requires image conversion
*/
static supportsNativePDF(provider: string): boolean;
static getProviderConfig(provider: string): PDFProviderConfig | null;
private static isValidPDF;
private static extractBasicMetadata;
static estimateTokens(pageCount: number, mode?: "text-only" | "visual"): number;
/**
* Convert a PDF buffer to an array of base64 PNG images
*
* This is used automatically when a provider (like Azure, Mistral, Ollama) doesn't
* support native PDF input but does support image input. The PDF pages are converted
* to PNG images and sent as vision content.
*
* @param pdfBuffer - PDF file content as Buffer
* @param options - Conversion options
* @returns Promise with conversion result including base64 images
*
* @example
* ```typescript
* // Check if conversion is needed
* if (!PDFProcessor.supportsNativePDF('azure')) {
* const result = await PDFProcessor.convertToImages(pdfBuffer, {
* scale: 2,
* maxPages: 10
* });
* // Use images in LLM input instead of PDF
* options.input.images = result.images;
* }
* ```
*/
static convertToImages(pdfBuffer: Buffer, options?: PDFImageConversionOptions): Promise<PDFImageConversionResult>;
/**
* Convert a PDF file path to an array of base64 PNG images
*
* @param pdfPath - Path to the PDF file
* @param options - Conversion options
* @returns Promise with conversion result
*/
static convertFromPath(pdfPath: string, options?: PDFImageConversionOptions): Promise<PDFImageConversionResult>;
/**
* Check if PDF to image conversion is available
* Useful for feature detection
*
* @returns true if pdf-to-img package is available
*/
static isImageConversionAvailable(): Promise<boolean>;
/**
* Get estimated memory usage for converting a PDF
*
* @param pdfSizeBytes - Size of PDF file in bytes
* @param pageCount - Estimated number of pages
* @param scale - Scale factor
* @returns Estimated memory usage in MB
*/
static estimateConversionMemoryUsage(pdfSizeBytes: number, pageCount: number, scale?: number): number;
/**
* Get list of providers that require PDF → Image conversion
*/
static getImageFallbackProviders(): string[];
/**
* Get list of providers that support native PDF
*/
static getNativePDFProviders(): string[];
}
export declare const PDFImageConverter: typeof PDFProcessor;