import type { DocumentSource, FileInput } from './index.js'; import type { FileLoaderOptions } from './text.js'; /** * Extracts a PDF's text: the whole document as one string, or one string per page. Wrap the parser * you already use — `pdfjs-dist`, `unpdf`, `pdf-parse`, or an OCR service — so no PDF library is a * dependency of this package. */ export type PdfTextExtractor = (bytes: Uint8Array, source: string) => Promise | string | readonly string[]; /** Options for `loadPdf()`. */ export interface PdfLoaderOptions extends FileLoaderOptions { /** Your PDF parser. */ extract: PdfTextExtractor; /** * One document per page when the extractor returns pages, with `page` in the metadata, so a * citation can name the page. On by default; off joins the pages into one document. */ splitPages?: boolean; } /** Raised when a file given to `loadPdf()` is not a PDF. */ export declare class PdfLoaderError extends Error { /** The file that failed. */ readonly source: string; constructor(message: string, /** The file that failed. */ source: string); } /** * PDF files, through the parser you inject. A file that does not start with the PDF signature is * refused before it reaches the parser, so a mislabelled upload fails with a clear error. */ export declare function loadPdf(inputs: FileInput | Iterable, options: PdfLoaderOptions): AsyncGenerator;