@xberg-io/langchain-xberg
v1.0.14
Published
LangChain.js document loader for Xberg — extract text, tables, and metadata from 101 document formats with optional OCR.
Maintainers
Readme
@xberg-io/langchain-xberg
A LangChain.js document loader for Xberg.
Point it at a file, a directory, or raw bytes and it returns LangChain Documents with the extracted
text, tables, and rich metadata from 101 document formats — with optional OCR for scans and images.
Extraction runs locally in-process through the @xberg-io/xberg native binding. No API key, no cloud
call, no data leaves your machine.
Installation
@langchain/core is a peer dependency — install it alongside the loader:
npm install @xberg-io/langchain-xberg @langchain/coreNode.js 20.15+ is required on a platform for which @xberg-io/xberg ships a prebuilt binary (Linux
x64/arm64 glibc or musl, macOS arm64, Windows x64/arm64).
Quick start
import { XbergLoader } from "@xberg-io/langchain-xberg";
// Single file — one Document
const loader = new XbergLoader({ filePath: "report.pdf" });
const docs = await loader.load();
console.log(docs[0].pageContent, docs[0].metadata);
// Multiple files or a directory — one batched extraction
const many = new XbergLoader({ filePath: "./docs", glob: "**/*.pdf" });
// Raw bytes — mimeType is required
const bytes = new XbergLoader({ data: fileBytes, mimeType: "application/pdf" });One Document per chunk (retrieval)
Enable chunking on the ExtractionConfig to emit one Document per chunk, each carrying heading
path, page span, and token-count metadata ready to embed:
const loader = new XbergLoader({
filePath: "report.pdf",
config: { chunking: { max_chars: 1000, max_overlap: 200 } },
});
const chunks = await loader.load();One Document per page
const loader = new XbergLoader({
filePath: "report.pdf",
config: { pages: { extractPages: true } },
});
const pages = await loader.load(); // metadata.page is 0-indexedSupported formats
Xberg extracts from 101 formats including PDF, DOCX, PPTX, XLSX, HTML, EPUB, images, and more. See the Xberg documentation for the full list and the extraction configuration reference.
Part of Xberg.io
- Xberg — document intelligence: text, tables, metadata from 101 formats with optional OCR.
- Xberg Enterprise — managed extraction API with SDKs, dashboards, and observability.
