docling icon indicating copy to clipboard operation
docling copied to clipboard

can it identify the sections, like which section is the heading which one is the table etc if yes share a code snippet on how to do it

Open madmaxtwentytwo opened this issue 1 year ago • 3 comments

Question

...

madmaxtwentytwo avatar Aug 05 '25 11:08 madmaxtwentytwo

Hi @madmaxtwentytwo! I'm Dosu and I’m helping the docling team.

Yes, Docling can identify and classify sections like headings, tables, titles, and more in documents. After parsing a document, you can programmatically access these sections using the DoclingDocument API. Here’s a basic example of how to extract headings and tables:

from docling.document_converter import DocumentConverter
from docling_core.types.doc.document import SectionHeaderItem, TableItem

# Parse your document (supports docx, html, md, pdf, etc.)
doc = DocumentConverter().convert("your_document.docx").document

# Extract headings (section headers)
headings = [item for item in doc.texts if isinstance(item, SectionHeaderItem)]
for heading in headings:
    print(f"Heading (level {heading.level}): {heading.text}")

# Extract tables
for table in doc.tables:
    print("Table:")
    print(table.export_to_markdown(doc=doc))  # or table.export_to_dataframe()

You can also use the HierarchicalChunker to chunk the document into sections and get heading metadata for each chunk:

from docling_core.transforms.chunker import HierarchicalChunker

chunks = list(HierarchicalChunker().chunk(doc))
for chunk in chunks:
    print("Section Headings:", chunk.meta.headings)
    print("Chunk Text:", chunk.text)

SectionHeaderItem objects have a level attribute for heading depth, and TableItem objects provide structured access to table data. This works well for docx, html, and markdown; PDF heading hierarchy is still being improved (source, source, source).

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about docling Share Dosu with your team

dosubot[bot] avatar Aug 05 '25 11:08 dosubot[bot]

are there any specific settings that i have to enable inorder to get the text from images?

the below code is unable to extract text from the images which are there in the ppt

from docling.document_converter import DocumentConverter source = "22804.pptx" # Local file or URL converter = DocumentConverter() result = converter.convert(source) print(result.document.export_to_markdown())

madmaxtwentytwo avatar Aug 12 '25 03:08 madmaxtwentytwo

There aren't any settings you can enable in Docling to extract text from images inside PPTX files. The current backend for PPTX only extracts images as picture objects—it doesn't run OCR or pull text from those images. OCR options (like do_ocr, ocr_engine, ocr_lang) are available for PDFs and standalone image files, but not for PPTX files processed with the SimplePipeline and MsPowerpointDocumentBackend. If you need text from images in a PPTX, you'll need to extract the images separately (for example, by unzipping the PPTX and grabbing the files from /ppt/media) and then run them through an external OCR tool like Tesseract or EasyOCR. This is a known limitation and a feature that users have requested, but it's not implemented yet (source, source).

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about docling with Dosu Add Dosu to your team

dosubot[bot] avatar Aug 12 '25 04:08 dosubot[bot]