Creating ODT documents with dynamic images in PHP

I support a couple of PHP and mySQL based web databases in a shared hosting package. Databases have a mechanism for the user to load OpenOffice documents using placeholders:

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

Then I use this great PHP tool to run through an OpenOffice document and insert values ​​from the database into it. The result will again be an OpenOffice document.

What he cannot do is dynamic images .

Does anyone know - only a PHP solution is desirable - to embed images in OpenOffice documents?

  • I know PUNO . It is impossible to use it in this context because it shares hosting.
  • I know that OpenOffice can be run as a daemon - the same thing.
  • I know phpDocWriter . This was great for SXW files, but now they are dead.
  • I know that OpenDocument is a collection of XML files in a ZIP file. Once I tried to programmatically add a caption to each image in an ODT document. It drove me crazy with insanity. I look with admiration at the developers who work with the format, but this is not for me.

I would really appreciate any hints of existing solutions.

+4
source share
3 answers

I think odtPHP may be what you are looking for

seems to be able to insert images into the placeholder in the document and just read from the array to see which image to place.

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

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

Alternatively, you can include a default image with a specific file name in the document and simply replace this image file in the archive.

+2
source

There is a new version of TbsOOo, OpenTBS , and it has a function to insert / modify an image in a file.

http://www.tinybutstrong.com/opentbs.php

+1
source

Have you tried using the AddFileToDoc method to add an image to a document?

The documentation for this method is here:

http://www.tinybutstrong.com/tbsooo.php#AddFileToDoc

0
source

All Articles