Is there a limit in manipulating a docx document with Python ? I used this mod :
pip install python-docx
I have a almost blank starting file called "TEST.docx" When I execute this code, I have no issue when I open the output file :
import docx
from docx import Document
from docx.shared import Inches
document = Document("TEST.docx")
document.add_picture("test.jpg", width=Inches(7.0))
document.save("TEST_Output.docx")
But when I want to add lot of files (I repeat the "add_picture" line several times) :
import docx
from docx import Document
from docx.shared import Inches
document = Document("TEST.docx")
document.add_picture("test.jpg", width=Inches(7.0))
document.add_picture("test.jpg", width=Inches(7.0))
document.add_picture("test.jpg", width=Inches(7.0))
document.add_picture("test.jpg", width=Inches(7.0))
document.add_picture("test.jpg", width=Inches(7.0))
document.add_picture("test.jpg", width=Inches(7.0))
document.add_picture("test.jpg", width=Inches(7.0))
document.add_picture("test.jpg", width=Inches(7.0))
document.save("TEST_Output.docx")
Then, the script is correctly executed but when I open the docx with Word, I get an error message explaining that the content is damaged. If I click on "Yes", the document is correctly opened with the appropriate pictures..
Any ideas ? Thanks.