import { LoadPdfOptions, RagLoaderResult } from "./loader.type.mjs"; //#region ../ai/src/rag/loaders/load-pdf.d.ts /** * Load a PDF's bytes into {@link RagDocument}(s) via the OPTIONAL `pdf-parse` * peer. The peer is resolved lazily on the FIRST call (not at import) so * importing `@warlock.js/ai` never forces it to be installed; when it is * absent the curated {@link PDF_PARSE_INSTALL_INSTRUCTIONS} is thrown as a * plain `Error` (a missing optional peer is an infrastructure fault, not a * content problem). * * By default the whole PDF becomes a single document carrying * `metadata.pageCount`. With `perPage: true`, each page becomes its own * document (`id` suffixed `#p`, `metadata.page` set) so citations stay * page-precise. Document `metadata.title` comes from the PDF info * dictionary's `Title` (unless overridden), and `metadata.loader` is * `"pdf"`. The output is the exact shape `index()` consumes. * * @example * import { readFile } from "node:fs/promises"; * const kb = ai.rag({ embedder, store }); * await kb.index(await loadPdf(await readFile("guide.pdf"), { id: "guide" })); * * @example * // One document per page for page-precise citations: * await kb.index(await loadPdf(bytes, { id: "manual", perPage: true })); * * @param input - The PDF bytes (`Buffer`, `ArrayBuffer`, or `Uint8Array`). * @param options - `perPage` plus shared `id` / `metadata` / `tags` * ({@link LoadPdfOptions}). * @returns A {@link RagLoaderResult} ready for `rag.index()`. * @throws {Error} carrying {@link PDF_PARSE_INSTALL_INSTRUCTIONS} when the * `pdf-parse` peer is not installed. */ declare function loadPdf(input: Buffer | ArrayBuffer | Uint8Array, options?: LoadPdfOptions): Promise; //#endregion export { loadPdf }; //# sourceMappingURL=load-pdf.d.mts.map