Skip to content

[Improvement] Support PDF heading hierarchy inference (HeadingHierarchyOptions) in ConvertDocumentOptions #754

Closed

Description

@Krambamboli

Description

In Python Docling (docling.datamodel.pipeline_options.PdfPipelineOptions), HeadingHierarchyOptions (heading_hierarchy_options) allows reconstructing a true H1 -> H6 heading tree from PDF bookmarks, outline numbering (1.1, 1.2.1), and font/visual styles instead of emitting all detected section_header elements flat at level 1:

from docling.datamodel.pipeline_options import HeadingHierarchyOptions, PdfPipelineOptions

pipeline_options = PdfPipelineOptions(
    heading_hierarchy_options=HeadingHierarchyOptions(
        enabled=True,
        max_level=6,
        use_bookmarks=True,
        use_numbering=True,
        use_style=True,
        use_font_style=True,
    )
)

Currently, there is no way to enable or configure HeadingHierarchyOptions via ConvertDocumentOptions in docling-java (nor via a DOCLING_SERVE_* container environment variable).

Why this is important for Java RAG pipelines

When using docling-java with Spring AI or LangChain4j for RAG ingestion, structure-aware chunkers (HybridChunker / HierarchicalChunker) rely on the document's heading levels to group sections and build hierarchical metadata paths (e.g., Chapter 1 > 1.2 Methodology). Without HeadingHierarchyOptions, PDF headings frequently remain flat at level 1.

Proposed Change

Expose heading hierarchy configuration in ConvertDocumentOptions (and the underlying docling-serve options schema), e.g.:

  • doHeadingHierarchy(Boolean) / headingHierarchyOptions(HeadingHierarchyOptions) (enabled, maxLevel, useBookmarks, useNumbering, useStyle, useFontStyle).

Activity

  1. edeandrea commented on Oct 22, 2026

    @edeandrea
    Contributor

    Thanks @Krambamboli for this issue! I'll get working on it!

  2. edeandrea commented on Oct 22, 2026

    @edeandrea
    Contributor
  3. allcontributors commented on Oct 22, 2026

    @allcontributors
    Contributor

    @edeandrea

    This project's configuration file has malformed JSON: .all-contributorsrc. Error:: Unexpected string in JSON at position 6440

  4. edeandrea commented on Oct 22, 2026

    @edeandrea
    Contributor
  5. allcontributors commented on Oct 22, 2026

    @allcontributors
    Contributor

    @edeandrea

    I've put up a pull request to add @Krambamboli! 🎉

  6. added a commit that references this issue on Oct 22, 2026
    a932fe4
  7. docling-java-ops commented on Oct 22, 2026

    @docling-java-ops
    Contributor

    🎉 This issue has been resolved in v0.7.1 (Release Notes)

  8. Krambamboli commented on Oct 23, 2026

    @Krambamboli
    Author

    @edeandrea Thank you so much for the fast response, I really appreciate it. This makes our ingestion pipeline way better.

  9. edeandrea commented on Oct 23, 2026

    @edeandrea
    Contributor

    You're very welcome! Keep the reports coming! Its hard to keep up with Docling's pydantic model. Everything is manual unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    releasedIssue has been released

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions