Rya*_*yan 6 python image center docx
我正在使用https://python-docx.readthedocs.org/en/latest/构建自动化报告程序
我试图将图片居中,甚至尝试了我在谷歌某处阅读的这个技巧:
document.add_picture('C:\Users\Public\Pictures\Picture.jpg',height=Inches(3.44))
last_paragraph = document.paragraphs[-1]
last_paragraph.style = 'centerstyle'
没有运气......
那里的任何人想出办法解决这个问题?
小智 21
你可以这样做.
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
Run Code Online (Sandbox Code Playgroud)
我知道我现在可能很晚才回复,但也许对其他人有帮助.