Categories > OpenTBS with ODT >

Format text

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Martin Koeditz
Date: 2014-04-09
Time: 15:35

Format text

Hello,

is there a way to format text via PHP? I'd like to have some text parts formatted italic and red font color.

Kind regards,
Martin
By: Skrol29
Date: 2014-04-10
Time: 01:32

Re: Format text

Hi,

You can insert XML content and prevent it from being converted.
But this is nor simple because in ODT the formating is defined using styles.

So the best is to define your own named character style in the ODT.
Then you can use a TBS field with paramtere "att" in order to chnage the style name of the text snippet.

The inner XML with character style is like this:
<text:p text:style-name="P1">
  text here <text:span text:style-name="mystyle">hello</text:span> text there
</text:p>

So the TBS can be like this:
<text:p text:style-name="P1">
  text here <text:span text:style-name="mystyle">[onload.selected_style;att=text:style-name;magnet=#]</text:span> text there
</text:p>
By: Martin Koeditz
Date: 2014-04-10
Time: 09:03

Re: Format text

Thank you for the reply.

I've created a paragraph style named 'Historisch' in the odt. The part to be replaced looks like this:
Suchbegriff: [onshow.SEARCH]

Now I fill the placeholder via PHP:
$TBS->VarRef['SEARCH'] = "<text:span text:style-name=\"T1\">TEXT</text:span>";

Unfortunately I get this result:
Suchbgriff: <text:span text:stylename="T1">TEXT</text:span>

What am I doing wrong?
By: Skrol29
Date: 2014-04-10
Time: 10:57

Re: Format text

[onshow.SEARCH;strconv=no]
By: Martin Koeditz
Date: 2014-04-10
Time: 15:26

Re: Format text

OK, I changed the the expression in the template, but now the text is gone. Just white background.

$TBS->VarRef['SEARCH'] = '<text:h text:style-name="Heading_20_5" text:outline-level="5">TEXT</text:h>';

Template:
http://www.it-syn.de/tmp/template.odt

Result file:
http://www.it-syn.de/tmp/output.odt

At the end of the page there is the section
[onshow.SEARCH;strconv=no]

Maybe it's just a simple mistake?


By: Skrol29
Date: 2014-04-10
Time: 18:47

Re: Format text

The fields is correctly merged, as we can see in the inner XML.
But your text cannot be displayed by LibreOffice because <text:h> cannot be placed into <text:p>.
If you replace <text:h> with <text:span> then it works.
By: Martin Koeditz
Date: 2014-04-10
Time: 21:29

Re: Format text

Thank you so much. It's working now.