mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-26 20:14:47 +00:00
feat: Add visualization of bbox on page with html export.
Signed-off-by: Peter Staar <taa@zurich.ibm.com>
This commit is contained in:
parent
2579d89510
commit
c9735de4c6
@ -12,6 +12,12 @@ from typing import Annotated, Dict, List, Optional, Type
|
|||||||
|
|
||||||
import rich.table
|
import rich.table
|
||||||
import typer
|
import typer
|
||||||
|
from docling_core.transforms.serializer.html import (
|
||||||
|
HTMLDocSerializer,
|
||||||
|
HTMLOutputStyle,
|
||||||
|
HTMLParams,
|
||||||
|
)
|
||||||
|
from docling_core.transforms.visualizer.layout_visualizer import LayoutVisualizer
|
||||||
from docling_core.types.doc import ImageRefMode
|
from docling_core.types.doc import ImageRefMode
|
||||||
from docling_core.utils.file import resolve_source_to_path
|
from docling_core.utils.file import resolve_source_to_path
|
||||||
from pydantic import TypeAdapter
|
from pydantic import TypeAdapter
|
||||||
@ -156,6 +162,7 @@ def export_documents(
|
|||||||
export_json: bool,
|
export_json: bool,
|
||||||
export_html: bool,
|
export_html: bool,
|
||||||
export_html_split_page: bool,
|
export_html_split_page: bool,
|
||||||
|
# export_html_localization: bool,
|
||||||
export_md: bool,
|
export_md: bool,
|
||||||
export_txt: bool,
|
export_txt: bool,
|
||||||
export_doctags: bool,
|
export_doctags: bool,
|
||||||
@ -189,9 +196,23 @@ def export_documents(
|
|||||||
if export_html_split_page:
|
if export_html_split_page:
|
||||||
fname = output_dir / f"{doc_filename}.html"
|
fname = output_dir / f"{doc_filename}.html"
|
||||||
_log.info(f"writing HTML output to {fname}")
|
_log.info(f"writing HTML output to {fname}")
|
||||||
|
"""
|
||||||
conv_res.document.save_as_html(
|
conv_res.document.save_as_html(
|
||||||
filename=fname, image_mode=image_export_mode, split_page_view=True
|
filename=fname, image_mode=image_export_mode, split_page_view=True
|
||||||
)
|
)
|
||||||
|
"""
|
||||||
|
ser = HTMLDocSerializer(
|
||||||
|
doc=conv_res.document,
|
||||||
|
params=HTMLParams(
|
||||||
|
image_mode=image_export_mode,
|
||||||
|
output_style=HTMLOutputStyle.SPLIT_PAGE,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
ser_res = ser.serialize(
|
||||||
|
visualizer=LayoutVisualizer(),
|
||||||
|
)
|
||||||
|
with open(fname, "w") as fw:
|
||||||
|
fw.write(ser_res.text)
|
||||||
|
|
||||||
# Export Text format:
|
# Export Text format:
|
||||||
if export_txt:
|
if export_txt:
|
||||||
|
769
poetry.lock
generated
769
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,7 @@ packages = [{ include = "docling" }]
|
|||||||
######################
|
######################
|
||||||
python = "^3.9"
|
python = "^3.9"
|
||||||
pydantic = "^2.0.0"
|
pydantic = "^2.0.0"
|
||||||
docling-core = {version = "^2.29.0", extras = ["chunking"]}
|
docling-core = "^2.31.2"
|
||||||
docling-ibm-models = "^3.4.0"
|
docling-ibm-models = "^3.4.0"
|
||||||
docling-parse = "^4.0.0"
|
docling-parse = "^4.0.0"
|
||||||
filetype = "^1.2.0"
|
filetype = "^1.2.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user