@xberg-io/llamaindex-xberg
v1.0.14
Published
LlamaIndex.TS reader and node parser for Xberg — extract text, tables, metadata, and structure-aware nodes from 101 document formats with optional OCR.
Maintainers
Readme
@xberg-io/llamaindex-xberg
A LlamaIndex.TS reader and node parser for Xberg.
XbergReader turns a file, a directory, or raw bytes into LlamaIndex Documents with the extracted
text, tables, and rich metadata from 101 formats — with optional OCR for scans and images.
XbergNodeParser then splits those documents into TextNodes along Xberg's own semantic boundaries
(native chunks, or structural elements) instead of a blind character window.
Extraction runs locally in-process through the @xberg-io/xberg native binding. No API key, no cloud
call, no data leaves your machine.
Installation
@llamaindex/core is a peer dependency — install it alongside the reader:
npm install @xberg-io/llamaindex-xberg @llamaindex/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 { XbergReader } from "@xberg-io/llamaindex-xberg";
// Single file — one Document (or one per page with pages.extractPages)
const reader = new XbergReader();
const docs = await reader.loadData("report.pdf");
// Multiple files — one batched extraction
const many = await reader.loadData(["a.pdf", "b.docx"]);
// Raw bytes — mimeType is required
const fromBytes = await reader.loadData({ data: fileBytes, mimeType: "application/pdf" });By default the reader requests Xberg's element_based result format so each document carries a
structural element stream for the node parser. Errors are logged and the failed input is skipped; pass
{ raiseOnError: true } to propagate them instead.
Structure-aware node parsing
Pair the reader with XbergNodeParser to split documents into nodes along Xberg's boundaries. It
prefers native chunks (ExtractionConfig.chunking) and falls back to structural elements:
import { XbergReader, XbergNodeParser } from "@xberg-io/llamaindex-xberg";
const reader = new XbergReader({ extractionConfig: { chunking: { max_chars: 1000, max_overlap: 200 } } });
const documents = await reader.loadData("report.pdf");
const parser = new XbergNodeParser();
const nodes = parser.getNodesFromDocuments(documents);The reader forwards the chunk/element payload on private metadata keys that are excluded from LLM and embedding input; the parser consumes them and strips them from the emitted nodes.
Supported 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.
