create
[ class tree: create ] [ index: create ] [ all elements ]

example

  1. <?php
  2.  
  3. /**
  4.  * Inserts a header and footer with font styles.
  5.  *
  6.  * @category   Phpdocx
  7.  * @package    examples
  8.  * @subpackage intermediate
  9.  * @copyright  Copyright (c) 2009-2013 Narcea Producciones Multimedia S.L.
  10.  *              (http://www.2mdc.com)
  11.  * @license    http://www.phpdocx.com/wp-content/themes/lightword/pro_license.php
  12.  * @version    2012.12.26
  13.  * @link       http://www.phpdocx.com
  14.  * @since      File available since Release 1.8
  15.  */
  16. require_once '../../classes/CreateDocx.inc';
  17.  
  18. $docx new CreateDocx();
  19.  
  20. $customLayout array(
  21.                     'width' => '11906',
  22.                     'height' => '16838',
  23.                     'numberCols' => '1',
  24.                     'orient' => 'portrait',
  25.                     'code' => '9',
  26.                     'marginTop' => '1617',
  27.                     'marginRight' => '1701',
  28.                     'marginBottom' => '1417',
  29.                     'marginLeft' => '1701',
  30.                     'marginHeader' => '308',
  31.                     'marginFooter' => '708',
  32.                     'gutter' => '0'       
  33.                 );
  34. $docx->modifyPageLayout('custom'$customLayout);
  35.  
  36. $headerImage $docx->addImage(array('name' => '../files/img/image.png''dpi' => 300'rawWordML' => true'target' => 'defaultHeader'));
  37. $myImage $docx->createWordMLFragment(array($headerImage));
  38.  
  39. $pager $docx->addPageNumber('numerical'array('jc' =>'right''rawWordML' => true));
  40. $myPager $docx->createWordMLFragment(array($pager));
  41.  
  42. $valuesTable array(
  43.     array(
  44.         $myImage,
  45.         $myPager
  46.     )
  47. );
  48.  
  49. $options array('size_col' => array(40004400)'border' => 0'rawWordML' => true);
  50.  
  51. $headerTable $docx->addTable($valuesTable$options);
  52. $myHeader $docx->createWordMLFragment(array($headerTable));
  53.  
  54. $docx->addHeader(array('default' => $myHeader));
  55.  
  56. $htmlFooter ='<p style="font-weight: bold; text-align: center">A footer generated with HTML.</p>';
  57. $footer $docx->embedHTML($htmlFooterarray('rawWordML' => true'target' => 'defaultFooter'));
  58. $myFooter $docx->createWordMLFragment(array($footer));
  59.  
  60. $docx->addFooter(array('default' =>$myFooter));
  61.  
  62. $docx->addText('A Word document with a header and footer that illustrates how to include images and page numbering.');
  63.  
  64. $docx->createDocx('../docx/example_header_and_footer');

Documentation generated on Mon, 13 Jan 2014 13:44:07 +0100 by phpDocumentor 1.4.4