The second image is the exported DOCX:
I'm unsure as to why this is happening. I've tried several ways to handle the image, including this method:
- Code: Select all
def _insert_image_to_paragraph(self, paragraph: object, image_path: str, width: int = None, height: int = None, alignment: str = None):
"""Insert an image into a paragraph with specified properties"""
picture = paragraph.AppendPicture(image_path)
# Set size if specified
if width:
picture.Width = width
if height:
picture.Height = height
# Set alignment and wrapping
if alignment == 'left':
picture.TextWrappingStyle = TextWrappingStyle.Square
picture.DistanceFromText.Left = 0
picture.DistanceFromText.Right = 20
elif alignment == 'right':
picture.TextWrappingStyle = TextWrappingStyle.Square
picture.DistanceFromText.Left = 20
picture.DistanceFromText.Right = 0
elif alignment == 'center':
picture.TextWrappingStyle = TextWrappingStyle.InLineWithText
picture.DistanceFromText.Left = 10
picture.DistanceFromText.Right = 10
return picture
Essentially I'm getting the html class attributes and along with those trying to append the image to the start of the paragraph and set it's wrapping style. But it's not working.
Any suggestions?
I'm obviously using Spire.DOCX or Python and running this on a Ubuntu server.
Thanks in advance.