-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
executable file
·63 lines (49 loc) · 1.83 KB
/
main.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
<?php
/**
* Created by PhpStorm.
* User: willnewmarch
* Date: 23/09/2017
* Time: 09:50
*/
// with your own install
use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Alignment;
require_once 'PhpPresentation/src/PhpPresentation/Autoloader.php';
\PhpOffice\PhpPresentation\Autoloader::register();
require_once 'Common/src/Common/Autoloader.php';
\PhpOffice\Common\Autoloader::register();
$csv = array_map('str_getcsv', file($argv[1]));
$objPHPPowerPoint = new PhpPresentation();
$objPHPPowerPoint->removeSlideByIndex(0);
$slideCount = 0;
foreach ($csv as &$row) {
$objPHPPowerPoint->createSlide();
$slideCount++;
$currentSlide = $objPHPPowerPoint->getSlide($slideCount-1);
$title = $currentSlide->createRichTextShape()
->setHeight(300)
->setWidth(600)
->setOffsetX(170)
->setOffsetY(180);
$title->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $title->createTextRun($row[0]);
$textRun->getFont()->setBold(true)
->setSize(40)
->setColor(new Color('FF222222'));
$description = $currentSlide->createRichTextShape()
->setHeight(300)
->setWidth(600)
->setOffsetX(170)
->setOffsetY(360);
$description->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $description->createTextRun($row[1]);
$textRun->getFont()
->setSize(18)
->setColor(new Color('FF000000'));
}
$oWriterPPTX = IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
$oWriterPPTX->save(__DIR__ . "/".$argv[2].".pptx");
$oWriterODP = IOFactory::createWriter($objPHPPowerPoint, 'ODPresentation');
$oWriterODP->save(__DIR__ . "/".$argv[2].".odp");