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

example

  1. <?php
  2.  
  3. /**
  4.  * Creates a document with different types of customized elements.
  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 2.2
  15.  */
  16. require_once '../../classes/CreateDocx.inc';
  17.  
  18. $users array(
  19.                 => array('name' => 'Don Mattingly',
  20.                             'value1' => '0.2',
  21.                             'value2' => '0.4',
  22.                             'value3' => '0.6',
  23.                             ),
  24.                 => array('name' => 'Brian Sipe',
  25.                             'value1' => '0.3',
  26.                             'value2' => '0.3',
  27.                             'value3' => '0.4',
  28.                             ),
  29.                 => array('name' => 'Julius Erving',
  30.                             'value1' => '0.1',
  31.                             'value2' => '0.2',
  32.                             'value3' => '0.7',
  33.                             )
  34. );
  35.                 
  36.  
  37. foreach ($users as $user{
  38.     
  39.     $docx new CreateDocx();
  40.     
  41.     $docx->addBreak(array('type' => 'line'));
  42.  
  43.     $text array();
  44.     
  45.     $text[=
  46.         array(
  47.             'text' => 'Hi, ',
  48.     );
  49.     
  50.     $text[=
  51.         array(
  52.             'text' => $user['name'],
  53.             'b' => 'single',
  54.     );
  55.     
  56.     $text[=
  57.         array(
  58.             'text' => ' this is a sample text.'
  59.     );
  60.     
  61.     $docx->addText($text);
  62.     
  63.     $docx->addBreak(array('type' => 'line'));
  64.     
  65.     $docx->addText('Lorem ipsum dolor sit amet, consectetur: ');
  66.     
  67.     $paramsList array(
  68.         'val' => 1,
  69.         'bullets' => array(312)
  70.     );
  71.     
  72.     $valuesList array(
  73.         'Donec tellus justo',
  74.             array(
  75.                 'faucibus nec commodo quis',
  76.                 'dignissim ut ipsum',
  77.                 'Aenean hendrerit interdum',
  78.                     array(
  79.                         'Morbi malesuada luctus libero',
  80.                         'sodales est placerat eget',
  81.                         'Aenean eget nulla vel'
  82.                     ),
  83.             ),
  84.         'enim viverra iaculis',
  85.         'aliquet aliquam nisl',
  86.     );
  87.     $docx->addList($valuesList$paramsList);
  88.  
  89.     $docx->addBreak(array('type' => 'page'));
  90.     
  91.     $legends array(
  92.         'legend1' => array($user['value1']),
  93.         'legend2' => array($user['value2']),
  94.         'legend3' => array($user['value3'])
  95.     );
  96.     $args array(
  97.         'data' => $legends,
  98.         'type' => 'pie3DChart',
  99.         'title' => $user['name''\'s chart',
  100.         'rotX' => 20'rotY' => 20'perspective' => 30,
  101.         'color' => 2,
  102.         'textWrap' => 0,
  103.         'sizeX' => 10'sizeY' => 10,
  104.         'jc' => 'left',
  105.         'showPercent' => 1,
  106.         'font' => 'Times New Roman'
  107.     );
  108.     $docx->addChart($args);
  109.     
  110.     $docx->createDocx('../docx/example_multidocument_' $user['name']);
  111.  
  112. }

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