From b6b1af097b175dc1eabd4c1a6bd9d22e19a2092c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Nov 2020 16:24:17 +0530 Subject: [PATCH] DOCX Input: When converting images placed using the obsolete VML markup default them to being inline rather than block images. Fixes #1905319 [Centered images aren't centered after conversion](https://bugs.launchpad.net/calibre/+bug/1905319) Also seems to match Word behavior. --- src/calibre/ebooks/docx/images.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/docx/images.py b/src/calibre/ebooks/docx/images.py index 55130e1fbc..8c326f8360 100644 --- a/src/calibre/ebooks/docx/images.py +++ b/src/calibre/ebooks/docx/images.py @@ -306,9 +306,12 @@ class Images(object): except LinkedImageNotFound as err: self.log.warn('Linked image: %s not found, ignoring' % err.fname) continue - img = IMG(src='images/%s' % src, style="display:block") + style = get(imagedata.getparent(), 'style') + img = IMG(src='images/%s' % src) alt = get(imagedata, 'o:title') img.set('alt', alt or 'Image') + if 'position:absolute' in style: + img.set('style', 'display: block') yield img def get_float_properties(self, anchor, style, page):