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

example

  1. <?php
  2.  
  3. /**
  4.  * Embeds shapes into a table using addParagraph
  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      2012.12.26
  15.  */
  16.  
  17. require_once '../../classes/CreateDocx.inc';
  18.  
  19. $docx new CreateDocx();
  20.  
  21. $colors array('red' =>'b70000',
  22.                 'grey' => '999999',
  23.                 'blue' => '2565ee',
  24.                 'green' => '25ee65');
  25.  
  26. $tableValues array();
  27.  
  28. foreach($colors as $key => $value){
  29.     $options array('spacingTop' => 0'spacingBottom' => 0'rawWordML' => true);
  30.     $rect array('type' => 'rect',
  31.                 'width' => 10,
  32.                 'height' => 10,
  33.                 'strokecolor' => '#555555',
  34.                 'strokeweight' => '1',
  35.                 'fillcolor' => '#'.$value);
  36.     $shapeData $docx->addParagraph(array($rect)$options);
  37.  
  38.     $text_1 array('color' => '000000',
  39.                   'font' => 'Arial',
  40.                   'sz' => '11',
  41.                   'type' => 'text',
  42.                   'text' => 'This is the color of the following chunk of text: '
  43.                );
  44.     $text_2 array('color' => $value,
  45.                   'font' => 'Arial',
  46.                   'sz' => '11',
  47.                   'type' => 'text',
  48.                   'text' => $key.' characters.'
  49.                );
  50.   $textData $docx->addParagraph(array($text_1$text_2)$options);
  51.   
  52.   $shape $docx->createWordMLFragment($shapeData);
  53.   $text $docx->createWordMLFragment($textData);
  54.  
  55.   $tableRow array($shape$text);
  56.   $tableValues[$tableRow;
  57. }
  58.  
  59. $tableOptions array('border' => 'none');
  60. $docx->addTable($tableValues$tableOptions);
  61.  
  62. $docx->createDocx('../docx/example_embedded_shapes');

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