Skip to content

itext/GIDS2026

Repository files navigation

Tagged PDF to Markdown

This project contains iText 9.5 examples and two main entrypoints:

  • com.itextpdf.demo.ComplexTaggedPdfMain (creates a complex, tagged PDF 2.0 report)
  • com.itextpdf.demo.TaggedPdfToMarkdownMain (converts a PDF to Markdown using the structure tree)

It reads a PDF and tries to build Markdown using the PDF structure tree (tagged content). If tags are missing or empty, it falls back to plain text extraction.

The converter prepends YAML front matter for dataset pipelines:

  • source_file
  • page_count
  • extraction_mode (tagged_structure_tree or plain_text_fallback)

Build

mvn clean compile

Run the Converter

mvn -q dependency:build-classpath "-Dmdep.outputFile=target\cp.txt"
$cp = Get-Content "target\cp.txt"
java -cp "target\classes;$cp" com.itextpdf.demo.TaggedPdfToMarkdownMain "input.pdf" "output.md"

If output.md is omitted, the converter writes next to the input PDF using the same file name with .md extension.

Generate a Complex Tagged PDF 2.0

mvn -q dependency:build-classpath "-Dmdep.outputFile=target\cp.txt"
$cp = Get-Content "target\cp.txt"
java -cp "target\classes;$cp" com.itextpdf.demo.ComplexTaggedPdfMain

This creates complex-tagged-report.pdf in the project root.

Extract Markdown with Python + Docling

Install Python dependencies:

python -m pip install -r requirements.txt

Run the Docling extractor (defaults to complex-tagged-report.pdf):

python scripts/docling_extract.py

Run with explicit paths:

python scripts/docling_extract.py --input "complex-tagged-report.pdf" --output "complex-tagged-report.docling.md"

By default, the script writes <input>.docling.md next to the input PDF.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors