0

I saw many post about changing picture in OpenTBS but I don't understood how to do that. I have a .odt file which has an image and I need to replace it from php with another one. From documentation I see the Example: [ onshow.x;ope=changepic] but I have no idea where I have to put this line. I've also tried to use this code below but nothing happens.

"ticket.odt" has an image (it has $PicRef description) which I would like to change.

$TBS= new clsTinyButStrong;
$TBS->PlugIn(TBS_INSTALL, OPENTBS_PLUGIN);
$TBS->LoadTemplate("Ticket/ticket.odt");
$TBS->PlugIn(OPENTBS_CHANGE_PICTURE, $PicRef, $logo );

As documentation $PicRef is a string that is saved in the Title or the Description of the picture and $logo is the path for picture file that will be copied inside the document Could someone explain me how it works and what I have to do?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
SMatt
  • 31
  • 2
  • 9

1 Answers1

1

Example using command OPENTBS_CHANGE_PICTURE:

PHP side:

$TBS->PlugIn(OPENTBS_CHANGE_PICTURE, 'my_picture', 'logo.png');
$TBS->Show(OPENTBS_FILE, $file_name);

Template side:

In the ODT template do a right-click on the picture you want to be replaced then you have the contextual menu. In the contextual menu, select Properties. Then in the tab Options, change the property Name to 'my_picture'.

When running the script, the picture will be replaced.


Example using parameter changepic:

PHP side:

$TBS->VarRef['x'] = 'logo.png';
$TBS->Show(OPENTBS_FILE, $file_name);

Template side:

Put the TBS field [onshow.x;ope=changepic] somewhere in the normal text after the picture you whant to be changed. Or Put the TBS field [onshow.x;ope=changepic;tagpos=inside] in the property Name of the picture (see previous example).

Skrol29
  • 5,402
  • 1
  • 20
  • 25
  • Hi @Skrol29, thanks a lot for your answer. I've tried both examples but the picture still not change. In particular in the first case i get into the $file_name the same image as the tamplate but resized as 'logo.png', then in the second case the picture stil be the same but into the property name i see "Pictures/opentbs_added_1.png" – SMatt Dec 18 '17 at 09:56
  • Could you send the files to reproduce your problem ? – Skrol29 Dec 19 '17 at 21:54
  • H @Skrol29 , sorry if I did not answer. Here my files : https://www.dropbox.com/s/ohnrhe5fr4asztw/opentbs.zip?dl=0 Thanks!!! – SMatt Jan 12 '18 at 10:59