forked from PHPOffice/PHPWord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_31_Shape.php
98 lines (87 loc) · 2.24 KB
/
Sample_31_Shape.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// New section
$section = $phpWord->addSection();
// Define styles
$phpWord->addTitleStyle(1, ['size' => 14, 'bold' => true]);
// Arc
$section->addTitle('Arc', 1);
$section->addShape(
'arc',
[
'points' => '-90 20',
'frame' => ['width' => 120, 'height' => 120],
'outline' => ['color' => '#333333', 'weight' => 2, 'startArrow' => 'oval', 'endArrow' => 'open'],
]
);
// Curve
$section->addTitle('Curve', 1);
$section->addShape(
'curve',
[
'points' => '1,100 200,1 1,50 200,50',
'connector' => 'elbow',
'outline' => [
'color' => '#66cc00',
'weight' => 2,
'dash' => 'dash',
'startArrow' => 'diamond',
'endArrow' => 'block',
],
]
);
// Line
$section->addTitle('Line', 1);
$section->addShape(
'line',
[
'points' => '1,1 150,30',
'outline' => [
'color' => '#cc00ff',
'line' => 'thickThin',
'weight' => 3,
'startArrow' => 'oval',
'endArrow' => 'classic',
],
]
);
// Polyline
$section->addTitle('Polyline', 1);
$section->addShape(
'polyline',
[
'points' => '1,30 20,10 55,20 75,10 100,40 115,50, 120,15 200,50',
'outline' => ['color' => '#cc6666', 'weight' => 2, 'startArrow' => 'none', 'endArrow' => 'classic'],
]
);
// Rectangle
$section->addTitle('Rectangle', 1);
$section->addShape(
'rect',
[
'roundness' => 0.2,
'frame' => ['width' => 100, 'height' => 100, 'left' => 1, 'top' => 1],
'fill' => ['color' => '#FFCC33'],
'outline' => ['color' => '#990000', 'weight' => 1],
'shadow' => [],
]
);
// Oval
$section->addTitle('Oval', 1);
$section->addShape(
'oval',
[
'frame' => ['width' => 100, 'height' => 70, 'left' => 1, 'top' => 1],
'fill' => ['color' => '#33CC99'],
'outline' => ['color' => '#333333', 'weight' => 2],
'extrusion' => [],
]
);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}