Reputation: 11
I would like to add a logo (picture in jpg or png) to a footer or header by using python-docx.
Is there a way how to do it?
Upvotes: 1
Views: 2801
Reputation: 28883
Add a run and add a picture to the run:
document = Document()
section = document.sections[0]
header = section.header
paragraph = header.paragraphs[0]
run = paragraph.add_run()
run.add_picture("my-image.png")
More documentation on working with headers and footers is here:
https://python-docx.readthedocs.io/en/latest/user/hdrftr.html
Upvotes: 4