{"data":{"slug":"github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-621650d2484d","title":"Xberg Document Extraction","summary":"Extract text, tables, metadata, and images from documents using Xberg. Supports multiple languages and formats.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-621650d2484d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-621650d2484d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-621650d2484d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-621650d2484d\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"The tool requires installation via pip, npm, cargo, or CLI, and supports Python, Node.js, Rust, and CLI for integration into workflows.","instructions":"---\ntype: Playbook\ntitle: Xberg\ndescription: Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg. Use when writing code that calls Xberg APIs in Python, Node.js\/TypeScript, Rust, or CLI. Covers installation, extraction (sync\/async), configuration (OCR, chunking, output format), batch processing, error handling, and plugins.\nx-ai-rulez:\n  kind: skill\n  id: xberg\n  metadata:\n    license: Elastic-2.0\n    metadata:\n      author: xberg-io\n      version: \"0.1.0\"\n      repository: https:\/\/github.com\/xberg-io\/xberg\n    name: xberg\n---\n\n# Xberg Document Extraction\n\nXberg is a document intelligence library with a Rust core and bindings for Python, TypeScript\/Node.js, Ruby, PHP, Go, Java, C#, Elixir, WebAssembly, Dart, Kotlin Android, Swift, Zig, and C. It extracts text, tables, metadata, and images from 107 formats across 140 unique file extensions and accepts 53 compatibility MIME aliases, including PDF, Office documents, images, HTML, email, archives, and academic formats.\n\nUse this skill when writing code that:\n\n- Extracts text or metadata from documents\n- Performs OCR on scanned documents or images\n- Batch-processes multiple files\n- Configures extraction options (output format, chunking, OCR, language detection)\n- Implements custom plugins (post-processors, validators, OCR backends)\n\n> If the `xberg` MCP server is registered in this session, prefer its tools over shelling out to the CLI \u2014 they expose the same extraction surface with structured arguments and results.\n\n## Installation\n\n### Python\n\n```bash\npip install xberg\n```\n\n### Node.js\n\n```bash\nnpm install @xberg-io\/xberg\n```\n\n### Rust\n\n```bash\ncargo add xberg\n```\n\n```toml\n# Cargo.toml\n[dependencies]\nxberg = { version = \"1.1.0\", features = [\"full\"] }\ntokio = { version = \"1\", features = [\"full\"] }\n# feature flags: pdf, ocr, chunking, embeddings, language-detection, keywords, api, mcp\n#                (or \"formats\" \/ \"full\" aggregates); tokio-runtime is on by default\n```\n\n### CLI\n\n```bash\nbrew install xberg-io\/tap\/xberg\n# or run without a persistent install (the CLI proxy package self-installs the binary):\nnpx @xberg-io\/xberg-cli@1.3.10 --help\nuvx --from xberg-cli==1.3.8 xberg --help\n# or download a prebuilt binary from the latest GitHub release:\n#   https:\/\/github.com\/xberg-io\/xberg\/releases\/latest\n# or build from source:\ncargo install xberg-cli\n```\n\n## Quick Start\n\nThe library entry points are `extract(input, config)` and `extract_batch(inputs, config)`. Both return an `ExtractionResult` **envelope** \u2014 the extracted document(s) live in `result.results`, and per-document data (`content`, `tables`, `metadata`, \u2026) is on each `result.results[i]`. Python and Node are async-only.\n\n### Python\n\n```python\nimport asyncio\nfrom xberg import ExtractInput, extract, ExtractionConfig\n\nasync def main() -> None:\n    result = await extract(ExtractInput(uri=\"document.pdf\"), ExtractionConfig())\n    doc = result.results[0]\n    print(doc.content)    # extracted text\n    print(doc.metadata)   # document metadata\n    print(doc.tables)     # extracted tables\n\nasyncio.run(main())\n```\n\n### Node.js\n\n```typescript\nimport { extract } from \"@xberg-io\/xberg\";\n\nconst output = await extract({ kind: \"uri\", uri: \"document.pdf\" });\nconst doc = output.results[0];\nconsole.log(doc.content);\nconsole.log(doc.metadata);\nconsole.log(doc.tables);\n```\n\n### Rust\n\n```rust\nuse xberg::{extract, ExtractInput, ExtractionConfig};\n\n#[tokio::main]\nasync fn main() -> xberg::Result<()> {\n    let output = extract(ExtractInput::from_uri(\"document.pdf\"), &ExtractionConfig::default()).await?;\n    println!(\"{}\", output.results[0].content);\n    Ok(())\n}\n```\n\n### CLI\n\n```bash\nxberg extract document.pdf\nxberg extract document.pdf --format json\nxberg extract document.pdf --content-format markdown\n```\n\n## Configuration\n\nAll languages use the same configuration structure with language-appropriate naming conventions.\n\n### Python (snake_case)\n\n```python\nfrom xberg import (\n    ExtractInput, extract,\n    ExtractionConfig, OcrConfig, TesseractConfig, PdfConfig, ChunkingConfig, OutputFormat,\n)\n\nconfig = ExtractionConfig(\n    ocr=OcrConfig(\n        backend=\"tesseract\",\n        language=[\"eng\"],\n        tesseract_config=TesseractConfig(psm=6, enable_table_detection=True),\n    ),\n    pdf_options=PdfConfig(passwords=[\"secret123\"]),\n    chunking=ChunkingConfig(max_characters=1000, overlap=200),\n    output_format=OutputFormat(\"markdown\"),\n)\n\nresult = await extract(ExtractInput(uri=\"document.pdf\"), config)\n```\n\n### Node.js (camelCase)\n\n```typescript\nimport { extract, type ExtractionConfig } from \"@xberg-io\/xberg\";\n\nconst config: ExtractionConfig = {\n  ocr: { backend: \"tesseract\", language: [\"eng\"] },\n  pdfOptions: { passwords: [\"secret123\"] },\n  chunking: { maxCharacters: 1000, overlap: 200 },\n  outputFormat: \"markdown\",\n};\n\nconst output = await extract({ kind: \"uri\", uri: \"document.pdf\" }, config);\n```\n\n### Rust (snake_case)\n\n```rust\nuse xberg::{extract, ExtractInput, ExtractionConfig, OcrConfig, ChunkingConfig, OutputFormat};\n\nlet config = ExtractionConfig {\n    ocr: Some(OcrConfig {\n        backend: \"tesseract\".into(),\n        language: vec![\"eng\".to_string()],\n        ..Default::default()\n    }),\n    chunking: Some(ChunkingConfig {\n        max_characters: 1000,\n        overlap: 200,\n        ..Default::default()\n    }),\n    output_format: OutputFormat::Markdown,\n    ..Default::default()\n};\n\nlet output = extract(ExtractInput::from_uri(\"document.pdf\"), &config).await?;\n```\n\n### Config File (TOML)\n\n```toml\noutput_format = \"markdown\"\n\n[ocr]\nbackend = \"tesseract\"\nlanguage = \"eng\"\n\n[chunking]\nmax_characters = 1000\noverlap = 200\n\n[pdf_options]\npasswords = [\"secret123\"]\n```\n\n```bash\n# CLI: auto-discovers xberg.toml\/yaml\/yml\/json in current\/parent directories\nxberg extract doc.pdf\n# or explicit:\nxberg extract doc.pdf --config xberg.toml\nxberg extract doc.pdf --config-json '{\"ocr\":{\"backend\":\"tesseract\",\"language\":\"deu\"}}'\n```\n\n## Batch Processing\n\n`extract_batch` takes a list of `ExtractInput`s and returns one envelope whose `results` array holds documents in discovery order; one input may yield multiple documents. Per-input failures are reported in `result.errors` with an input index.\n\n### Python\n\n```python\nfrom xberg import ExtractInput, extract_batch, ExtractionConfig\n\ninputs = [\n    ExtractInput(uri=\"doc1.pdf\"),\n    ExtractInput(uri=\"doc2.docx\"),\n    ExtractInput(uri=\"doc3.xlsx\"),\n]\noutput = await extract_batch(inputs, ExtractionConfig())\n\nfor doc in output.results:\n    print(f\"{len(doc.content)} chars extracted\")\n```\n\n### Node.js\n\n```typescript\nimport { extractBatch } from \"@xberg-io\/xberg\";\n\nconst output = await extractBatch([\n  { kind: \"uri\", uri: \"doc1.pdf\" },\n  { kind: \"uri\", uri: \"doc2.docx\" },\n]);\nfor (const doc of output.results) {\n  console.log(`${doc.content.length} chars`);\n}\n```\n\n### Rust\n\n```rust\nuse xberg::{extract_batch, ExtractInput, ExtractionConfig};\n\nlet config = ExtractionConfig::default();\nlet inputs = vec![ExtractInput::from_uri(\"doc1.pdf\"), ExtractInput::from_uri(\"doc2.docx\")];\nlet output = extract_batch(inputs, &config).await?;\n```\n\n### CLI\n\n```bash\nxberg batch *.pdf --format json\nxberg batch docs\/*.docx --content-format markdown\n```\n\n## OCR\n\nOCR runs automatically for images and scanned PDFs. Tesseract is the default backend (native binding, no external install required).\n\n### Backends\n\nSelect with `OcrConfig.backend`:\n\n- **tesseract** (default): built-in native binding. All Tesseract languages supported.\n- **paddleocr** (`\"paddleocr\"` \/ `\"paddle-ocr\"`): ONNX-based PaddleOCR.\n- **vlm**: Vision-Language-Model OCR (configure via `OcrConfig.vlm_config`).\n\nCustom backends can be registered in Python\/Node via `register_ocr_backend` (see [Advanced Features](..\/..\/references\/advanced-features.md)).\n\n### Language Codes\n\n```python\nconfig = ExtractionConfig(ocr=OcrConfig(language=[\"eng\"]))          # English\nconfig = ExtractionConfig(ocr=OcrConfig(language=[\"eng\", \"deu\"]))   # Multiple\n# The single-string shorthand (\"eng+deu\") is only accepted in config files \/ --config-json,\n# not in the OcrConfig constructor (Python takes a list, Node takes an array).\n```\n\n### Force OCR\n\n```python\nconfig = ExtractionConfig(force_ocr=True)  # OCR even if text is extractable\n```\n\n## Result Envelope and Document Fields\n\n`extract` \/ `extract_batch` return an `ExtractionResult` envelope: `results` (list of documents), `errors` (per-input failures), and `summary` (counts). Per-document fields live on each document in `results` \u2014 bind `doc = result.results[0]` (Python\/Node) or `&output.results[0]` (Rust) first.\n\n| Field        | Python (`doc.`)        | Node.js (`doc.`)      | Rust (`document.`)      | Description                                   |\n| ------------ | ---------------------- | --------------------- | ----------------------- | --------------------------------------------- |\n| Text content | `content`              | `content`             | `content`               | Extracted text (str\/String)                   |\n| MIME type    | `mime_type`            | `mimeType`            | `mime_type`             | Input document MIME type                      |\n| Metadata     | `metadata`             | `metadata`            | `metadata`              | Document metadata (flat mapping)              |\n| Tables       | `tables`               | `tables`              | `tables`                | Extracted tables with cells + markdown        |\n| Languages    | `detected_languages`   | `detectedLanguages`   | `detected_languages`    | Detected languages (if enabled)               |\n| Chunks       | `chunks`               | `chunks`              | `chunks`                | Text chunks (if chunking enabled)             |\n| Images       | `images`               | `images`             | `images`                | Extracted images (if enabled)                 |\n| Elements     | `elements`             | `elements`            | `elements`              | Semantic elements (if element_based format)   |\n| Pages        | `pages`                | `pages`               | `pages`                 | Per-page content (if page extraction enabled) |\n| Keywords     | `extracted_keywords`   | `extractedKeywords`   | `extracted_keywords`    | Extracted keywords (if enabled)               |\n\n## Error Handling\n\n### Python\n\n`extract` \/ `extract_batch` raise an exported `XbergError` subclass, such as `ParsingError`, `SecurityError`, or `ValidationError`, including calls with `on_progress`. Catch `XbergError` for extraction failures. Per-input failures during `extract_batch` are reported non-fatally in `result.errors`.\n\n```python\nfrom xberg import ExtractInput, extract, ExtractionConfig, XbergError\n\ntry:\n    result = await extract(ExtractInput(uri=\"file.pdf\"), ExtractionConfig())\n    for err in result.errors:\n        print(f\"Per-input error: {err}\")\nexcept XbergError as e:\n    print(f\"Extraction failed: {e}\")\n```\n\n### Node.js\n\nThe Node binding throws plain `Error` objects (it does not export typed error subclasses). Catch with `instanceof Error`, and inspect `output.errors` for non-fatal per-input failures.\n\n```typescript\nimport { extract } from \"@xberg-io\/xberg\";\n\ntry {\n  const output = await extract({ kind: \"uri\", uri: \"file.pdf\" });\n  if (output.errors.length > 0) {\n    console.error(\"Per-input errors:\", output.errors);\n  }\n} catch (e) {\n  if (e instanceof Error) {\n    console.error(`Extraction failed: ${e.message}`);\n  }\n}\n```\n\n### Rust\n\n```rust\nuse xberg::{extract, ExtractInput, ExtractionConfig, XbergError};\n\nlet config = ExtractionConfig::default();\nmatch extract(ExtractInput::from_uri(\"file.pdf\"), &config).await {\n    Ok(output) => println!(\"{}\", output.results[0].content),\n    Err(XbergError::Parsing { message, .. }) => eprintln!(\"Parse error: {message}\"),\n    Err(XbergError::Ocr { message, .. }) => eprintln!(\"OCR error: {message}\"),\n    Err(XbergError::UnsupportedFormat(mime)) => eprintln!(\"Unsupported: {mime}\"),\n    Err(e) => eprintln!(\"Error: {e}\"),\n}\n```\n\n## Common Pitfalls\n\n1. **Result is an envelope**: `extract` \/ `extract_batch` return `ExtractionResult` with `results`, `errors`, and `summary`. Per-document fields (`content`, `tables`, `chunks`, \u2026) are on `result.results[i]`, NOT on the top-level return.\n2. **Async-only**: Python and Node have no sync variants \u2014 always `await extract(...)`. Rust `extract` is async; use `#[tokio::main]` or an async context.\n3. **Build the input**: pass an `ExtractInput`, not a bare path. Use `ExtractInput(uri=...)` \/ `ExtractInput::from_uri(...)` (Python\/Rust) or `{ kind: \"uri\", uri: \"...\" }` (Node); for bytes use `kind=\"bytes\"` with `bytes`\/`mime_type`.\n4. **Python ChunkingConfig fields**: construct with `max_characters` and `overlap` (defaults 1000 \/ 200); these are also the readable attributes. When passing config as a dict\/JSON, the `max_chars` \/ `max_overlap` aliases are also accepted. Node uses `maxCharacters` \/ `overlap`; Rust struct fields are `max_characters` \/ `overlap`.\n5. **Python errors**: catch `XbergError` or a specific exported subclass for `extract` \/ `extract_batch` failures, including calls with `on_progress`. Node throws plain `Error` (no typed error subclasses).\n6. **Rust extract signature**: `extract(input, &config)` \u2014 the config is a reference. Use `&ExtractionConfig::default()` for defaults.\n7. **CLI --format vs --content-format**: `--format` controls CLI output (`text`, `json`, or `toon`). `--content-format` controls content rendering (`plain`, `markdown`, `djot`, `html`, `json`, or `doctags`).\n8. **Config file field names**: Use snake_case in TOML\/YAML\/JSON config files \u2014 `[chunking]` fields are `max_characters` and `overlap`; other fields use names like `output_format`, `pdf_options`.\n\n## Supported Formats (Summary)\n\n| Category          | Extensions                                                                                                                                                  |\n| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **PDF**           | `.pdf`                                                                                                                                                      |\n| **Word**          | `.docx`, `.docm`, `.doc`, `.dotx`, `.dotm`, `.dot`, `.odt`, `.pages`, `.wpd`, `.wp`, `.wp5`, `.wp6`, `.hwp`, `.hwpx`                                       |\n| **Spreadsheets**  | `.xlsx`, `.xlsm`, `.xlsb`, `.xls`, `.xla`, `.xlam`, `.xltm`, `.xltx`, `.xlt`, `.ods`, `.numbers`                                                            |\n| **Presentations** | `.pptx`, `.pptm`, `.ppt`, `.pps`, `.ppsx`, `.potx`, `.potm`, `.pot`, `.odp`, `.key`                                                                         |\n| **eBooks**        | `.epub`, `.fb2`                                                                                                                                             |\n| **Images**        | `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.bmp`, `.tiff`, `.tif`, `.jp2`, `.jpg2`, `.j2c`, `.j2k`, `.jpc`, `.jbig2`, `.jb2`, `.pnm`, `.pbm`, `.pgm`, `.ppm`, `.heic`, `.heics`, `.heif`, `.heifs`, `.hif`, `.avif`, `.avcs`, `.svg` |\n| **Markup**        | `.html`, `.htm`, `.xhtml`, `.xht`, `.xml`, `.kml`                                                                                                           |\n| **Data**          | `.json`, `.geojson`, `.jsonl`, `.ndjson`, `.yaml`, `.yml`, `.toml`, `.csv`, `.tsv`, `.dbf`, `.sqlite`, `.sqlite3`, `.db`, `.gpkg`, `.gpkx`                  |\n| **Text**          | `.txt`, `.adoc`, `.asciidoc`, `.vtt`, `.md`, `.markdown`, `.commonmark`, `.qmd`, `.rmd`, `.mdx`, `.djot`, `.dj`, `.doctags`, `.rst`, `.org`, `.rtf`       |\n| **Email**         | `.eml`, `.msg`, `.pst`                                                                                                                                      |\n| **Archives**      | `.zip`, `.tar`, `.tgz`, `.gz`, `.7z`                                                                                                                        |\n| **Audio\/Video**   | `.mp3`, `.mpga`, `.m4a`, `.wav`, `.webm`, `.mp4`, `.mpg4`, `.mp4v`, `.m4v`, `.mpeg`, `.mpg`, `.mpe`, `.m1v`, `.m2v`                                     |\n| **Academic**      | `.bib`, `.ris`, `.nbib`, `.enw`, `.tex`, `.latex`, `.typ`, `.typst`, `.jats`, `.nxml`, `.ipynb`, `.docbook`, `.dbk`, `.docbook4`, `.docbook5`, `.opml`      |\n\nCSL JSON is supported through an explicit MIME type but does not have a registered file extension.\n\nSee [..\/..\/references\/supported-formats.md](..\/..\/references\/supported-formats.md) for the complete format reference with MIME types.\n\n## Additional Resources\n\nDetailed reference files for specific topics:\n\n- **[Python API Reference](..\/..\/references\/python-api.md)** \u2014 All functions, config classes, plugin protocols, exact signatures\n- **[Node.js API Reference](..\/..\/references\/nodejs-api.md)** \u2014 All functions, TypeScript interfaces, worker pool APIs\n- **[Rust API Reference](..\/..\/references\/rust-api.md)** \u2014 All functions with feature gates, structs, Cargo.toml examples\n- **[CLI Reference](..\/..\/references\/cli-reference.md)** \u2014 All commands, flags, config precedence, exit codes\n- **[Configuration Reference](..\/..\/references\/configuration.md)** \u2014 TOML\/YAML\/JSON formats, auto-discovery, env vars, full schema\n- **[Supported Formats](..\/..\/references\/supported-formats.md)** \u2014 Format families, extensions, capabilities, and authoritative discovery commands\n- **[Advanced Features](..\/..\/references\/advanced-features.md)** \u2014 Plugins, embeddings, MCP server, API server, security limits\n- **[Other Language Bindings](..\/..\/references\/other-bindings.md)** \u2014 Go, Ruby, Java, C#, PHP, Elixir, WASM, Dart, Kotlin Android, Swift, Zig, C, and Docker\n\n## Related skills\n\nTask-focused sibling skills go deeper than this overview:\n\n- **xberg-extracting-with-ocr** \u2014 OCR backends, language packs, force-OCR, tuning.\n- **xberg-extracting-tables** \u2014 layout-aware table detection and table models.\n- **xberg-chunking** \u2014 chunk size\/overlap, markdown\/yaml\/semantic chunkers, the `chunk` command.\n- **xberg-extracting-keywords** \u2014 YAKE\/RAKE keywords, language detection, the `embed` command.\n- **xberg-batch-extraction** \u2014 the `batch` command, `--file-configs`, parallelism, error recovery.\n- **xberg-picking-a-format** \u2014 choosing `--format` \/ `--content-format` per consumer.\n\nFull documentation: <https:\/\/docs.xberg.io>\nGitHub: <https:\/\/github.com\/xberg-io\/xberg>\n","use_cases":["Extract text and metadata from PDF documents for content analysis","Process multiple documents in batch for data research","Integrate document extraction into a software development workflow"],"limitations":[],"compatibility":[],"setup_tip":"### Python\n\n```bash\npip install xberg\n```\n\n### Node.js\n\n```bash\nnpm install @xberg-io\/xberg\n```\n\n### Rust\n\n```bash\ncargo add xberg\n```\n\n```toml\n# Cargo.toml\n[dependencies]\nxberg = { version = \"1.1.0\", features = [\"full\"] }\ntokio = { version = \"1\", features = [\"full\"] }\n# feature flags: pdf, ocr, chunking, embeddings, language-detection, keywords, api, mcp\n#                (or \"formats\" \/ \"full\" aggregates); tokio-runtime is on by default\n```\n\n### CLI\n\n```bash\nbrew install xberg-io\/tap\/xberg\n# or run without a persistent install (the CLI proxy package self-installs the binary):\nnpx @xberg-io\/xberg-cli@1.3.10 --help\nuvx --from xberg-cli==1.3.8 xberg --help\n# or download a prebuilt binary from the latest GitHub release:\n#   https:\/\/github.com\/xberg-io\/xberg\/releases\/latest\n# or build from source:\ncargo install xberg-cli\n```","sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/plugin\/.ai-rulez\/skills\/xberg\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T14:21:46.000000Z","updated_at":"2026-11-16T05:16:54.000000Z","seo_title":"Xberg Document Extraction Tool","seo_description":"Extract text, tables, metadata, and images from PDF, Office, and other formats with Xberg. Supports Python, Node.js, Rust, and CLI.","seo_keywords":["document extraction","PDF text extraction","Xberg API","document metadata extraction","batch document processing"]}}