@docling/docling-components

中文文档
0.0.11发布于 2026/10/06MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2241

Web components for displaying Docling output.

原始使用文档
文档目录6 节
  1. Install package
  2. Document components
  3. docling-img
  4. docling-table
  5. Item components
  6. Annotation components

Docling Components

Web components for displaying Docling output, which simplifies document processing, parsing diverse formats — including advanced PDF understanding. This package requires the JSON output of documents that are converted by Docling. Get started with the interactive examples.

Install package

In case of a client or single page application that is bundled upfront:

npm i @docling/docling-components

Next, import the package at the application root to install the components:

import '@docling/docling-components';

In case of a static or server-side rendered website; add the package to the page HTML. Either download the package and serve it as part of the rest of the website, or use a CDN mirror of NPM:

<html>
  <head>
    ...

    <script
      type="module"
      src="https://unpkg.com/@docling/docling-components/dist/index.es.js"
    />
  </head>

  ...
</html>

Document components

docling-img

This component displays the converted document in context of its original form, by showing the full page renderings that are embedded in the conversion JSON (for specific input document formats). Each document item is shown as a bounding box on top of the page.

Plain use

Similar to <img> you can point the component to the Docling JSON file.

<docling-img src="conversion.json"></docling-img>

Or load the document programmatically:

<script type="module">
  const cmp = document.getElementById('cmp');

  const fetched = await fetch('conversion.json');
  const doc = await fetched.json();
  cmp.src = doc;
</script>
...
<docling-img id="cmp" pagenumbers></docling-img>

Item filter and highlight

Narrow down the marked document items according to their reference path in the converted document:

<docling-img src="conversion.json" items="#/pictures/3"></docling-img>

Select entire item categories with items="#/pictures", full pages with items="#/pages/2", and unions with items="#/pictures, #/tables".

Or select specific items programmatically:

<script type="module">
  const cmp = document.getElementById('cmp');
  const fetched = await fetch('conversion.json');
  const doc = await fetched.json();
  cmp.src = doc;

  // Select the first three tables.
  cmp.items = doc.tables.slice(0, 3);
</script>
...
<docling-img id="cmp" pagenumbers></docling-img>

To emphasize item selections, you can suppress the non-selection into a page backdrop and/or trim out the pages without any selected items:

<docling-img
  src="conversion.json"
  items="#/pictures"
  trim="pages"
  backdrop
></docling-img>

Tooltip

Pops up a tooltip besides an item when you hover it on a page. This tooltip shows the item's parsed content and annotations if matching web components are available:

<docling-img src="conversion.json">
  <docling-tooltip></docling-tooltip>
</docling-img>

Overlay

Overlays parsed content and annotations directly on top of items (potentially occluding them).

<docling-img src="conversion.json">
  <docling-overlay></docling-overlay>
</docling-img>

docling-table

This component displays the converted document as a table of parsed document items, with columns for item contents and an image from the rendered document (if available).

Plain use

<docling-table src="conversion.json"></docling-table>

You can select items with the items attributes, as described for the docling-img component. Selecting items will trim all non-selected items from view.

Configure columns

Select the columns that you want to have shown and in what order:

<docling-table src="conversion.json">
  <docling-column>
    <docling-item-text></docling-item-text>
    <docling-item-table></docling-item-table>
  </docling-column>
  <docling-column>
    <docling-item-provenance></docling-item-provenance>
  </docling-column>
</docling-table>

You can use this to display the cropped image of a single document item as well:

<docling-table src="conversion.json" items="#/tables/2">
  <docling-column>
    <docling-item-provenance></docling-item-provenance>
  </docling-column>
</docling-table>

Item components

Most types of document item have a prepackaged component that will be used to visualize it:

TagItem label
<docling-item-text>checkbox_selected
checkbox_unselected
footnote
page_footer
page_header
paragraph
text
reference
<docling-item-table>table

You can use these tags directly with elements like <docling-tooltip> to specify what components will be used, including optional parameters. For example, to exclusively show tooltips for table components:

<docling-tooltip>
  <docling-item-table></docling-item-table>
</docling-tooltip>

You can create your own item components by extending from the DoclingItemElement class at /src/item/ItemElement.ts and annotating the class with @customDoclingItemElement('docling-my-first-item-component') to have it registered as both a custom web element and as a default component for rendering document items.

Annotation components

Some types of document item annotation have a prepackaged component that will be used to visualize it:

TagItem labelAnnotation kind
<docling-picture-classification>chart
picture
classification
<docling-picture-description>chart
picture
description

You can use these tags directly with elements like <docling-tooltip> to specify what components will be used. For example, to overlay pictures with their classification, if any:

<docling-overlay>
  <docling-picture-classification></docling-picture-classification>
</docling-overlay>

You can create your own annotation components by extending from the DoclingAnnotationElement class at /src/annotation/AnnotationElement.ts and annotating the class with @customDoclingAnnotationElement('docling-my-first-annotation-component') to have it registered as both a custom web element and as a default component for rendering document annotations.

版本与发布记录

@docling/docling-components 共发布 8 个版本,首次发布于 2025/02/04;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.11latest2026/10/061 个月前
0.0.102026/09/281 个月前
0.0.72025/05/081.5 年前
0.0.62025/04/151.6 年前
0.0.52025/03/281.6 年前
0.0.42025/03/141.7 年前

关于 @docling/docling-components 的常见问题

@docling/docling-components 是什么?

Web components for displaying Docling output.

如何安装 @docling/docling-components?

在项目目录运行 npm install @docling/docling-components,或使用 pnpm add / yarn add / bun add。

@docling/docling-components 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@docling/docling-components 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@docling/docling-components 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@docling/docling-components 可以商用吗?

@docling/docling-components 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@docling/docling-components 的下载量有多少?

根据 npm 官方下载统计,@docling/docling-components 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,241 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@docling/docling-components 还在维护吗?

最新版本 0.0.11 发布于 2026/10/06(1 个月前);至今共发布 8 个版本,其中过去 12 个月发布了 2 个;首次发布于 2025/02/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。