-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Basically, I want to achieve "Format Picture" in Office Word, where you right click an element in a .docx file and attach solid line (ideally, I want to also manually set color, width, transparency, etc) border to the image
import docx
from docx import Document
from docx.oxml import OxmlElement
from docx.oxml.ns import qn
doc = Document(p)
for element in doc.element.body:
if hasattr(element, 'inner_content_elements'):
for ele in element.inner_content_elements:
for i in ele.inner_content_items:
outline = OxmlElement('a:ln', {'w': '9525'})
solid_fill = OxmlElement('a:solidFill')
scheme_color = OxmlElement('a:schemeClr', {'val': 'green'})
solid_fill.append(scheme_color)
outline.append(solid_fill)
i.append(outline)
Above is the code I tried, which gives no error, but the result file is broken, as it says when I tried to open the file:
Word experienced an error trying to open the file.
Try these suggestions.
* Check the file permissions for the document or drive.
* Make sure there is sufficient free memory and disk space.
* Open the file with the Text Recovery converter.
(Path/to/the/file)
Any suggestions?
Metadata
Metadata
Assignees
Labels
No labels