title: Create docx file with gujarati font from HTML content in php
body: <p>My Basic requirement is to create docx file from HTML content but the date should be in Gujarati language font. Font should be "Gujrati-Saral".</p>
  
  <p>When i try to create docx file then it will either create blank or font convert into english language.</p>
  
  <p>I am using html to docx converter for this :
  <a href="http://htmltodocx.codeplex.com/releases/view/101183" rel="nofollow">http://htmltodocx.codeplex.com/releases/view/101183</a></p>
  
  <p>Following is the font link :
  <a href="http://www.fonts2u.com/gujrati-saral-1.font" rel="nofollow">http://www.fonts2u.com/gujrati-saral-1.font</a></p>
  
  <p>Following is the code which i used :</p>
  
  <pre><code>&lt;?php
  /**
  *  Example of use of HTML to docx converter
  */
  
  // Load the files we need:
  require_once 'phpword/PHPWord.php';
  require_once 'simplehtmldom/simple_html_dom.php';
  require_once 'htmltodocx_converter/h2d_htmlconverter.php';
  require_once 'example_files/styles.inc';
  
  // Functions to support this example.
  require_once 'documentation/support_functions.inc';
  
  // HTML fragment we want to parse:
  $html = file_get_contents('example_files/example_html.html');
  // $html = file_get_contents('test/table.html');
  
  // New Word Document:
  $phpword_object = new PHPWord();
  $section = $phpword_object-&gt;createSection();
  
  // HTML Dom object:
  $html_dom = new simple_html_dom();
  $html_dom-&gt;load('&lt;html&gt;&lt;body&gt;&lt;font face="Gujrati-Saral-1" size="12"&gt;Kem cho&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;');
  // Note, we needed to nest the html in a couple of dummy elements.
  
  // Create the dom array of elements which we are going to work on:
  $html_dom_array = $html_dom-&gt;find('html',0)-&gt;children();
  
  // We need this for setting base_root and base_path in the initial_state array
  // (below). We are using a function here (derived from Drupal) to create these
  // paths automatically - you may want to do something different in your
  // implementation. This function is in the included file 
  // documentation/support_functions.inc.
  $paths = htmltodocx_paths();
  
  // Provide some initial settings:
  $initial_state = array(
    // Required parameters:
    'phpword_object' =&gt; &amp;$phpword_object, // Must be passed by reference.
    // 'base_root' =&gt; 'http://test.local', // Required for link elements - change it to your domain.
    // 'base_path' =&gt; '/htmltodocx/documentation/', // Path from base_root to whatever url your links are relative to.
    'base_root' =&gt; $paths['base_root'],
    'base_path' =&gt; $paths['base_path'],
    // Optional parameters - showing the defaults if you don't set anything:
    'current_style' =&gt; array('size' =&gt; '11'), // The PHPWord style on the top element - may be inherited by descendent elements.
    'parents' =&gt; array(0 =&gt; 'body'), // Our parent is body.
    'list_depth' =&gt; 0, // This is the current depth of any current list.
    'context' =&gt; 'section', // Possible values - section, footer or header.
    'pseudo_list' =&gt; TRUE, // NOTE: Word lists not yet supported (TRUE is the only option at present).
    'pseudo_list_indicator_font_name' =&gt; 'Wingdings', // Bullet indicator font.
    'pseudo_list_indicator_font_size' =&gt; '7', // Bullet indicator size.
    'pseudo_list_indicator_character' =&gt; 'l ', // Gives a circle bullet point with wingdings.
    'table_allowed' =&gt; TRUE, // Note, if you are adding this html into a PHPWord table you should set this to FALSE: tables cannot be nested in PHPWord.
    'treat_div_as_paragraph' =&gt; TRUE, // If set to TRUE, each new div will trigger a new line in the Word document.
  
    // Optional - no default:    
    'style_sheet' =&gt; htmltodocx_styles_example(), // This is an array (the "style sheet") - returned by htmltodocx_styles_example() here (in styles.inc) - see this function for an example of how to construct this array.
    );    
  
  // Convert the HTML and put it into the PHPWord object
  htmltodocx_insert_html($section, $html_dom_array[0]-&gt;nodes, $initial_state);
  
  // Clear the HTML dom object:
  $html_dom-&gt;clear(); 
  unset($html_dom);
  
  // Save File
  $h2d_file_uri = tempnam('', 'htd');
  $objWriter = PHPWord_IOFactory::createWriter($phpword_object, 'Word2007');
  $objWriter-&gt;save($h2d_file_uri);
  
  // Download the file:
  header('Content-Description: File Transfer');
  header('Content-Type: application/octet-stream');
  header('Content-Disposition: attachment; filename=example.docx');
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Pragma: public');
  header('Content-Length: ' . filesize($h2d_file_uri));
  ob_clean();
  flush();
  $status = readfile($h2d_file_uri);
  unlink($h2d_file_uri);
  exit;
  </code></pre>