Categories > OpenTBS with ODT >

Problem with 'image' parameter for Open Office

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Philipp
Date: 2014-01-27
Time: 11:14

Problem with 'image' parameter for Open Office

Hi,

maybe someone can help me with my problem.
I am trying to insert an image into an OpenOffice *.odt
In my PHP class i am setting the path to the image, for example: $this->setValues('image.src' => '../files/image.jpg');
In my *.odt I try to display the image with [image.src;image]
But I get an error message that don't really help me to figure out what I am doing wrong:
Uno Webservice Error: unoconv -f doc --stdout /home/projects/uno-api/unoservice/temp/convert_doc_BsuXrw | base64 ended with code 0 but no results
The UnoWebservice composes the odt to an document and gives it back to the client.

I am thankfull for every tipp!
By: Skrol29
Date: 2014-01-27
Time: 11:57

Re: Problem with 'image' parameter for Open Office

Hi Philipp,

This is not the way to insert an image in an ODT file.
First of all, the image cannot be actually inserted, it is replaced. You have to place a default image in your ODT and then OpenTBS will replace it with your chosen one.

If is is a single image, then the simplest way is to use the command OPENTBS_CHANGE_PICTURE.
See http://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html#modify_contents

The UnoWebservice error message is not helpful to debug your template.
Is is better for your to be able to check the possible TBS and OpenTBS error messages.
By: Philipp
Date: 2014-01-27
Time: 17:34

Re: Problem with 'image' parameter for Open Office

Hi,
thanks for the fast reply. So, I tired but at the moment I don't get it working.
First I placed the jpg into the *.odt and gave it a title and description as named 'test'.
In my class I am doing:
include_once('clsOpenTBS.class.php');
$doc = new tinyDoc(); (We use this in our system. it extends clsTinyButStrong class)
$doc->setZipMethod('shell');
$doc->setProcessDir('/tmp');
$doc->createFrom($this->templateFileName);
$doc->loadXml('content.xml');
$doc->loadXml('styles.xml');
$doc->close();
$doc->PlugIn(OPENTBS_CHANGE_PICTURE, '#test#', '../files/test_change.jpg');

then I get my document but the image is not changed.

Mybe you have a little tip again?
By: Skrol29
Date: 2014-01-27
Time: 22:20

Re: Problem with 'image' parameter for Open Office

Hi,

tinyDoc is an old class for the same purpose as OpenTBS.
tinyDoc is not maintained since 2009. I'm not sure it is compatible with the last TBS version.
Nevertheless, tinyDoc and OpenTBS cannot be used for the same merging since they both try to merge data on their own.

tinyDoc works with temporary files, since OpenTBS works with the PHP memory.
OpenTBS quite simpler than tinyDoc and it doesn't need exe files nore configuration.

With OpenTBS, your code could be like this:
You may change the TBS class name in order to use tinyDoc in another part of your code with another TBS version.
include_once('tbs_class.php'); // Load the TinyButStrong template engine
include_once('tbs_plugin_opentbs.php'); // Load the OpenTBS plugin

$doc= new clsTinyButStrong; // new instance of TBS
$doc->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin

$doc->LoadTemplate($this->templateFileName);
$doc->PlugIn(OPENTBS_CHANGE_PICTURE, '#test#', '../files/test_change.jpg');
$doc->Show(OPENTBS_FILE, $this->output_file_name);
By: Philipp
Date: 2014-01-28
Time: 10:37

Re: Problem with 'image' parameter for Open Office

Hi,

ok, this is a pitty. Because of economic reasons I can't switch from tinyDoc to openTBS.
Is there any possibility to get an image into a *.odt with the use of tinyDoc?

greets, Philipp
By: Skrol29
Date: 2014-01-28
Time: 12:41

Re: Problem with 'image' parameter for Open Office

You don't need to switch all the application.
Regarding to your snippet, it can be done by replacing tinyDoc with TBS only on this snippet. But you maybe have more code in the real source.

For the image with tinyDoc, did you check the tinyDoc examples ?
http://tinydoc.unesolution.fr/examples
By: Philipp
Date: 2014-01-28
Time: 12:48

Re: Problem with 'image' parameter for Open Office

Hi,

ok, this is a pitty. Because of economic reasons I can't switch from tinyDoc to openTBS.
Is there any possibility to get an image into a *.odt with the use of tinyDoc?

greets, Philipp
By: Philipp
Date: 2014-01-28
Time: 12:50

Re: Problem with 'image' parameter for Open Office

Hey,

yes I checked the examples before. But the *.odt  testfiles seems to be 'broken'. I get an error message that the file is corrupted. I click on 'fix' but then I only see a document with a little symfony image in it. So I can#t figure out how to build up mit *.odt file.
The php code example is clear to understand