UNPKG

@langchain/community

Version:
1 lines • 2.89 kB
{"version":3,"file":"pdf.d.cts","names":["Document","BufferLoader","PDFLoader","Blob","splitPages","pdfjs","parsedItemSeparator","PDFLoaderImports","Buffer","Promise","pdf_parse_lib_pdf_js_v1_10_100_build_pdf_js0","getDocument"],"sources":["../../../src/document_loaders/fs/pdf.d.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BufferLoader } from \"@langchain/classic/document_loaders/fs/buffer\";\n/**\n * A class that extends the `BufferLoader` class. It represents a document\n * loader that loads documents from PDF files.\n * @example\n * ```typescript\n * const loader = new PDFLoader(\"path/to/bitcoin.pdf\");\n * const docs = await loader.load();\n * console.log({ docs });\n * ```\n */\nexport declare class PDFLoader extends BufferLoader {\n private splitPages;\n private pdfjs;\n protected parsedItemSeparator: string;\n constructor(filePathOrBlob: string | Blob, { splitPages, pdfjs, parsedItemSeparator }?: {\n parsedItemSeparator?: string | undefined;\n pdfjs?: typeof PDFLoaderImports | undefined;\n splitPages?: boolean | undefined;\n });\n /**\n * A method that takes a `raw` buffer and `metadata` as parameters and\n * returns a promise that resolves to an array of `Document` instances. It\n * uses the `getDocument` function from the PDF.js library to load the PDF\n * from the buffer. It then iterates over each page of the PDF, retrieves\n * the text content using the `getTextContent` method, and joins the text\n * items to form the page content. It creates a new `Document` instance\n * for each page with the extracted text content and metadata, and adds it\n * to the `documents` array. If `splitPages` is `true`, it returns the\n * array of `Document` instances. Otherwise, if there are no documents, it\n * returns an empty array. Otherwise, it concatenates the page content of\n * all documents and creates a single `Document` instance with the\n * concatenated content.\n * @param raw The buffer to be parsed.\n * @param metadata The metadata of the document.\n * @returns A promise that resolves to an array of `Document` instances.\n */\n parse(raw: Buffer, metadata: Document[\"metadata\"]): Promise<Document[]>;\n}\ndeclare function PDFLoaderImports(): Promise<{\n getDocument: typeof import(\"pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js\").getDocument;\n version: string;\n}>;\nexport {};\n//# sourceMappingURL=pdf.d.ts.map"],"mappings":";;;;;;;;;AAYA;;;;;;;AA0BiCA,cA1BZE,SAAAA,SAAkBD,YAAAA,CA0BND;EAA+BA,QAAAA,UAAAA;EAARS,QAAAA,KAAAA;EA1BjBR,UAAAA,mBAAAA,EAAAA,MAAAA;EAAY,WAAA,CAAA,cAAA,EAAA,MAAA,GAIVE,IAJU,EAAA;IAAA,UAAA;IAAA,KAAA;IAAA;IAAA,EAAA;IA4BlCI,mBAAgB,CAAA,EAAA,MAAAG,GAAAA,SAAAA;mBAtBVH;;;;;;;;;;;;;;;;;;;;aAoBRC,kBAAkBR,uBAAuBS,QAAQT;;iBAE/CO,gBAAAA,CAAAA,GAAoBE;sBAAJC,4CAAAA,CAC6CC"}