Search code examples
djangoimagelibreofficeodt

Using variable images with django-webodt


Is anyone using django-webodt? Looking through the documentation, I can't find anything about using images in a document. I want to insert "variable" images (ImageField) in my ODT document. Is this possible?

I'm using the OpenOffice backend.


Solution

  • I don't know if it is a solution for you, I use pod in my projects with nice results, I have never tested to include images but it is documented:

    Quoting pod doc:

    enter image description here

    Integrating external files or images into the result: the document function

    The document function allows you to integrate, into the ODT result, images or files that come from external sources. Here is the function signature; the table below explains each parameter.

    EDITED DUE OP COMMENT

    I come to test it and work pretty well, also into loops. Here you can see python (or django) rendering document with images:

    >>> from appy.pod.renderer import Renderer
    >>> taula1 = [1,2,3]
    >>> taula = [ taula1, taula1 ]
    >>> renderer = Renderer('report.odt',  globals(), 'result.odt')
    >>> renderer.run()
    

    ODT:

    enter image description here

    Result:

    enter image description here