docling-project / docling-project/docling
Severe Markdown Conversion Issues: Cropped/Missing Images, Mixed Layout
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
Most of my presentations consist of a combination of screenshots and textual explanations (e.g., tutorials or system usage guides). However, during the conversion process, I’ve encountered the following problems:
Images are cropped: Some images appear only partially, resulting in missing visual content.
Mixed image and text layout: In several cases, images and their related text are merged or positioned in a disordered way.
Missing images: Some slides that contain images result in Markdown output with the images missing entirely.
Images interpreted as tables: Some screenshots (e.g., reports or UI elements) are interpreted as tables and are converted accordingly, which leads to misrepresentation.
I’ve confirmed that the .pptx to .pdf conversion using LibreOffice preserves the original layout and content properly, so these issues appear to be introduced during the Markdown conversion phase.
### Attempts and Observations
Here’s what I’ve tried so far:
Directly converting .pptx files with docling (without converting to PDF first): this yielded even poorer results.
Setting picture_area_threshold to 0 in the pipeline config: no notable improvements.
Customizing MarkdownPictureSerializer to append image annotations: useful for adding descriptions but did not resolve the core issues.
### Steps to reproduce
Convert .pptx files to .pdf using LibreOffice.
Use docling to convert the resulting .pdf into Markdown format, with embedded images and descriptions.
```
def convert_to_pdf(input_path: str, output_dir: Path) -> Path:
if not os.path.isfile(input_path):
raise FileNotFoundError(f"Can't find file:{input_path}")
command = [
'soffice',
'--headless',
'--convert-to', 'pdf',
'--outdir', str(output_dir),
input_path
]
subprocess.run(command, check=True)
base_name = Path(input_path).stem
pdf_path = output_dir / f"{base_name}.pdf"
if not pdf_path.exists():
raise FileNotFoundError(f"Can't Find PDF:{pdf_path}")
return pdf_path
def create_picture_description_options(model: str, prompt: str, picture_area_threshold: float = 0.0) -> PictureDescriptionApiOptions:
return PictureDescriptionApiOptions(
url="http://localhost:11434/v1/chat/completions",
params={"model": model},
prompt=prompt,
timeout=300,
scale=1.0,
picture_area_threshold=picture_area_threshold
)
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=PdfPipelineOptions(
generate_picture_images=True,
do_picture_description=True,
enable_remote_services=True,
accelerator_options=accelerator_options,
picture_description_options=create_picture_description_options(
model=MODEL_NAME,
prompt=PROMPT,
picture_area_threshold=0.0
)
)
)
}
)
```
### Docling version
Docling version: 2.31.0
...
### Python version
Python 3.11.11
For security and confidentiality reasons, I'm unable to share the actual document used in production. However, I’ve created and attached a simplified example (sample.pptx) that reproduces the key issues I encountered during the conversion process.
[sample.pptx](https://github.com/user-attachments/files/20601489/sample.pptx)
...
Contributor guide
Assessment
This issue has not been assessed yet.