Categories > OpenTBS general LibreOffice >

Inserting images into an OO template from a database

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Scott Snyder
Date: 2012-01-03
Time: 00:31

Inserting images into an OO template from a database

Hi all,

I have a database with entries containing text information and a field containing the content of a JPEG image.
I would like to populate an Open Office presentation document with some of the text fields and the image.

The OpenTBS demo assumes that the image data is in a file so it retrieves text information needed to find the appropriate file and use an ope=addpic command to insert the image into the docuent inplace of the one that is there.

How would I go about inserting the binary image data from the database into the OO presentation template. I assume that it is some variation of [b.photo;ope=addpic;default=current] (where the block 'b' has a field 'photo' containing the binary image data), but I am not sure of the syntax.

Thanks,

Scott
By: Skrol29
Date: 2012-01-03
Time: 02:14

Re: Inserting images into an OO template from a database

Hi Scott,

You can edit the zip archive manually, but for this you need to change several things in several sub-files (the main content file, the manifest file and the picture file).
Usually the "addpic" parameter does all that hard job for you.

Since OpenTBS actually insert the picture file only when Show() is called, then it would be a smart idea to change the insert information just before the Show() method.
This would enables you to replace "external file" with "binary content".
Unfortunately, this would be heavy for the PHP memory because it needs that all the images to are saved in the same time in memory.

I think the best idea is simply to save all the binary contents of pictures in a temporary folder. Use the usual "addpic" feature, and then cleanup the temporary folder after Show().
When pictures are inserted from an existing file, then this has no memory cost because OpenTBS simply output the binary contents one by one.
By: Scott Snyder
Date: 2012-01-03
Time: 15:24

Re: Inserting images into an OO template from a database

You are right, for several hundred images I probably would run into memory issues.
I tried it with saving the image content to a temp directory and everything seems to be working.

Thanks for your help,

Scott