/* tslint:disable */ /* eslint-disable */ /* auto-generated by NAPI-RS */ /** Config for a reusable [`DocumentConverter`]. */ export interface ConverterOptions { /** * Named Whisper model preset for audio sources (English-only / * Distil-Whisper variants under `.models/asr//`). */ asrModel?: string /** * ASR transcription language for audio/video: a Whisper code (`"en"`, * `"de"`, …) or `"auto"` (default) — detected from the first 30 seconds. */ asrLang?: string /** * Character encoding of text inputs (Markdown, CSV, AsciiDoc, WebVTT, * XML, …) — docling's `TextBackendOptions.encoding`: a WHATWG label * (`"shift_jis"`, `"koi8-r"`, `"windows-1251"`). Unset = detect (BOM, * UTF-8, a statistical guess for a non-Latin encoding — #675 — else * windows-1252); bytes it cannot decode fail the conversion. */ encoding?: string /** * Jupyter notebooks (#673): which cell outputs the document keeps — * `"none"` (default, the notebook as written) or `"text"` (stream and * `text/plain` results as code blocks after their cell, image outputs * as pictures). */ ipynbOutputs?: string /** * Document metadata (#679): `"none"` (default, nowhere), `"json"` (a * `metadata` object in the docling JSON) or `"frontmatter"` (YAML * front matter at the top of the Markdown as well). */ metadata?: string /** * Tracked changes in DOCX / DOC / ODT (#851, Pandoc's * `--track-changes`): `"accept"` (insertions shown, deletions left * out), `"reject"` (the reverse) or `"all"` (both, typed with author * and date in the Pandoc AST). Unset: each reader's own view. DOCX * reads all three, DOC accept and reject, ODT accept; a mode a reader * lacks is an error. */ trackChanges?: string /** * DOCX DrawingML drawings (#858): `"mermaid"` (the default) adds a * `mermaid` code item after a drawing's picture with the flowchart its * labelled shapes and connectors describe — only when every connector * names its two end shapes; a drawing laid by eye gets no graph. * `"none"` turns the extraction off. */ extractDiagrams?: string /** * Word (DOCX / DOC): a style's `w:outlineLvl` alone makes it a heading * (docling's `use_outline_level_for_headings`, docling#4480; default * `true`). `false` for templates whose body styles carry an outline * level only for the TOC. */ useOutlineLevelForHeadings?: boolean /** * Max frames sampled from a video input as timestamped pictures (needs * the ffmpeg binary at runtime; `0` = transcript only). Default 8. * `4294967295` (`2**32 - 1`, the largest value this field takes) keeps * every distinct cut (#647). */ videoFrames?: number /** * ffmpeg's scene score (0–1) a video frame must exceed to count as a * cut (#647). Default 0.27; 0.6 keeps hard cuts only. */ videoSceneThreshold?: number /** * Downscale each sampled video frame inside ffmpeg so its longer side * is at most this many px (#647); `0` / unset = the source resolution. */ videoFrameMaxSide?: number /** * Drop a sampled video frame whose 64-bit difference hash is within * this Hamming distance (0–64) of a frame already kept (#647): the same * slide after a fade becomes one picture. Unset = keep every frame; * 4–6 is a good distance. */ videoFrameDedupe?: number /** * XBRL: the directory the instance's taxonomy is read from (docling's * `XBRLBackendOptions.taxonomy`); unset = the instance's own directory. */ xbrlTaxonomy?: string /** * Convert only this PDF page window: `"A-B"` or a single page `"N"` * (1-based inclusive — issue #80). Other formats ignore it. */ pages?: string /** * Per-document budget in seconds for the PDF pipeline (docling's * `document_timeout`, #497); unset = unlimited. Checked between pages: * once spent, the pages done so far are the document, `status` is * `"partial_success"` and `errors` says why. */ documentTimeout?: number /** * Print progress to stderr (#783, docling's `show_progress`): a line * per document, a bar for its pages and each enrichment pass, drawn in * place on a terminal. Default `false`. For your own UI pass a * `progressCallback` to the async conversions instead. */ showProgress?: boolean /** * OCR recognition language for scanned PDF/image pages: `"en"` (default; * proper Latin word spacing) or `"ch"` (the multilingual * docling-conformance model), or a BCP-47 tag for either language — * `"en-US"`, `"eng"`, `"zh"`, `"zh-Hans"`, `"zh-TW"`, docling's `iso:` * prefix accepted (#388); script and region subtags are ignored. Any * other language is an error. Formats that never OCR ignore it. */ ocrLang?: string /** * Which regions feed the OCR (docling's `OcrMode`, #254): `"default"` | * `"full_page"` | `"layout_regions"` | `"pdf_aware_layout_regions"`. * `full_page`/`layout_regions` discard the text layer like * `forceFullPageOcr`. */ ocrMode?: string /** * OCR render scale in px per PDF point (docling's `OcrOptions.scale`, * #254); unset reads the pipeline's own 2.0 px/pt render (docling's * default is 3 = 216 dpi). */ ocrScale?: number /** * Where a PDF's text layer splits words drawn without a space glyph * (#921): `"adaptive"` (default, docling-parse ≥ 7's line-local * threshold; also `DOCLING_RS_PDF_WORD_GAP`) | `"legacy"` * (docling-parse ≤ 6) | a factor such as `"0.2"` of the two flanking * glyphs' mean advance, in (0, 4]. */ pdfWordGap?: string /** * Keep a PDF's typographic punctuation as drawn (#921) — `„ “ ‚ ‘`, * en/em dashes, `…` — instead of folding it to ASCII the way * docling-parse's sanitizer does (the default; also * `DOCLING_RS_PDF_KEEP_TYPOGRAPHY`). */ pdfKeepTypography?: boolean /** * Report what the PDF reader repaired to read the input (#934) on the * result's `pdfRepairs` — a stream whose `/Length` misses its * `endstream`, a padded xref. Off by default (also * `DOCLING_RS_PDF_REPORT_REPAIRS`); the conversion is unchanged. */ pdfReportRepairs?: boolean /** * RapidOCR's text-line orientation handling (#666): oriented line * crops, tall lines turned 90°, upside-down lines turned by the 0/180 * classifier (`.models/ocr_textline_ori.onnx`). Unset = off unless * `DOCLING_RS_OCR_TEXTLINE_ORIENTATION` is set. */ ocrTextlineOrientation?: boolean /** * Picture crops (and page images) in px per PDF point — docling's * `images_scale` (#520), 0.1–4.0; unset keeps the pipeline's 2.0 px/pt * render. The JSON picture `dpi` is 72·scale (#519). */ imagesScale?: number /** * Keep each page's render as the JSON `pages[n].image` — docling's * `generate_page_images` (#520). Default `false`. */ pageImages?: boolean /** * Which OCR engine reads scanned pages (#460): `"ppocr"` (default, the * built-in PP-OCRv3 recognizer) | `"tesseract"` (the system `tesseract` * binary). Under Tesseract `ocrLang` is its language list — tessdata * stems (`"deu+fra"`) or BCP-47 tags. */ ocrEngine?: string /** * Email (.eml/.msg): append an Attachments section — names and content * types only, never the payload (#251). Default `false`. */ listAttachments?: boolean /** * Omit empty cells from sparse XLSX/XLS table grids (#271; docling.rs * extension). Default `false`. */ skipEmptyCells?: boolean /** * Unpadded `| a | b |` Markdown tables, all formats (#271; docling.rs * extension). Default `false`. */ compactTables?: boolean /** * Render pictures' alt text (DOCX/PPTX/XLSX, #676) in Markdown and * HTML; `strict` implies it, JSON has it always. Default `false`. */ pictureAltText?: boolean /** * EBCDIC (#252): copybook layout as inline `EbcdicLayout` JSON or a * file path; defaults to the `.layout.json` sidecar. */ ebcdicLayout?: string /** * Keep layout + TableFormer, never OCR — docling's `do_ocr=False`, its * CLI's `--no-ocr` (#244; since 2.0 the meaning of `noOcr`, #611). * Structured output survives; text that exists only as pixels (scanned * pages, text inside images) comes back empty. Default `false`. */ noOcr?: boolean /** `noOcr` under its pre-2.0 name, still read. */ skipOcr?: boolean /** * Skip the whole PDF ML stack and read the embedded text layer only — * the CLI's `--text-layer-only` (what `noOcr` meant before 2.0, #611). * Default `false`. `"auto"` decides per document: the text layer alone * when it carries the document (no model touched), the full pipeline — * OCR included — when it does not. */ textLayerOnly?: boolean | string /** * The password of an encrypted PDF or Office document — .docx/.xlsx/ * .pptx/.doc/.xls/.ppt (#611, #625). */ password?: string /** * `password` under its pre-#625 name (docling's PDF-only * `--pdf-password`), still read; set one of the two. */ pdfPassword?: string /** * Skip TableFormer — tables come from the layout model's geometry * instead (the CLI's `--no-table-former`, #577). Default `false`. */ noTableFormer?: boolean /** * OCR every PDF page even when it carries an embedded text layer * (docling's `force_full_page_ocr`) — for text layers that exist but lie. * Default `false`. */ forceFullPageOcr?: boolean /** * Keep every detected picture as a picture: disable the demotion of * uncaptioned dense-text "picture" regions into paragraphs (the escape * hatch for image-extraction workflows, #173). Default `false`. */ noTextPanels?: boolean /** * Infer PDF/image section-header levels after assembly (docling's * `HeadingHierarchyModel`, #302): PDF bookmarks are authoritative, then * legal/outline numbering, then font style. Default `false` — headings * then keep the flat detected level. */ headingHierarchy?: boolean /** * Classify every PDF/image picture with DocumentFigureClassifier * (docling's `do_picture_classification`, #423): the 26-class prediction * lands on the JSON picture item's `classification`. Needs * `.models/picture_classifier.onnx`; a missing model warns and skips the * pass. Default `false`. */ doPictureClassification?: boolean /** * Rewrite detected code blocks (and detect their language) with the * CodeFormulaV2 VLM (docling's `do_code_enrichment`, #423). Needs * `.models/code_formula/`; an autoregressive decode per code region — * seconds each on CPU. Default `false`. */ doCodeEnrichment?: boolean /** * Decode display formulas to LaTeX with CodeFormulaV2 (docling's * `do_formula_enrichment`, #423): Markdown renders `$$latex$$` instead * of the formula placeholder comment. Same model and cost as * `doCodeEnrichment`. Default `false`. */ doFormulaEnrichment?: boolean /** * OCR the pictures embedded in non-PDF documents — DOCX/PPTX * screenshots, HTML figures, sampled video frames — with the pipeline's * OCR models and attach the text to the picture as docling's description * annotation (#645): Markdown prints it between the caption and the * image placeholder, the JSON picture item carries `meta.description` + * the `description` annotation, chunks include it. Needs the OCR models * (`.models/ocr_rec*`, `ocr_det.onnx`; or Tesseract under `ocrEngine`); * with `skipOcr` / `textLayerOnly` it warns and reads nothing. PDF/image * pages are OCR'd by the pipeline itself. Default `false`. */ doPictureOcr?: boolean /** * With `doPictureOcr`: only read the pictures the DocumentFigureClassifier * labels as one of these comma-separated classes * (`"screenshot_from_computer,screenshot_from_manual"`); unset = every * picture. Needs `.models/picture_classifier.onnx`. */ pictureOcrClasses?: string /** * With `doPictureOcr`: skip pictures whose smaller side is under this * many pixels (icons, bullets). Default 32 * (`DOCLING_RS_PICTURE_OCR_MIN_SIDE`). */ pictureOcrMinSide?: number /** * The picture OCR's resolution in px per picture pixel under * RapidOCR's 2000 px cap (#666): `1.0` reads pictures at their native * pixels; unset keeps the image-input rule. */ pictureOcrScale?: number /** * `false` drops the embedded image bytes from every picture after the * enrichment pass (#645): slim JSON/DCLX, placeholder-only Markdown, the * OCR text kept. Default `true`. */ keepPictureImages?: boolean /** * Describe every picture — the embedded pictures of DOCX/PPTX/XLSX/ * HTML, a PDF's figures, video frames, an image input as a whole — * through an OpenAI-compatible vision endpoint (#670); the answer is the * picture's description annotation, where `doPictureOcr` puts its text. * `pictureOcrMinSide` / `pictureOcrClasses` select the pictures here * too; identical images are sent once; an endpoint error warns and the * conversion goes on. Default `false`. */ doPictureDescription?: boolean /** * The vision endpoint (`/v1` base or the full `chat/completions` URL); * falls back to `vlmEndpoint`, then `$DOCLING_RS_VLM_ENDPOINT`. */ pictureDescriptionEndpoint?: string /** Model name; falls back to `vlmModel`, then `$DOCLING_RS_VLM_MODEL`. */ pictureDescriptionModel?: string /** Bearer token; falls back to `vlmApiKey`, then `$DOCLING_RS_VLM_API_KEY`. */ pictureDescriptionApiKey?: string /** The instruction sent with every picture; unset = the mode's prompt. */ pictureDescriptionPrompt?: string /** * `"caption"` (default; MarkItDown's caption prompt) | `"ocr"` * (markitdown-ocr's text-extraction prompt). */ pictureDescriptionMode?: string /** Pictures in flight at once (default 1). */ pictureDescriptionConcurrency?: number /** * Redact personal data from the converted document before any export * (#621): e-mail, phone, card numbers (Luhn), IBANs (mod-97), IP * addresses, URL credentials, national IDs, and — with the NER model * under `.models/ner/` — names, organizations and locations; every * string of the document model is rewritten, so Markdown, JSON, DCLX * and chunks all come out clean. The result's `redaction` carries the * counts per label. A docling.rs extension; default `false`. */ redactPii?: boolean /** * `"label"` (default: `[EMAIL]`) | `"pseudonym"` (`[EMAIL_1]`, one * number per distinct value) | `"fixed:"`. */ redactMode?: string /** * Comma-separated kinds to redact (`"email,phone,credit_card,iban, * ip_address,url_credentials,national_id,person,organization,location, * address"`); unset = every kind. */ redactKinds?: string /** * Extra patterns as `NAME=REGEX` lines (newline-separated); the match * (or capture group 1) is redacted as `[NAME]`. */ redactPattern?: string /** * Embedded images and page renders: `"drop"` (default) | `"box_out"` * (OCR and paint over the lines carrying a value) | `"keep"`. */ redactImages?: string /** * With `redactPii` (#694): comma-separated terms never redacted even * when a detector flags them. */ redactAllowTerms?: string /** Comma-separated terms always redacted, as `[REDACTED]`. */ redactDenyTerms?: string /** * Regexes, one per line, a flagged span must not match in full to be * redacted — the document's own part numbers and record IDs. */ redactAllowPatterns?: string /** The NER detector's minimum confidence, 0–1 (default 0.85). */ redactNerMinScore?: number /** * `"standard"` (default) or `"vlm"` (#77): replace the whole ONNX stack — * layout, OCR, TableFormer — with a remote OpenAI-compatible vision * endpoint, which converts each rendered page on its own. PDF and image * inputs only; any other format is rejected rather than silently falling * back, matching the CLI's `--pipeline vlm`. * * Selecting it explicitly is deliberate: the `DOCLING_RS_VLM_*` variables * below are fallbacks, never triggers. A stale `DOCLING_RS_VLM_ENDPOINT` * left in the environment must not silently route every PDF over the * network. * * By the same rule the `vlm_*` options below are read **only** under * `"vlm"`. Passing them with the standard pipeline is not an error and * does not switch pipelines — they are ignored, exactly as the CLI drops * a stray `--vlm-endpoint` given without `--pipeline vlm`. They configure * the VLM; `pipeline` alone selects it. */ pipeline?: string /** * VLM server: the base `/v1` URL or the full `…/chat/completions` one — * the suffix is appended when missing. Falls back to * `$DOCLING_RS_VLM_ENDPOINT`; required when `pipeline` is `"vlm"`. */ vlmEndpoint?: string /** * VLM model name as the server knows it (e.g. `"granite-docling"`). * Falls back to `$DOCLING_RS_VLM_MODEL`; required when `pipeline` is `"vlm"`. */ vlmModel?: string /** * Bearer token for the VLM endpoint; local servers (LM Studio, Ollama, * vLLM) need none. Falls back to `$DOCLING_RS_VLM_API_KEY`. */ vlmApiKey?: string /** * Instruction sent with every page image, overriding docling's * DocLang-eliciting default. Falls back to `$DOCLING_RS_VLM_PROMPT`. */ vlmPrompt?: string /** * `max_tokens` for each page completion. Default `8192` — a dense page of * DocLang runs long, and a truncated answer loses the tail of the page. */ vlmMaxTokens?: number /** * Emit cleaner, more conformant Markdown (code-fence languages preserved, * no inline-run spacing artifacts) instead of docling's byte-for-byte * legacy output. Markdown only. Default `false`. */ strict?: boolean /** * For HTML/EPUB/MHTML/JATS, resolve external `` (data: URIs, local * files, http(s) URLs, EPUB/MHTML archive parts, JATS `` files) * and embed the bytes. Off by default; when on, * http(s) URLs are fetched over the network — enable only for trusted input. * The alias of `imageSources: "remote"` (#646). */ fetchImages?: boolean /** * Which image references resolve (#646): `"none"` (default — every * picture a placeholder), `"embedded"` (`data:` URIs and parts of the * same container: EPUB/MHTML entries, an email's `cid:` attachments — * no filesystem, no network), `"local"` (plus files under the source * file's directory, never an absolute path or one that escapes it), * `"remote"` (plus http(s) fetches). HTML, EPUB, MHTML, JATS, AsciiDoc, * ODF, Markdown and email bodies. */ imageSources?: string /** * Hosts a `"remote"` image fetch may reach (#646): exact names or * `*.suffix` wildcards; redirects are held to the same list. Unset = * any host. */ imageHosts?: Array /** Largest image that resolves, in bytes (#646; default 32 MiB). */ maxImageBytes?: number /** * Images resolved per document; the rest stay placeholders (#646; * default unlimited). */ maxImages?: number /** * Total resolved image bytes per document, in MiB (#646; default * unlimited). */ maxImageTotalMb?: number /** * Smallest image that resolves, in bytes — skips spacer / tracking * pixels (#646; default 0). */ minImageBytes?: number /** * Restrict the converter to these formats (ids like `"md"`, `"pdf"`, or * extensions like `".html"`); anything else is rejected. Default: accept all. */ allowedFormats?: Array } /** Per-call output options (how to render the converted document). */ export interface OutputOptions { /** * `"markdown"` (default), `"json"` (docling-core DoclingDocument wire * format), `"text"` (plain text, docling's `export_to_text`, #613), * `"latex"` (a complete LaTeX document, #317), `"html"` (a * complete HTML document, docling-core's `HTMLDocSerializer`, #492 — * pictures follow `imageMode` like Markdown) or `"pandoc"` (Pandoc's * JSON AST for `pandoc -f json`, #515 — pictures follow `imageMode`) or * `"vtt"` (WebVTT subtitles, docling's `--to vtt`, #614: a cue per timed * text item — an audio/video transcript's segments, a `.vtt` input's * cues). */ to?: string /** * Picture handling for Markdown: `"placeholder"` (default; `"embedded"` * for `to: "pandoc"`, #537), `"embedded"` (base64 data URIs inline), or * `"referenced"` (returns image files in `images`). Ignored for JSON, * which always embeds images as data URIs. */ imageMode?: string /** Directory name used in `referenced` image links. Default `"artifacts"`. */ artifactsDir?: string /** * `to: "pandoc"` (#848): the `Header` depth a section heading gets — * `"docling"` (default: the title is `Header 1`, a level-n section * heading `Header n+1`, docling's Markdown / HTML depth) or `"source"` * (`Header n`: a DOCX `Heading 1` is `Header 1`, as `pandoc -f docx` * reads it). */ pandocHeadingDepth?: string /** * Text inserted between pages in Markdown output — docling's * `export_to_markdown(page_break_placeholder=…)`, e.g. * `""`. A break lands only between two rendered * blocks on different pages (PDF/image pages, slides, sheets, DjVu * pages) — never first or last, empty pages collapse. Unset: no page * breaks, docling's default. Markdown only. */ pageBreakPlaceholder?: string } /** * All options for the one-shot module-level functions (converter config + * output options in a single object). */ export interface ConvertOptions { strict?: boolean fetchImages?: boolean /** Image-source tier (#646): `"none"` | `"embedded"` | `"local"` | `"remote"`. */ imageSources?: string /** Remote image host allow-list (#646). */ imageHosts?: Array /** Largest image that resolves, in bytes (#646). */ maxImageBytes?: number /** Images resolved per document (#646). */ maxImages?: number /** Total resolved image bytes per document, in MiB (#646). */ maxImageTotalMb?: number /** Smallest image that resolves, in bytes (#646). */ minImageBytes?: number /** Named Whisper model preset for audio sources. */ asrModel?: string /** * ASR transcription language for audio/video: a Whisper code (`"en"`, * `"de"`, …) or `"auto"` (default) — detected from the first 30 seconds. */ asrLang?: string /** * Character encoding of text inputs (docling's * `TextBackendOptions.encoding`); unset = detect. */ encoding?: string /** * Jupyter notebooks (#673): which cell outputs the document keeps — * `"none"` (default, the notebook as written) or `"text"` (stream and * `text/plain` results as code blocks after their cell, image outputs * as pictures). */ ipynbOutputs?: string /** * Document metadata (#679): `"none"` (default), `"json"` or * `"frontmatter"`. */ metadata?: string /** * Tracked changes (#851): `"accept"` | `"reject"` | `"all"`; see * [`ConverterOptions::track_changes`]. */ trackChanges?: string /** * Diagram extraction (#858): `"mermaid"` (default) | `"none"`; see * [`ConverterOptions::extract_diagrams`]. */ extractDiagrams?: string /** * Outline-level headings (docling#4480; default `true`); see * [`ConverterOptions::use_outline_level_for_headings`]. */ useOutlineLevelForHeadings?: boolean /** * Max frames sampled from a video input (`0` = transcript only; * `4294967295` = every distinct cut, #647). */ videoFrames?: number /** Scene score (0–1) a video frame must exceed to be a cut (#647). */ videoSceneThreshold?: number /** Cap on a sampled video frame's longer side in px (#647). */ videoFrameMaxSide?: number /** * Difference-hash distance (0–64) under which a sampled video frame is * a duplicate and dropped (#647). */ videoFrameDedupe?: number /** XBRL taxonomy directory (docling's `XBRLBackendOptions.taxonomy`). */ xbrlTaxonomy?: string /** PDF page window `"A-B"` (or `"N"`), 1-based inclusive (#80). */ pages?: string /** * Per-document budget in seconds (docling's `document_timeout`, #497); * see `ConverterOptions.documentTimeout`. */ documentTimeout?: number /** * Print progress to stderr (#783, docling's `show_progress`): a line * per document, a bar for its pages and each enrichment pass, drawn in * place on a terminal. Default `false`. For your own UI pass a * `progressCallback` to the async conversions instead. */ showProgress?: boolean /** * OCR recognition language for scanned pages: `"en"` (default) | `"ch"`, * or a BCP-47 tag for either (`"en-US"`, `"zh-Hans"`, #388). */ ocrLang?: string /** * Which regions feed the OCR (docling's `OcrMode`, #254): `"default"` | * `"full_page"` | `"layout_regions"` | `"pdf_aware_layout_regions"`. */ ocrMode?: string /** * OCR render scale in px per PDF point (docling's `OcrOptions.scale`, * #254); unset reads the pipeline's own 2.0 px/pt render. */ ocrScale?: number /** The PDF text layer's word-gap rule (#921). See [`ConverterOptions`]. */ pdfWordGap?: string /** * Keep a PDF's typographic punctuation as drawn (#921). See * [`ConverterOptions`]. */ pdfKeepTypography?: boolean /** Report the PDF reader's repairs (#934). See [`ConverterOptions`]. */ pdfReportRepairs?: boolean /** * RapidOCR's text-line orientation handling (#666). See * [`ConverterOptions`]. */ ocrTextlineOrientation?: boolean /** * Picture crops (and page images) in px per PDF point — docling's * `images_scale` (#520), 0.1–4.0; unset keeps the pipeline's 2.0 px/pt * render. The JSON picture `dpi` is 72·scale (#519). */ imagesScale?: number /** * Keep each page's render as the JSON `pages[n].image` — docling's * `generate_page_images` (#520). Default `false`. */ pageImages?: boolean /** * Which OCR engine reads scanned pages (#460): `"ppocr"` (default) | * `"tesseract"`. */ ocrEngine?: string /** * Email (.eml/.msg): append an Attachments section — names and content * types only, never the payload (#251). Default `false`. */ listAttachments?: boolean /** * Omit empty cells from sparse XLSX/XLS table grids (#271). Default * `false`. */ skipEmptyCells?: boolean /** Unpadded Markdown tables (#271). Default `false`. */ compactTables?: boolean /** Pictures' alt text (#676) in Markdown and HTML. Default `false`. */ pictureAltText?: boolean /** * EBCDIC (#252): copybook layout as inline `EbcdicLayout` JSON or a * file path; defaults to the `.layout.json` sidecar. */ ebcdicLayout?: string /** * Keep layout + TableFormer, never OCR — docling's `do_ocr=False`, its * CLI's `--no-ocr` (#244; since 2.0 the meaning of `noOcr`, #611). * Structured output survives; text that exists only as pixels (scanned * pages, text inside images) comes back empty. Default `false`. */ noOcr?: boolean /** `noOcr` under its pre-2.0 name, still read. */ skipOcr?: boolean /** * Skip the whole PDF ML stack and read the embedded text layer only — * the CLI's `--text-layer-only` (what `noOcr` meant before 2.0, #611). * Default `false`. `"auto"` decides per document: the text layer alone * when it carries the document (no model touched), the full pipeline — * OCR included — when it does not. */ textLayerOnly?: boolean | string /** * The password of an encrypted PDF or Office document — .docx/.xlsx/ * .pptx/.doc/.xls/.ppt (#611, #625). */ password?: string /** * `password` under its pre-#625 name (docling's PDF-only * `--pdf-password`), still read; set one of the two. */ pdfPassword?: string /** * Skip TableFormer — tables come from the layout model's geometry * instead (the CLI's `--no-table-former`, #577). Default `false`. */ noTableFormer?: boolean /** * OCR every PDF page even when it carries a text layer (docling's * `force_full_page_ocr`). Default `false`. */ forceFullPageOcr?: boolean /** * Keep every detected picture as a picture: disable text-panel demotion * (#173). Default `false`. */ noTextPanels?: boolean /** * Infer PDF/image section-header levels after assembly (#302). Default * `false`. */ headingHierarchy?: boolean /** * Opt-in enrichment models (#423): picture classification, code rewrite * + language, formula LaTeX. See [`ConverterOptions`]. Default `false`. */ doPictureClassification?: boolean doCodeEnrichment?: boolean doFormulaEnrichment?: boolean /** * Picture OCR for non-PDF documents (#645) and its filters. See * [`ConverterOptions`]. Defaults `false` / unset / 32 / `true`. */ doPictureOcr?: boolean pictureOcrClasses?: string pictureOcrMinSide?: number pictureOcrScale?: number keepPictureImages?: boolean /** * Describe every picture — the embedded pictures of DOCX/PPTX/XLSX/ * HTML, a PDF's figures, video frames, an image input as a whole — * through an OpenAI-compatible vision endpoint (#670); the answer is the * picture's description annotation, where `doPictureOcr` puts its text. * `pictureOcrMinSide` / `pictureOcrClasses` select the pictures here * too; identical images are sent once; an endpoint error warns and the * conversion goes on. Default `false`. */ doPictureDescription?: boolean /** * The vision endpoint (`/v1` base or the full `chat/completions` URL); * falls back to `vlmEndpoint`, then `$DOCLING_RS_VLM_ENDPOINT`. */ pictureDescriptionEndpoint?: string /** Model name; falls back to `vlmModel`, then `$DOCLING_RS_VLM_MODEL`. */ pictureDescriptionModel?: string /** Bearer token; falls back to `vlmApiKey`, then `$DOCLING_RS_VLM_API_KEY`. */ pictureDescriptionApiKey?: string /** The instruction sent with every picture; unset = the mode's prompt. */ pictureDescriptionPrompt?: string /** * `"caption"` (default; MarkItDown's caption prompt) | `"ocr"` * (markitdown-ocr's text-extraction prompt). */ pictureDescriptionMode?: string /** Pictures in flight at once (default 1). */ pictureDescriptionConcurrency?: number /** PII redaction (#621) and its settings. See [`ConverterOptions`]. */ redactPii?: boolean redactMode?: string redactKinds?: string redactPattern?: string redactImages?: string /** * With `redactPii` (#694): comma-separated terms never redacted even * when a detector flags them. */ redactAllowTerms?: string /** Comma-separated terms always redacted, as `[REDACTED]`. */ redactDenyTerms?: string /** * Regexes, one per line, a flagged span must not match in full to be * redacted — the document's own part numbers and record IDs. */ redactAllowPatterns?: string /** The NER detector's minimum confidence, 0–1 (default 0.85). */ redactNerMinScore?: number /** * `"standard"` (default) or `"vlm"` (#77): convert PDF/image pages * through a remote OpenAI-compatible vision endpoint instead of the ONNX * stack. The `vlm_*` options below take effect only under `"vlm"` and are * ignored otherwise. See [`ConverterOptions::pipeline`] for the full * contract. */ pipeline?: string /** * VLM server, base `/v1` or full `…/chat/completions` URL. Falls back to * `$DOCLING_RS_VLM_ENDPOINT`. */ vlmEndpoint?: string /** VLM model name. Falls back to `$DOCLING_RS_VLM_MODEL`. */ vlmModel?: string /** Bearer token for the VLM endpoint. Falls back to `$DOCLING_RS_VLM_API_KEY`. */ vlmApiKey?: string /** * Per-page instruction, overriding docling's default DocLang prompt. * Falls back to `$DOCLING_RS_VLM_PROMPT`. */ vlmPrompt?: string /** `max_tokens` per page completion. Default `8192`. */ vlmMaxTokens?: number allowedFormats?: Array to?: string imageMode?: string artifactsDir?: string /** See [`OutputOptions::pandoc_heading_depth`] (#848). */ pandocHeadingDepth?: string /** See [`OutputOptions::page_break_placeholder`]. */ pageBreakPlaceholder?: string } /** In-memory input for [`DocumentConverter::convert`] / [`convert`]. */ export interface ConvertInput { /** Logical document name (used as the docling document name). */ name: string /** Raw file bytes. */ data: Buffer /** * Format id or extension (e.g. `"md"`, `"pdf"`, `".html"`). Omit to infer * from an extension on `name`. */ format?: string } /** One extracted image file, returned for the `referenced` image mode. */ export interface ImageArtifact { /** Path relative to the Markdown file (e.g. `"artifacts/image_000000.png"`). */ path: string /** The image bytes to write at `path`. */ data: Buffer } /** The result of a conversion. */ export interface ConvertResult { /** The rendered document: Markdown or JSON, per `to`. */ content: string /** Detected input format id (e.g. `"md"`, `"pdf"`). */ format: string /** `"success"`, `"partial_success"`, or `"failure"`. */ status: string /** The document name. */ inputName: string /** * For the `referenced` image mode, the image files to write next to the * Markdown; empty otherwise. */ images: Array /** * The problems the conversion survived — docling's * `ConversionResult.errors`; non-empty exactly when `status` is * `"partial_success"` (a spent `documentTimeout`, #497; a VLM page * that failed or came back cut off, #762/#763). */ errors: Array /** * What the PII pass redacted (#621) when `redactPii` was on: counts * per label (`{ EMAIL: 2, PHONE: 1 }`); absent otherwise. */ redaction?: Record /** * What the PDF reader repaired to read the input (#934) when * `pdfReportRepairs` was on and the input is a PDF — `[]` for a * well-formed file; absent otherwise. */ pdfRepairs?: Array } /** One repair the PDF reader made to read the input (#934). */ export interface PdfRepairItem { /** * `"stream_length"` (a stream whose declared `/Length` does not end at * its `endstream`) | `"xref_entries_padded"`. */ kind: string /** The stream's `[object number, generation]`. */ object?: Array /** Byte offset of the object's `N G obj` header. */ offset?: number /** The declared `/Length`; absent when missing or unresolvable. */ declared?: number /** * The recovered length; absent when the stream had no unambiguous end * and was dropped. */ recovered?: number } /** * docling's `ErrorItem`: one recorded problem of a conversion that still * produced a document. */ export interface ConversionErrorItem { /** * `"document_backend"`, `"model"`, `"doc_assembler"`, `"user_input"`, * `"pipeline"`. */ componentType: string /** * The stage that recorded it (`"pipeline"` for the document budget, * `"VlmPipeline"` for a VLM page). */ moduleName: string errorMessage: string /** * The 1-based page the problem belongs to; absent when it is * document-scoped. */ pageNo?: number } /** * One entry of a ZIP archive converted by [`convert_archive`] / * [`convert_archive_file`] (#557): its path inside the archive and what * became of it. */ export interface ArchiveItem { /** The entry's path inside the archive (`/`-separated). */ path: string /** * `"converted"` (`result` is set), `"skipped"` (`error` says why: * unsupported type, nested archive, unsafe path, over a * `DOCLING_RS_ZIP_MAX_*` limit) or `"failed"` (`error` is the * conversion error; the other entries are unaffected). */ outcome: string result?: ConvertResult error?: string } /** * Convert a file on disk. Detects the format from the extension and (for * HTML/EPUB/JATS image fetching) resolves relative `` / `` * paths against the file's directory. */ export declare function convertFile(path: string, options?: ConvertOptions | undefined | null): ConvertResult /** Convert in-memory bytes. */ export declare function convert(input: ConvertInput, options?: ConvertOptions | undefined | null): ConvertResult /** * Async (Promise-returning) [`convert_file`]. The CPU-bound work runs on the * libuv thread pool, keeping the event loop free — use this for PDF/image. */ export declare function convertFileAsync(path: string, options?: ConvertOptions | undefined | null, progress?: (err: Error | null, arg: string) => any | undefined | null): Promise /** Async (Promise-returning) [`convert`]. */ export declare function convertAsync(input: ConvertInput, options?: ConvertOptions | undefined | null, progress?: (err: Error | null, arg: string) => any | undefined | null): Promise /** * Convert every document inside a ZIP archive on disk (#557): one * [`ArchiveItem`] per entry. Throws only when the file is not a readable ZIP. */ export declare function convertArchiveFile(path: string, options?: ConvertOptions | undefined | null): Array /** * Convert every document inside an in-memory ZIP archive (#557); `input.name` * names it, `input.format` is ignored. */ export declare function convertArchive(input: ConvertInput, options?: ConvertOptions | undefined | null): Array /** Async (Promise-returning) [`convert_archive_file`]. */ export declare function convertArchiveFileAsync(path: string, options?: ConvertOptions | undefined | null): Promise> /** Async (Promise-returning) [`convert_archive`]. */ export declare function convertArchiveAsync(input: ConvertInput, options?: ConvertOptions | undefined | null): Promise> /** Options for the chunk* functions. */ export interface ChunkOptions { /** * `"hierarchical"` (default): one chunk per document item, docling's * structure-driven chunker. `"hybrid"`: tokenization-aware refinement — * splits oversized chunks and merges undersized same-heading neighbours; * requires `tokenizer`. */ chunker?: string /** * Path to a HuggingFace `tokenizer.json` (e.g. all-MiniLM-L6-v2's) for the * hybrid chunker's token counts. When omitted, falls back to * `.models/chunk/tokenizer.json` (populated by * `scripts/install/download_dependencies.sh`). */ tokenizer?: string /** * The hybrid chunker's token budget per chunk. Default `256` (docling's * default for the MiniLM embedding model). */ maxTokens?: number /** * Merge undersized peer chunks with the same headings (hybrid only). * Default `true`, matching docling. */ mergePeers?: boolean } /** One chunk record — the analogue of docling's `DocChunk`. */ export interface Chunk { /** The chunk body (markdown-flavoured text, same as docling's `DocChunk.text`). */ text: string /** * The heading path above the chunk, outermost first; absent for content * above any heading. */ headings?: Array /** * JSON-pointer refs of the document items the chunk was built from * (`"#/texts/12"`, `"#/tables/0"`, …). */ docItems: Array /** * The embedding-ready rendering: heading path + text, newline-joined * (docling's `chunker.contextualize(chunk)`). */ contextualized: string } /** * Chunk a file on disk with docling's chunkers: convert it, then run the * hierarchical (default) or hybrid chunker over the document. */ export declare function chunkFile(path: string, options?: ChunkOptions | undefined | null): Array /** * Async (Promise-returning) [`chunk_file`]; conversion + chunking run on the * libuv thread pool. */ export declare function chunkFileAsync(path: string, options?: ChunkOptions | undefined | null): Promise> /** Chunk in-memory bytes (same contract as [`convert`], then chunk). */ export declare function chunk(input: ConvertInput, options?: ChunkOptions | undefined | null): Array /** Async (Promise-returning) [`chunk`]. */ export declare function chunkAsync(input: ConvertInput, options?: ChunkOptions | undefined | null): Promise> /** * Chunk an already-converted document, passed as docling-core JSON (the * `content` of a `convert*` call with `to: "json"`) — so a document converted * once (e.g. through the warm PDF `Pipeline`) can be chunked without * re-converting. */ export declare function chunkDocument(documentJson: string, options?: ChunkOptions | undefined | null): Array /** Async (Promise-returning) [`chunk_document`]. */ export declare function chunkDocumentAsync(documentJson: string, options?: ChunkOptions | undefined | null): Promise> /** * Chunk a file and stream each chunk as the chunkers produce it — no * all-chunks array is materialized, and the first chunk reaches JS while the * rest of the document is still being chunked. * * `callback` is invoked as `(err, chunk)`: once per chunk with `chunk` a * `Chunk`, once with `chunk === null` at the end, or once with a non-null * `err` on failure. Prefer the `streamFileChunks` async-generator wrapper in * JS over calling this directly. */ export declare function chunkFileStreaming(path: string, callback: (err: Error | null, arg: Chunk | undefined | null) => any, options?: ChunkOptions | undefined | null): void /** * Streaming [`chunk`]: chunk in-memory bytes, pushing each chunk through the * callback (same contract as [`chunk_file_streaming`]). Prefer the * `streamChunks` async-generator wrapper in JS. */ export declare function chunkStreaming(input: ConvertInput, callback: (err: Error | null, arg: Chunk | undefined | null) => any, options?: ChunkOptions | undefined | null): void /** * Streaming [`chunk_document`]: chunk an already-converted docling-core JSON * document, pushing each chunk through the callback (same contract as * [`chunk_file_streaming`]). Prefer the `streamDocumentChunks` * async-generator wrapper in JS. */ export declare function chunkDocumentStreaming(documentJson: string, callback: (err: Error | null, arg: Chunk | undefined | null) => any, options?: ChunkOptions | undefined | null): void /** One attachment of an `.eml` / Outlook `.msg`, from [`email_attachments`]. */ export interface EmailAttachment { /** Position among the message's attachments. */ index: number /** * A safe file name, unique within the message (base name only, control * and bidi-format characters removed; `attachment-N` when the message * declares none, `.eml` for a forwarded message; a repeated * name gets `-2`, `-3`, …) — safe to write into one directory as it is. */ name: string /** The declared media type (`type/subtype`), if any. */ contentType?: string /** * The format id it converts as (`"pdf"`, `"docx"`, `"email"`, …), from * its extension, else its media type, else the bytes; absent when * `skipped` says why it will not convert. */ format?: string /** Payload size in bytes (0 without a payload). */ size: number /** * An image the message shows inline (part of the HTML body) rather than * a file to open; a PDF disposed `inline` is still `false` (#564). */ inline: boolean /** * Why it is not converted, when it is not: no payload (a reference, an * OLE object), over a limit, a nested archive, an unsupported type. */ skipped?: string /** * The payload, when kept: every attachment with a payload within the * limits — also an unsupported type or an archive (hand a `.zip` to * your own extractor). Absent over a limit or without a payload. */ data?: Buffer } /** * Bounds on what [`email_attachments`] keeps, in bytes. Unset = the archive * defaults: 10 000 attachments, 256 MiB each, 1 GiB in all. */ export interface EmailAttachmentOptions { maxEntries?: number maxEntrySize?: number maxTotalSize?: number } /** * The attachments of an in-memory `.eml` / `.msg` with their payloads. A * forwarded message is an `.eml` entry whose `data` is the nested message. * Convert one with `convert({ name: att.name, data: att.data, format: att.format })` * — `format` carries what the extension cannot (a `scan.bin` sent as * `application/pdf`, a nameless sniffed part; #564). */ export declare function emailAttachments(input: ConvertInput, options?: EmailAttachmentOptions | undefined | null): Array /** [`email_attachments`] for a message file on disk. */ export declare function emailAttachmentsFile(path: string, options?: EmailAttachmentOptions | undefined | null): Array /** * Async (Promise-returning) [`email_attachments`]: a large `.msg` parses off * the event loop (#564). */ export declare function emailAttachmentsAsync(input: ConvertInput, options?: EmailAttachmentOptions | undefined | null): Promise> /** Async (Promise-returning) [`email_attachments_file`]. */ export declare function emailAttachmentsFileAsync(path: string, options?: EmailAttachmentOptions | undefined | null): Promise> /** The list of supported input format ids. */ export declare function supportedFormats(): Array /** * Detect a format id from a filename or extension (e.g. `"report.pdf"` → * `"pdf"`). Returns `null` for unknown extensions. */ export declare function formatFromName(name: string): string | null /** * The format a buffer evidently is, by its content alone (#672 — the * engine's `InputFormat::detect`): the format id, or `null` for bytes * without a signature (prose, Markdown, CSV, random bytes). Signatures * only: PDF, the Office / ODF / EPUB / iWork packages, the OLE files, * RTF, HTML, the raster images, DjVu, audio and video containers, * WordPerfect, WebVTT, DocTags, SVG, AbiWord, XML, JSON and Jupyter * notebooks, MIME messages, LaTeX. What `convert({ name, data })` does * for a name with no or an unknown extension. */ export declare function detectFormat(data: Buffer): string | null /** * A reusable converter. Holds config (strict / fetch-images / allowed formats) * so you can convert many documents without re-parsing options each time — * the analogue of the Rust `DocumentConverter`. */ export declare class DocumentConverter { constructor(options?: ConverterOptions | undefined | null) /** Convert a file on disk (sync). */ convertFile(path: string, options?: OutputOptions | undefined | null): ConvertResult /** Convert in-memory bytes (sync). */ convert(input: ConvertInput, options?: OutputOptions | undefined | null): ConvertResult /** Async (Promise-returning) file conversion (runs off the event loop). */ convertFileAsync(path: string, options?: OutputOptions | undefined | null, progress?: (err: Error | null, arg: string) => any | undefined | null): Promise /** Async (Promise-returning) bytes conversion (runs off the event loop). */ convertAsync(input: ConvertInput, options?: OutputOptions | undefined | null, progress?: (err: Error | null, arg: string) => any | undefined | null): Promise /** * Convert every document inside a ZIP archive on disk (#557), with this * converter's config per entry (sync). */ convertArchiveFile(path: string, options?: OutputOptions | undefined | null): Array /** Convert every document inside an in-memory ZIP archive (#557) (sync). */ convertArchive(input: ConvertInput, options?: OutputOptions | undefined | null): Array /** Async (Promise-returning) archive conversion from disk. */ convertArchiveFileAsync(path: string, options?: OutputOptions | undefined | null): Promise> /** Async (Promise-returning) archive conversion from bytes. */ convertArchiveAsync(input: ConvertInput, options?: OutputOptions | undefined | null): Promise> /** * Stream a file's Markdown in chunks, in document order, as conversion * progresses (the headline win for PDF, whose pages convert in parallel). * * `callback` is invoked as `(err, chunk)`: once per Markdown chunk with * `chunk` a string, once with `chunk === null` at the end, or once with a * non-null `err` on failure. Every image mode streams here, `referenced` * included (its links resolve against `artifactsDir`) — unlike the warm * [`Pipeline`]'s streaming, which rejects it. Prefer the * `streamFileMarkdown` async-generator wrapper in JS over calling this * directly. */ convertFileStreaming(path: string, callback: (err: Error | null, arg: string | undefined | null) => any, options?: OutputOptions | undefined | null): void } /** * A reusable PDF/image pipeline that keeps the ONNX models (layout, OCR, * TableFormer) loaded across calls — the analogue of the Rust `Pipeline`. Use * this instead of the per-call `convertFile` when converting many PDFs/images: * the one-shot functions rebuild the pipeline (reloading every model) each * call, whereas this loads them once. * * Handles `pdf` and `image` inputs (the ML pipeline). Models load lazily on * first use, so constructing a `Pipeline` is cheap; the first conversion pays * the model-load cost. Synchronous and single-threaded — reuse one instance * for a sequence of documents (e.g. behind a job queue). */ export declare class Pipeline { /** * Construct the pipeline. `strict` (cleaner Markdown), the three * enrichment switches (`doPictureClassification`, `doCodeEnrichment`, * `doFormulaEnrichment`, #423) and every PDF/image option the one-shot * calls honour — `ocrEngine`, `ocrLang`, `ocrMode`, `ocrScale`, `pdfWordGap`, * `pdfKeepTypography`, * `noOcr`, `textLayerOnly`, `password`, `forceFullPageOcr`, * `noTextPanels`, `headingHierarchy`, * `pages` — are read here and apply to every conversion on this * instance, validated exactly as `DocumentConverter` validates them * (#471; before, only `strict` and the enrichment switches were read * and a `por+eng` Tesseract pipeline silently ran PP-OCR English). * `fetchImages` / `allowedFormats` and the non-PDF options don't apply * to the PDF/image pipeline. */ constructor(options?: ConverterOptions | undefined | null) /** Convert a PDF or image file, reusing the warm models. */ convertFile(path: string, options?: OutputOptions | undefined | null): ConvertResult /** Convert PDF or image bytes, reusing the warm models. */ convert(input: ConvertInput, options?: OutputOptions | undefined | null): ConvertResult /** * Async (Promise-returning) file conversion on the warm pipeline. The * CPU-bound work runs on the libuv thread pool, keeping the event loop * free; calls on the same instance run one at a time (the models are * mutable sessions), so overlapping Promises queue in submission order. */ convertFileAsync(path: string, options?: OutputOptions | undefined | null, progress?: (err: Error | null, arg: string) => any | undefined | null): Promise /** Async (Promise-returning) bytes conversion on the warm pipeline. */ convertAsync(input: ConvertInput, options?: OutputOptions | undefined | null, progress?: (err: Error | null, arg: string) => any | undefined | null): Promise /** * Stream a PDF's Markdown in chunks through the warm pipeline, in document * order, as pages finish converting (an image converts in one step and * arrives as a single chunk). * * `callback` is invoked as `(err, chunk)`: once per Markdown chunk with * `chunk` a string, once with `chunk === null` at the end, or once with a * non-null `err` on failure. Only `placeholder` / `embedded` image modes * stream; `referenced` is rejected. Prefer the `streamFileMarkdown` * async-generator wrapper in JS over calling this directly. */ convertFileStreaming(path: string, callback: (err: Error | null, arg: string | undefined | null) => any, options?: OutputOptions | undefined | null): void }