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

example

  1. <?php
  2.  
  3. /**
  4.  * Create different shapes
  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. $docx->addText('Arc:');
  22.  
  23. $options array('width' => 90,
  24.                  'height' => 90,
  25.                  //'coordsize' => '3000,500',
  26.                  'fillcolor' => '#555555',
  27.                  'strokecolor' => '#ff0000',
  28.                  'strokeweight' => '4',
  29.                  'startAngle' => 0,
  30.                  'endAngle' => 210,);
  31.                                  
  32.  
  33. $docx->addShape('arc'$options);
  34.  
  35. $docx->addText('Curve:');
  36.  
  37. $options array('from' => '300,40',
  38.                  'to' => '120,150',
  39.                  'fillcolor' => '#555555',
  40.                  'strokecolor' => '#ff0000',
  41.                  'strokeweight' => '4',
  42.                  'control1' => '60,70',
  43.                  'control2' => '125,170');
  44.                                  
  45.  
  46. $docx->addShape('curve'$options);
  47.  
  48. $docx->addText('Line:');
  49.  
  50. $options array('from' => '10,10',
  51.                  'to' => '150,10',
  52.                  'strokecolor' => '#0000ff',
  53.                  'strokeweight' => '2',
  54.                  'position' => 'absolute',
  55.                  'margin-left' => 20);
  56.                                  
  57. $docx->addShape('line'$options);                                 
  58.  
  59. $docx->addText('Polyline:');
  60.  
  61. $options array('points' => '10,10 20,20 25,10 40,7 3,55',
  62.                  'strokecolor' => '#ff00ff',
  63.                  'strokeweight' => '2',
  64.                  'position' => 'absolute',
  65.                  'margin-left' => 40,
  66.                  'margin-bottom' => 140);                                 
  67.  
  68. $docx->addShape('polyline'$options);
  69.  
  70. $docx->addBreak();
  71.  
  72. $docx->addText('Rectangle:');
  73.  
  74. $options array('width' => 60,
  75.                  'height' => 30,
  76.                  'strokecolor' => '#ff00ff',
  77.                  'strokeweight' => '3',
  78.                  'fillcolor' => '#ffff00',
  79.                  'position' => 'absolute',
  80.                  'margin-left' => 10,
  81.                  'margin-top' => -5);                                 
  82.  
  83. $docx->addShape('rect'$options);
  84.  
  85. $docx->addText('Rounded rectangle:');
  86.  
  87. $options array('width' => 60,
  88.                  'height' => 30,
  89.                  'strokecolor' => '#ff00ff',
  90.                  'strokeweight' => '3',
  91.                  'fillcolor' => '#ffff00',
  92.                  'position' => 'absolute',
  93.                  'margin-left' => 60,
  94.                  'margin-top' => 2,
  95.                  'arcsize' => 0.3);                                 
  96.  
  97. $docx->addShape('roundrect'$options);
  98.  
  99. $docx->addBreak();
  100.  
  101. $docx->addText('Arbitrary shape:');
  102.  
  103. $options array('path' => 'm,118hdc80,65,159,24,252,v33,11,66,24,100,34c374,41,413,29,419,51v30,109,-6,202,-100,234c308,296,299,311,285,318v-31,16,-100,34,-100,34c140,341,92,339,51,318,33,309,20,288,17,268,14,251,34,218,34,218hal,118hdxe',
  104.                  'width' => 50,
  105.                  'height' => 50,
  106.                  'strokecolor' => '#000000',
  107.                  'strokeweight' => '2',
  108.                  'fillcolor' => '#ff0000',
  109.                  'position' => 'absolute',
  110.                  'margin-left' => 5,
  111.                  'margin-top' => 0);                                 
  112.  
  113. $docx->addShape('shape'$options);
  114.  
  115. $docx->addBreak();
  116.  
  117. $docx->addText('The same arbitrary shape but with negative z-index and a negative margin-top so it is drawn behind this text.');
  118.  
  119. $options array('path' => 'm,118hdc80,65,159,24,252,v33,11,66,24,100,34c374,41,413,29,419,51v30,109,-6,202,-100,234c308,296,299,311,285,318v-31,16,-100,34,-100,34c140,341,92,339,51,318,33,309,20,288,17,268,14,251,34,218,34,218hal,118hdxe',
  120.                  'width' => 100,
  121.                  'height' => 100,
  122.                  'strokecolor' => '#dddddd',
  123.                  'strokeweight' => '2',
  124.                  'fillcolor' => '#ffff00',
  125.                  'position' => 'absolute',
  126.                  'margin-left' => 25,
  127.                  'margin-top' => -45,
  128.                  'z-index' => -100);                                 
  129.  
  130. $docx->addShape('shape'$options);
  131.  
  132. $docx->addBreak();
  133.  
  134. $docx->addText('An oval with no fill color and a circle with yellow color:');
  135.  
  136. $options array('width' => 100,
  137.                  'height' => 60,
  138.                  'strokecolor' => '#000000',
  139.                  'strokeweight' => '2');                                 
  140.  
  141. $docx->addShape('oval'$options);
  142.  
  143. $options array('width' => 100,
  144.                  'height' => 100,
  145.                  'strokecolor' => '#000000',
  146.                  'strokeweight' => '2',
  147.                  'fillcolor' => '#ffff00',
  148.                  'position' => 'absolute',
  149.                  'margin-top' => -75,
  150.                  'margin-left' => 150);                                 
  151.  
  152. $docx->addShape('oval'$options);
  153.  
  154. $docx->addBreak();
  155.  
  156. $docx->addText('Now we are going to insert a shape in two different table cells:');
  157.  
  158. $options array('width' => 100,
  159.                  'height' => 60,
  160.                  'strokecolor' => '#000000',
  161.                  'strokeweight' => '2',
  162.                  'rawWordML' => true);                                 
  163.  
  164. $docx->addShape('oval'$options);
  165.  
  166. $SHAPEdata $docx->addShape('oval'$options);
  167.  
  168. $fragment $docx->createWordMLFragment($SHAPEdata);
  169.  
  170. $valuesTable array(
  171.     array(
  172.         11,
  173.         $fragment
  174.     ),
  175.     array(
  176.         $fragment,
  177.         22
  178.     ),
  179. );
  180.  
  181. $paramsTable array(
  182.     'border' => 'single',
  183.     'border_sz' => 5,
  184. );
  185.  
  186. $test $docx->addTable($valuesTable$paramsTable);
  187.     
  188. $docx->createDocx('../docx/example_shapes');

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