You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ODS: pictures anchored to the sheet are dropped #4677
Pictures anchored to an ODS sheet (stored in <table:shapes>) are dropped. The conversion reports SUCCESS, and the only trace is a debug log:
Could not extract image from ODS sheet: 'DrawImage' object has no attribute 'get_data'
Pictures anchored to a cell are kept, because the rich cell path adds them.
OdsDocumentBackend._find_images_in_sheet reads each picture with img.get_data(), but odfdo's DrawImage has no get_data() (checked in odfdo 3.22.0 and 3.26.3), so the call raises for every picture and the except hides it.
#4557 changed this function, but it was merged into a stacked branch that didn't reach main (#4553 was closed), so main still has the get_data() call.
Steps to reproduce
fromodfdoimportDocument, Element, Frame, TablefromPILimportImagefromdocling.document_converterimportDocumentConverterImage.new("RGB", (200, 100), "red").save("red.png")
doc=Document("spreadsheet")
doc.body.clear()
table=Table("Sheet1", width=2, height=2)
doc.body.append(table)
# A picture anchored to cell B2cell=table.get_cell("B2")
cell.append(Frame.image_frame(doc.add_file("red.png"), size=("2cm", "1cm")))
table.set_cell("B2", cell)
# A picture anchored to the sheet, stored in <table:shapes>shapes=Element.from_tag("table:shapes")
shapes.append(
Frame.image_frame(doc.add_file("red.png"), size=("2cm", "1cm"), position=("1cm", "1cm"))
)
table.insert(shapes, position=0)
doc.save("pictures.ods")
result=DocumentConverter().convert("pictures.ods")
print(result.status, len(result.document.pictures)) # ConversionStatus.SUCCESS 1, expected 2
Activity
fix(odf): keep ODS pictures anchored to the sheet (#4678)