Test Code.
Work Fine!
It is Point that add picture frame in paragraph element.
fromodf.opendocumentimportOpenDocumentTextfromodf.textimportP,ParagraphPropertiesfromodfimportteletypefromodf.styleimportStylefromodf.drawimportFrame,Image# Justified style
justifystyle=Style(name="justified",family="paragraph")justifystyle.addElement(ParagraphProperties(attributes={"textalign":"justify"}))# Creating different style used in the document
doc=OpenDocumentText()s=doc.styless.addElement(justifystyle)# Adding a paragraph
paragraph_element=P(stylename=justifystyle)paragraph_text="hello world"teletype.addTextToElement(paragraph_element,paragraph_text)doc.text.addElement(paragraph_element,paragraph_text)# add picture
picframe=Frame()href=doc.addPicture("drawlogo.png")picframe.addElement(Image(href=href))# Point!
# add picture frame in paragraph element
paragraph_element.addElement(picframe)# save ODT
doc.save("new.odt")
Test Code.
Add element in Frame.
Add element in Image.
fromodf.opendocumentimportOpenDocumentTextfromodf.textimportPfromodfimportteletypefromodf.styleimportStyle,ParagraphPropertiesfromodf.drawimportFrame,Image# Justified style
justifystyle=Style(name="justified",family="paragraph")justifystyle.addElement(ParagraphProperties(attributes={"textalign":"justify"}))# Creating different style used in the document
doc=OpenDocumentText()s=doc.styless.addElement(justifystyle)# Adding a paragraph
paragraph_element=P(stylename=justifystyle)paragraph_text="hello world"teletype.addTextToElement(paragraph_element,paragraph_text)doc.text.addElement(paragraph_element,paragraph_text)# add picture
picframe=Frame(anchortype="paragraph",height='26mm',width='26mm',name='image1')href=doc.addPicture("drawlogo.png")picframe.addElement(Image(href=href,actuate="onLoad",show="embed",type="simple"))paragraph_element.addElement(picframe)# save ODT
doc.save("new.odt")
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I add Picture use LibreOffice Writer.
I read this documents's context.xml.
It's under code.
it add text.p in frame.
it add draw image in frame.
Add image to odt #45
He is mistake.
He should add frame in text.P .
Test code?
Not yet.
Test Code.
Work Fine!
It is Point that add picture frame in paragraph element.
Test Code.
Add element in Frame.
Add element in Image.