ODP: slides are not pages and items have no provenance, unlike PPTX
Bug
When an ODP presentation is converted, the document has no pages and no item says which slide it is on, so filtering by page, page numbers on chunks and page breaks in DocTags all come out empty, while the same deck saved as PPTX has them.
OdpDocumentBackend is a PaginatedDocumentBackend and counts slides as pages (page_count, L2044-L2048), but its convert (L2055-L2087) never adds a page, and no item gets provenance. doc.pages is empty and every prov list is empty.
The PowerPoint backend adds a page per slide (L1986-L1987) and gives each item the slide number and its shape box (_generate_prov, L550-L577); the ODS backend adds a page per sheet (L2377).
Impact
For the same two-slide deck, as .odp and saved as .pptx by LibreOffice:
.odp |
.pptx |
|
|---|---|---|
doc.num_pages() |
0 | 2 |
export_to_markdown(page_no=2) |
'' |
slide 2 |
page numbers in HierarchicalChunker chunks |
none | 1, 2 |
page break in export_to_doctags() |
no | yes |
Steps to reproduce
from io import BytesIO
from docling.datamodel.base_models import DocumentStream
from docling.document_converter import DocumentConverter
from docling_core.transforms.chunker import HierarchicalChunker
from odfdo import Document, DrawPage, Frame
deck = Document("presentation")
deck.body.clear()
for number in (1, 2):
page = DrawPage(f"page{number}", name=f"Slide {number}", master_page="presentation")
page.append(Frame.text_frame(f"Title {number}", size=("20cm", "3cm"), position=("2cm", "2cm"), presentation_class="title"))
page.append(Frame.text_frame(f"Body {number}", size=("20cm", "3cm"), position=("2cm", "6cm")))
deck.body.append(page)
buffer = BytesIO()
deck.save(buffer)
buffer.seek(0)
doc = DocumentConverter().convert(DocumentStream(name="deck.odp", stream=buffer)).document
print("pages:", sorted(doc.pages))
for text in doc.texts:
print(repr(text.text), "prov:", [(p.page_no, tuple(round(v) for v in p.bbox.as_tuple())) for p in text.prov])
print("export_to_markdown(page_no=2):", repr(doc.export_to_markdown(page_no=2)))
print("chunk pages:", [sorted({p.page_no for item in c.meta.doc_items for p in item.prov}) for c in HierarchicalChunker().chunk(doc)])
Output:
pages: []
'Title 1' prov: []
'Body 1' prov: []
'Title 2' prov: []
'Body 2' prov: []
export_to_markdown(page_no=2): ''
chunk pages: [[], []]
Expected: pages 1 and 2, and each item on its slide.
Possible fix
Add a page per slide, sized from the page layout of the slide's master page, and give the items of each shape the slide number and the shape's box from svg:x, svg:y, svg:width and svg:height (the whole slide when the shape has no position, an empty box for speaker notes), as the PowerPoint backend does. A PR with this change and tests follows; it does not apply draw:transform and does not cover shapes inside draw:g, whose text is not read at this commit (#4738, open PR #4747).
Docling version
docling main at commit a7760abf (v2.150.0-17), docling-core 2.106.0; the line numbers above are from that commit. Also reproduced on the docling 2.150.0 release with docling-core 2.106.0.
Python version
3.12.13 (main), 3.14.4 (2.150.0 release)
Classification labels added: bug, priority:medium, odf.
These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.