To access and edit document.xml styles using python-docx, you can follow the below steps:
from docx import *
from docx.opc.constants import CONTENT_TYPE as CT
from docx.oxml import *
from docx.oxml.ns import *
doc = Document('example.docx')
styles = doc.styles
for style in styles:
print(style.name)
print(style.font.name)
print(style.font.size)
style.font.name = 'Calibri'
style.font.size = Pt(12)
doc.save('example.docx')
Asked: 2023-06-09 02:57:11 +0000
Seen: 13 times
Last updated: Jun 09 '23