forked from PHPOffice/PHPPresentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_15_Background.php
41 lines (33 loc) · 1.31 KB
/
Sample_15_Background.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
<?php
include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Slide\Background\Color;
use PhpOffice\PhpPresentation\Slide\Background\Image;
use PhpOffice\PhpPresentation\Style\Color as StyleColor;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$oSlide1 = $objPHPPresentation->getActiveSlide();
$oSlide1->addShape(clone $oShapeDrawing);
$oSlide1->addShape(clone $oShapeRichText);
// Slide > Background > Color
$oBkgColor = new Color();
$oBkgColor->setColor(new StyleColor(StyleColor::COLOR_DARKGREEN));
$oSlide1->setBackground($oBkgColor);
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$oSlide2 = $objPHPPresentation->createSlide();
$oSlide2->addShape(clone $oShapeDrawing);
$oSlide2->addShape(clone $oShapeRichText);
// Slide > Background > Image
// @link : http://publicdomainarchive.com/public-domain-images-cave-red-rocks-light-beam-cavern/
$oBkgImage = new Image();
$oBkgImage->setPath(__DIR__ . '/resources/background.jpg');
$oSlide2->setBackground($oBkgImage);
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}