I'm building a automated report program using https://python-docx.readthedocs.org/en/latest/
I'm trying to center a picture and even tried this trick that I read somewhere on google:
document.add_picture('C:\Users\Public\Pictures\Picture.jpg',height=Inches(3.44))
last_paragraph = document.paragraphs[-1]
last_paragraph.style = 'centerstyle'
with no luck...
Anyone out there figured out a way to get around this?
You could do something like this.
from docx import Document
from docx.enum.text import WD_ALIGN_PARAGRAPH
my_image = document.add_picture('path/to/image')
last_paragraph = document.paragraphs[-1]
last_paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
I know I am probably replying to late now but maybe it helps to somebody else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With