run.add_picture() won't insert the image into the document
See original GitHub issueI’m trying to editing an existing Word document (.docx). Everything works well and I can easily add images at the end of the document with : document.add_picture("my_picture.png") .
My problem is presented when I try to get a specific paragraph and add a picture inside a new run.
ex. document.paragraphs[20].add_run().add_picture("my_picture.png")
The command executes correctly, but then when I open the saved word document no image is present at the paragraph n.20.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Apache Poi: adding an image to paragraph does not work
The result is that if I add both image and title, then it generates an empty document. If I add only the title,...
Read more >49765 – addPictures() not displaying Image in XWPF
When I use the method addPictures() for XWPF documents, I assume this adds the image data to the Word document without any additional...
Read more >Cannot insert Pictures into Word, PowerPoint, Excel
I have installed OpenOffice and inserted the same test picture into a Documents, Spreadsheet and Presentation (in Open Office) and the image ......
Read more >Adding Images to a Word Document using Java
Java makes it possible to add images to Word documents using the addPicture() method of XWPFRun class provided by Apache POI package.
Read more >Include a Picture or Other Image in Your Sheet
You can insert images directly into cells in your sheets. Images in the grid can be useful for many types of sheets, including...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Post the before-repair and after-repair XML and let’s have a look:
Then after the repair:
I was able to cope up with the error by not using paragraph spaces before and after. So, I think there is a problem in either line_spacing or space_after methods. Adding to that I was also not able to add picture using document.add_picture() call as stated in issue.
When adding picture forcefully in word application it appeared to misbehave and inserted picture under text. After that, saving the document generates error.