1

This code illustrates how to add an Image to a .docx document, by creating a new document and adding content into it, my document has only one page in it with little content, how can I prepend an Image to this data?In other words I want the Image to be the first Item in the document followed by what was already in the document.

from docx import Document
from docx.shared import Inches

document = #Path to my already existing docx that has one table in it.
document.add_picture('/tmp/foo.jpg') #Will add a picture at the end of the doc, but I want this picture at the very beginning before the other content
document.save('demo.docx')

I have checked most questions discussing "adding image at particular docx position" but they all seem to be adding images to a new document

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
Johnn Kaita
  • 432
  • 1
  • 3
  • 13

0 Answers0