News

Adding HTML to a docx document using PHPDocX

  • Jun 06, 2011

If you want to find more detailed info about the different posible ways to add HTML to your Word document, please, refer to the HTML to Word section of our API documentation.
If you need to embed some contant as HTML into a docx document, you can do so with a single call to the addHTML method:



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

$docx = new CreateDocx();

// Import of HTML starts here
$docx->addText('HTML content');

// Here, the HTML
$html= 'PHPDOCX is a PHP library designed to generate completely dynamic and fully customizable Word documents.';

$docx->addHTML($html);

// Closing the import
$docx->addText('End HTML content');

$docx->createDocx('example_html');