News

Text with different styles in the same paragraph in a docx document with PHPdocx

  • May 04, 2011

In a text documents, one paragraph maybe need different format for a phrase, or a complete text. PHPfocx can handle this situation using properties for every different text.


require_once('../../classes/CreateDocx.inc');

$docx = new CreateDocx();

$text = array();

// First text with properties
$text[] =
array(
'text' => 'Lorem ipsum',
'u' => 'single',
);

// Second text with properties
$text[] =
array(
'text' => ' sed do eiusmod tempor incididunt',
'b' => 'single',
);

// Adding both texts to the document
$docx->addText($text);

$docx->createDocx('example_text');