forked from PHPOffice/PHPPresentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_11_Shape.php
153 lines (128 loc) · 5.33 KB
/
Sample_11_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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Bullet;
use PhpOffice\PhpPresentation\Style\Color;
include_once 'Sample_Header.php';
function fnSlideRichText(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100);
$shape->setWidth(600);
$shape->setOffsetX(100);
$shape->setOffsetY(100);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
$textRun = $shape->createTextRun('RichText with');
$textRun->getFont()->setBold(true);
$textRun->getFont()->setSize(28);
$textRun->getFont()->setColor(new Color('FF000000'));
$shape->createBreak();
$textRun = $shape->createTextRun('Multiline');
$textRun->getFont()->setBold(true);
$textRun->getFont()->setSize(60);
$textRun->getFont()->setColor(new Color('FF000000'));
}
function fnSlideRichTextLineSpacing(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text) with line spacing (100)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100);
$shape->setWidth(400);
$shape->setOffsetX(100);
$shape->setOffsetY(100);
$shape->getActiveParagraph()->setLineSpacing(100);
$shape->createTextRun('RichText with');
$shape->createBreak();
$shape->createTextRun('Line Spacing 100');
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text) with line spacing (200)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100);
$shape->setWidth(400);
$shape->setOffsetX(100);
$shape->setOffsetY(200);
$shape->getActiveParagraph()->setLineSpacing(200);
$shape->createTextRun('RichText with');
$shape->createBreak();
$shape->createTextRun('Line Spacing 200');
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text) with line spacing (300)' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100);
$shape->setWidth(400);
$shape->setOffsetX(100);
$shape->setOffsetY(300);
$shape->getActiveParagraph()->setLineSpacing(300);
$shape->createTextRun('RichText with');
$shape->createBreak();
$shape->createTextRun('Line Spacing 300');
}
function fnSlideRichTextShadow(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text) with shadow' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100);
$shape->setWidth(400);
$shape->setOffsetX(100);
$shape->setOffsetY(100);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
$shape->getShadow()->setVisible(true)->setAlpha(75)->setBlurRadius(2)->setDirection(45);
$textRun = $shape->createTextRun('RichText with shadow');
$textRun->getFont()->setColor(new Color('FF000000'));
}
function fnSlideRichTextList(PhpPresentation $objPHPPresentation): void
{
// Create templated slide
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text) with list with red bullet' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100);
$shape->setWidth(400);
$shape->setOffsetX(100);
$shape->setOffsetY(100);
$shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET)->setBulletColor(new Color(Color::COLOR_RED));
$shape->createTextRun('Alpha');
$shape->createParagraph()->createTextRun('Beta');
$shape->createParagraph()->createTextRun('Delta');
$shape->createParagraph()->createTextRun('Epsilon');
}
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$oProperties = $objPHPPresentation->getDocumentProperties();
$oProperties->setCreator('PHPOffice')
->setLastModifiedBy('PHPPresentation Team')
->setTitle('Sample 11 Title')
->setSubject('Sample 11 Subject')
->setDescription('Sample 11 Description')
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');
// Remove first slide
echo date('H:i:s') . ' Remove first slide' . EOL;
$objPHPPresentation->removeSlideByIndex(0);
fnSlideRichText($objPHPPresentation);
fnSlideRichTextLineSpacing($objPHPPresentation);
fnSlideRichTextShadow($objPHPPresentation);
fnSlideRichTextList($objPHPPresentation);
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}