Heading level offset

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Markdown MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-markdown -- dnx GroupDocs.Markdown.Mcp --yes
Folders, licensing and more →

On this page

Use setHeadingLevelOffset to shift all heading levels in the output by a fixed number. This is useful when embedding converted content inside a larger document where top-level headings are already in use.

Example

import com.groupdocs.markdown.*;

public class HeadingOffsetExample {

    public static void main(String[] args) {
        DocumentConvertOptions options = new DocumentConvertOptions();
        options.setHeadingLevelOffset(2);

        MarkdownConverter.toFile("annual-report.docx", "heading-offset-example.md", options);

        // Source: # Title     → Output: ### Title
        // Source: ## Section  → Output: #### Section
        // Heading levels are clamped to the range 1-6.
    }
}

annual-report.docx is a sample file used in this example. Click here to download it.

![](data:...;base64,[elided])

**Annual Report 2025**

Meridian Outdoor Co.


### **Table of Contents**

Meridian Outdoor Co.	1
[TRUNCATED]

Download full output

On this page