Categories > OpenTBS with DOCX >

Bold on OpenTBS and Word

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Mat
Date: 2012-05-10
Time: 11:24

Bold on OpenTBS and Word

Hi all,

I have a docx with certain values that need to be replaced. Everything works like a charm, but i want some lines in bold. I ofcoarse searched these forums and Stackoverflow and found some stuff. But that doesn't seem to work. What i have now is this function (i am using italic to test):

function f_html2docx($FieldName, &$CurrVal) {
   $CurrVal =utf8_encode( $CurrVal);
   $CurrVal = '<w:r><w:t xml:space="preserve">' . $CurrVal . '</w:t></w:r>';
  
   $CurrVal= str_replace('<w:t>', '<w:t xml:space="preserve">', $CurrVal);
  
   $CurrVal= str_replace('<em>', '</w:t></w:r><w:r><w:rPr><w:i/></w:rPr><w:t xml:space="preserve">', $CurrVal);
   $CurrVal= str_replace('</em>', '</w:t></w:r><w:r><w:t xml:space="preserve">', $CurrVal);
 
   $CurrVal= str_replace('<sup>', '</w:t></w:r><w:r><w:rPr><w:vertAlign w:val="superscript"/></w:rPr><w:t xml:space="preserve">', $CurrVal);
   $CurrVal= str_replace('</sup>', '</w:t></w:r><w:r><w:t xml:space="preserve">', $CurrVal);
  
   $CurrVal= str_replace('<span class="autore">', '</w:t></w:r><w:r><w:rPr><w:smallCaps/></w:rPr><w:t xml:space="preserve">', $CurrVal);
   $CurrVal= str_replace('</span>', '</w:t></w:r><w:r><w:t xml:space="preserve">', $CurrVal);
}

I use this function into my .docx with this line:

[onshow.bezwaar;onformat=f_html2docx;strconv=no]

What i enter in the PHP file is:

$bezwaar .= "<em>".$var."</em>";

So far so good, but the result looks like this:

</w:t></w:r><w:r><w:rPr><w:i/></w:rPr><w:t xml:space="preserve">Content from var<w:t></w:r><w:r><w:t xml:space="preserve">

What am i doing wrong?
By: Mat
Date: 2012-05-10
Time: 11:53

Re: Bold on OpenTBS and Word

I think i solved it by using:

$TBS->LoadTemplate($template,OPENTBS_ALREADY_XML);

I don't know if that's the best solution though. Also is there a list of openxml tags, i'd like to change the fontsize as well.

By: Skrol29
Date: 2012-05-11
Time: 00:43

Re: Bold on OpenTBS and Word

Hi Mat,

For the OpenXML reference, I use http://www.schemacentral.com/sc/ooxml/ss.html and also Google....