docling-project / docling-project/docling

How can I extract the content of headers and footers from a DOCX file?

Open
#1,394 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### I want to extract the content of headers and footers from a DOCX file

Version:2.30.0

I want to extract text in follow place of docx.

![Image](https://github.com/user-attachments/assets/8d8be841-febb-4bf3-b551-5878e83e1684)

![Image](https://github.com/user-attachments/assets/217d0dba-7045-44c5-8d64-09b1e6075e19)

Now it only extract main content like:

![Image](https://github.com/user-attachments/assets/affaa5e1-eaf8-45b3-906e-7b6ca13ba086)

My extract code is:

```python

ocr_options = RapidOcrOptions(force_full_page_ocr=False)
pdf_pipeline_options = PdfPipelineOptions(artifacts_path=pdf_artifacts_path, ocr_options=ocr_options)
pdf_pipeline_options.do_ocr = True

converter = DocumentConverter(
format_options = {
InputFormat.PDF: PdfFormatOption(pipeline_options=pdf_pipeline_options),
InputFormat.IMAGE: ImageFormatOption(pipeline_options=pdf_pipeline_options),
}
)

source = "header_test.docx"
result = converter.convert(source)
print(result.document.export_to_markdown()) # 输出Markdown

```
Is there any way to help me achieve the recognition of this part of the content? Can it be done through configuration?

...
My test docx is :
[header_test.docx](https://github.com/user-attachments/files/19746582/header_test.docx)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.