Register Lost your password?
Full api documentation: full api documentation FREE version full api documentation PRO version

public function addHTML(string html)

This method allows to insert directly HTML (with CSS styles inline or in a separate CSS file) in your Word document. This method support practically all standard HTML tags: links, paragraphs, tables, lists, etcetera and CSS selectors.

Parameters

$html: HTML to insert into the document

Examples

Example 1 Version Pro


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

$docx = new CreateDocx();

$html= '<p>This will insert the name in the document: <strong>
          <span style="font-size:33px;">My name</span></strong></p>';

$docx->addHTML($html);

$docx->createDocx('example_html');

    9 Responses

  • renato.lima

    can i used addhtml with addtemplate variable ?

  • Paige thompson

    Does it embed HTML or does it convert HTML to dock (content) :P

  • sysadmin@duoconsulting.com

    how can we add CSS now?

  • nicolas
  • nicolas

    use [STYLE][/STYLE]
    PS: html tags are removed in comments…

  • kingsol

    How do handle images that are in the HTML? Can you put a replace the image tag with a temporary placeholder vairable in the html, use “AddHTML”, then use “AddTemplateImage”? I have blocks of html that contain lists, paragraphs, br tags and image tags… would like the image tags to works as well. Thank you.

  • kingsol

    I have addHTML working nicely, however, images referenced with full url paths, will work when those paths are present, but they do not embed the images in the document. So if the image is moved from the url, the documents can not render the image… is there a way to embed an image from the html?

  • admin

    Hello,

    The next version of phpdocx pro will include support for MHT files, so you’can add images offline and other content.

    Regards.

  • evikper

    It would be useful if the comments had dates so there was a way for me to know which version admins comment refer to.

Your comments