phpopenoffice.orgopendocument

Generate ODT documents with dynamic images in PHP


I maintain a couple of web databases based on PHP and mySQL on a shared hosting package. The databases have a mechanism for the user to upload OpenOffice documents with placeholders:

[person.name] [person.address] [person.postcode]

I then use this great PHP tool to run through the OpenOffice document and insert values from the database into it. The result is again, an OpenOffice document.

What it can't do is dynamic images.

Does anybody know a - preferably PHP-only - solution to insert images into OpenOffice documents?

I would really appreciate any hints on existing solutions.


Solution

  • I think odtPHP might be what you're looking for

    is seems to be able to insert images on a placeholder in the document and reads simply from an array to see which image to place.

    http://www.odtphp.com/index.php?i=tutorials&p=tutorial5

    Now, if you do this as a post-process after your current code, or simply use it instead of TBS, you got everything you need IMHO

    Alternatively, you can include a default image with a certain filename in your document, and simply replace that imagefile in the archive.