Closed telkamp closed 3 years ago
Thx for the report. The proposed way to insert an image in odfdo is to put the image inside a paragraph. See how_to_add_a_picture_to_a_text_document.py :
image_frame = Frame.image_frame(uri, size=("6cm", "4cm"), position=("5cm", "10cm"))
# put image frame in a paragraph:
para = Paragraph("")
para.append(image_frame)
body.append(para)
However, I don't remember if it is a requirement of ODF standard or for compatibility with some text processors, I'll check this.
The reason to put the frame inside a paragraph is probably to permit to edit the document, especially allowing to change the anchor to either paragraph or page.
Thank you for your response! I can confirm that my example works when I insert the image into the paragraph instead of the document's body. BTW, LibreOffice inserts the image into the document's body. But the result is the same.
In my code at the bottom of this issue I'm appending an
image_frame
directly to the body of the document. When Iopen the resulting odt file in LibreOffice, the image is not shown, because odfdo inserts a paragraph before thedraw:frame
elementI suggest that the default paragraph should be inserted behind the elements appended to the body. Workaround: When I remove the default paragraph, the image will be shown in LibreOffice:
Python code to append an
image_frame
directly to the body of the document