Open beatorizu opened 7 years ago
I have the same problem.
from odf.opendocument import OpenDocumentText, OpenDocumentDrawing
from odf.draw import Frame, Image, Page
from odf.style import PageLayout, MasterPage, Header, Footer
from odf.text import P
from odf import table
from datetime import datetime
textdoc = OpenDocumentText()
p = P()
textdoc.text.addElement(p)
photoframe = Frame(width="200pt", height="200pt", x="56pt", y="56pt", anchortype="paragraph")
href = textdoc.addPicture('test.png')
photoframe.addElement(Image(href=href))
p.addElement(photoframe)
textdoc.save("pic.odt")
With anchortype = "page"
from odf.opendocument import OpenDocumentText
from odf.draw import Frame, Image
from odf.style import Style, GraphicProperties
textdoc = OpenDocumentText()
frstyle = Style(name = 'frstyle', parentstylename="Graphics", family="graphic")
frstyle.addElement(GraphicProperties(verticalpos="from-top", verticalrel="page", horizontalpos="from-left", horizontalrel="page"))
textdoc.automaticstyles.addElement(frstyle)
photoframe = Frame(width="200pt", height="200pt", x="8cm", y="10cm", anchortype="page", stylename = frstyle)
href = textdoc.addPicture('test.png')
photoframe.addElement(Image(href=href))
textdoc.text.addElement(photoframe)
textdoc.save("pic.odt")
Hi I'm trying to add picture to odt file, but is not working. How I could add image.