API Documentation
Word content
Format conversion
CryptoPHPDOCX
Digital Signature package
addHTML
Inserts HTML into the Word document.
PRO, PRO+ and CORPORATE PHPDocX >= 2.3
Description
public addHTML (array $options)
This method allows to insert directly HTML (with CSS styles inline or in the head section) into your Word document. This method support practically all standard HTML tags: links, paragraphs, tables, lists, etcetera and CSS selectors.
This method IS NOT compatible with PDF conversion or with Open Office (use embedHTML instead).
Parameters
options
The posible keys and values are (required options are shown with yellow background):
| key | Type | Description |
|---|---|---|
| html | string | HTML to insert into the document. |
| rawWordML | bool | If true one may store the output into a variable. |
Return values
If the option rawWordML is set to true (default value is false) it returns a string with the raw WordML code, else returns nothing.
Code samples
Example #1: basic HTML code
require_once('../../classes/CreateDocx.inc');
$docx = new CreateDocx();
$html= 'This will insert the name in the document:
My name
';
$docx->addHTML(array('html' => $html));
$docx->createDocx('example_html');
The resulting Word document looks like (download .docx file):
Change log
- Available since 2.3
- rawWordML option included in 3.0
Available examples
See also
PHPDocx. Dinamic generation of reports in .docx format 

