0
有沒有辦法將框架周圍的內嵌圖片與python docx
?框架周圍的內嵌圖片
我有類似:
from docx import Document
from docx.shared import Mm
document = Document()
table = document.add_table(rows=1, cols=3)
pic_cells = table.rows[0].cells
paragraph = pic_cells[0].paragraphs[0]
run = paragraph.add_run()
run.add_picture('testQR.png', width=Mm(15), height=Mm(15))
document.save('demo.docx')
我需要把一幀圖像周圍,以紀念這個圖像的邊框(應該是與圖像尺寸相同)。
如何使用python docx package
對此進行格式化?
感謝您提供整潔的「枕頭」主意。這真正解決了圖片的問題 - 但不適用於文本。我將深入探討爲單元格模板樣式的可能性。 – Stefan
@Stefan如果你對預先定義的表格樣式不錯,那麼只需應用[此列表]中的一個(https://python-docx.readthedocs.org/en/latest/user/styles-understanding.html#table-styles -in默認模板)。但是,如果您需要自定義樣式(如爲特定單個單元格創建邊框),那麼您別無選擇,只能創建自己的模板,正如我在答案中所述。 – vrs