Small library to patch python-docx with SVG-support based on pull request #1343.
All credit goes to @takis and @lsaint who developed most of the code.
SVG support will hopefully be added upstream, making this package obsolete.
Until then, standard python-docx can be used, rather than one of the forks with SVG support.
Example
# Simply load `docx_svg`, patch it, and use `docx` as usually import docx_svg from docx import Document from docx.shared import Inches docx_svg.patch() with open("test.svg", 'w') as f: f.write( ('<svg height="2in" width="2in" xmlns="http://www.w3.org/2000/svg">' '<circle r="75" cx="100" cy="100" fill="red" />' '</svg>')) document = Document() document.add_picture("test.svg", width=Inches(2)) document.save('demo.docx')
Install
The project isn't on PyPi yet.
For now it can be installed with pip using e.g. the repo zip:
pip install https://github.com/pank/python-docx-svg/archive/refs/heads/master.zip