Adding HTML content to existing textrun

Feb 10, 2013 at 11:38 PM
Hey - great tool here. Perhaps I'm being daft - probably am - but I am hoping to add HTML content to an existing textrun without creating a new one or a new section, and am finding that I can't figure out how do this with your converter.

Some code is below (removing various loops and such for readability).

As you'll probably guess from the functions at play, I'm trying to spit out Wordpress posts into a Word doc. What I want is for the title to appear (in bold) inline with the content of the post. Right now it seems that your converter is adding a new section for it. Is this just the way it's going to be, or is there some way to get the converter to add to the textrun that's already in progress?

Thanks very much!
$PHPWord = new PHPWord();
$PHPWord->setDefaultFontName('Times New Roman');
$PHPWord->addFontStyle('IndividualClipTitle', array('bold'=>'true'));
$PHPWord->addFontStyle('IndividualClipPublication', array('underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE));
$PHPWord->addFontStyle('LinkStyle', array('color'=>'0000FF', 'underline'=>PHPWord_Style_Font::UNDERLINE_SINGLE));
$PHPWord->addTitleStyle( 1, array('bold'=>'true', 'size'=>'15'));
$PHPWord->addTitleStyle( 2, array('bold'=>'true', 'size'=>'13'));
$PHPWord->addTitleStyle( 3, array('bold'=>'true', 'size'=>'12'));
$PHPWord->addTitleStyle( 4, array('bold'=>'true', 'size'=>'12'));
$PHPWord->addTitleStyle( 5, array('bold'=>'true', 'size'=>'12'));
$PHPWord->addTitleStyle( 6, array('bold'=>'true', 'size'=>'12'));
$section = $PHPWord->createSection();
$styleTOC = array('tabLeader'=>PHPWord_Style_TOC::TABLEADER_DOT);
$styleFont = array('spaceAfter'=>60, 'name'=>'Times New Roman', 'size'=>12);
$section->addTOC($styleFont, $styleTOC);
$textrun = $section->createTextRun(array('spacebefore'=>'100'));
$textrun->addText($post->post_title.'. ', 'IndividualClipTitle'); 

$html_dom = new simple_html_dom();
$html_dom->load('<html><body>' . $post->post_content . '</body></html>');
$html_dom_array = $html_dom->find('html',0)->children();
$initial_state = array(
             'phpword_object' => &$section, 
              'base_root' => get_site_url(),
              'base_path' => get_site_url(),
              'style_sheet' => htmltodocx_styles_example(),);
htmltodocx_insert_html($section, $html_dom_array[0]->nodes, $initial_state);

 $textrun->addText(' [');
         $textrun->addText($publicationname, 'IndividualClipPublication');
         $textrun->addText(', ');
         $textrun->addLink( $clipurl, date('j/n/y', $publicationdate), 'LinkStyle');
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');