Example #1
0
 public function testTypeBar()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oBar = new Bar();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
     $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
     $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
     $oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
     $oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
     $oBar->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oBar);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt/c:spPr';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:tx/c:v';
     $this->assertEquals($oSeries->getTitle(), $oXMLDoc->getElement($element, 'ppt/charts/' . $oShape->getIndexedFilename())->nodeValue);
 }
Example #2
0
 /**
  * Get an array of all drawings
  *
  * @param  PhpPresentation                 $pPhpPresentation
  * @return \PhpOffice\PhpPresentation\Shape\AbstractDrawing[] All drawings in PhpPresentation
  * @throws \Exception
  */
 public function allDrawings(PhpPresentation $pPhpPresentation)
 {
     // Get an array of all drawings
     $aDrawings = array();
     // Loop trough PhpPresentation
     $slideCount = $pPhpPresentation->getSlideCount();
     for ($i = 0; $i < $slideCount; ++$i) {
         // Loop trough images and add to array
         $iterator = $pPhpPresentation->getSlide($i)->getShapeCollection()->getIterator();
         while ($iterator->valid()) {
             if ($iterator->current() instanceof AbstractDrawing && !$iterator->current() instanceof Table) {
                 $aDrawings[] = $iterator->current();
             } elseif ($iterator->current() instanceof Group) {
                 $iterator2 = $iterator->current()->getShapeCollection()->getIterator();
                 while ($iterator2->valid()) {
                     if ($iterator2->current() instanceof AbstractDrawing && !$iterator2->current() instanceof Table) {
                         $aDrawings[] = $iterator2->current();
                     }
                     $iterator2->next();
                 }
             }
             $iterator->next();
         }
     }
     return $aDrawings;
 }
Example #3
0
 /**
  * Save PhpPresentation to file
  *
  * @param  string    $pFilename
  * @throws \Exception
  */
 public function save($pFilename)
 {
     if (empty($pFilename)) {
         throw new \Exception("Filename is empty.");
     }
     if (!is_null($this->presentation)) {
         // Create new ZIP file and open it for writing
         $objZip = new \ZipArchive();
         // Try opening the ZIP file
         if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) {
             if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) {
                 throw new \Exception("Could not open " . $pFilename . " for writing.");
             }
         }
         // Add media
         $slideCount = $this->presentation->getSlideCount();
         for ($i = 0; $i < $slideCount; ++$i) {
             for ($j = 0; $j < $this->presentation->getSlide($i)->getShapeCollection()->count(); ++$j) {
                 if ($this->presentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawing) {
                     $imgTemp = $this->presentation->getSlide($i)->getShapeCollection()->offsetGet($j);
                     $objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath()));
                 }
             }
         }
         // Add PhpPresentation.xml to the document, which represents a PHP serialized PhpPresentation object
         $objZip->addFromString('PhpPresentation.xml', $this->writeSerialized($this->presentation, $pFilename));
         // Close file
         if ($objZip->close() === false) {
             throw new \Exception("Could not close zip file {$pFilename}.");
         }
     } else {
         throw new \Exception("PhpPresentation object unassigned.");
     }
 }
 public function testFeatureThumbnail()
 {
     $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getPresentationProperties()->setThumbnailPath($imagePath);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/thumbnail.jpeg'));
 }
Example #5
0
 public function testParent()
 {
     $object = new Note();
     $this->assertNull($object->getParent());
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->createSlide();
     $oSlide->setNote($object);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getParent());
 }
 public function testCompany()
 {
     $expected = 'aAbBcDeE';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getDocumentProperties()->setCompany($expected);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/app.xml'));
     $this->assertTrue($oXMLDoc->elementExists('/Properties/Company', 'docProps/app.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/Properties/Company', 'docProps/app.xml')->nodeValue);
 }
 public function testCommentsAuthors()
 {
     $oAuthor = new Comment\Author();
     $oComment = new Comment();
     $oComment->setAuthor($oAuthor);
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getActiveSlide()->addShape($oComment);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($pres->elementExists('/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"]', 'ppt/_rels/presentation.xml.rels'));
 }
 public function testLastView()
 {
     $expectedElement = '/p:viewPr';
     $expectedLastView = PresentationProperties::VIEW_OUTLINE;
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getPresentationProperties()->setLastView($expectedLastView);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('ppt/viewProps.xml'));
     $this->assertTrue($oXMLDoc->elementExists($expectedElement, 'ppt/viewProps.xml'));
     $this->assertEquals($expectedLastView, $oXMLDoc->getElementAttribute($expectedElement, 'lastView', 'ppt/viewProps.xml'));
 }
 public function testDocumentProperties()
 {
     $expected = 'aAbBcDeE';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getDocumentProperties()->setCreator($expected);
     $oPhpPresentation->getDocumentProperties()->setTitle($expected);
     $oPhpPresentation->getDocumentProperties()->setDescription($expected);
     $oPhpPresentation->getDocumentProperties()->setSubject($expected);
     $oPhpPresentation->getDocumentProperties()->setKeywords($expected);
     $oPhpPresentation->getDocumentProperties()->setCategory($expected);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/core.xml'));
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:creator', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:creator', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:title', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:title', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:description', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:description', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:subject', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:subject', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:keywords', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:keywords', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:category', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:category', 'docProps/core.xml')->nodeValue);
 }
Example #10
0
 public function testGroup()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oGroup = $oSlide->createGroup();
     $oDrawing = new Drawing();
     $this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
     $this->assertEmpty($oDrawing->allDrawings($oPhpPresentation));
     $oGroup->createDrawingShape();
     $oGroup->createDrawingShape();
     $oGroup->createDrawingShape();
     $this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
     $this->assertCount(3, $oDrawing->allDrawings($oPhpPresentation));
 }
Example #11
0
 public function testMemoryDrawing()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = new MemoryDrawing();
     $gdImage = @imagecreatetruecolor(140, 20);
     $textColor = imagecolorallocate($gdImage, 255, 255, 255);
     imagestring($gdImage, 1, 5, 5, 'Created with PhpPresentation', $textColor);
     $oShape->setImageResource($gdImage)->setRenderingFunction(MemoryDrawing::RENDERING_JPEG)->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT);
     $oSlide->addShape($oShape);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
     $element = '/manifest:manifest/manifest:file-entry[5]';
     $this->assertTrue($pres->elementExists($element, 'META-INF/manifest.xml'));
     $this->assertEquals('Pictures/' . $oShape->getIndexedFilename(), $pres->getElementAttribute($element, 'manifest:full-path', 'META-INF/manifest.xml'));
 }
Example #12
0
 /**
  * Write presentation relationships to XML format
  *
  * @param  PhpPresentation $pPhpPresentation
  * @return string        XML Output
  * @throws \Exception
  */
 public function writePresentationRelationships(PhpPresentation $pPhpPresentation)
 {
     // Create XML writer
     $objWriter = $this->getXMLWriter();
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // Relation id
     $relationId = 1;
     $parentWriter = $this->getParentWriter();
     if ($parentWriter instanceof PowerPoint2007) {
         // Add slide masters
         $masterSlides = $parentWriter->getLayoutPack()->getMasterSlides();
         foreach ($masterSlides as $masterSlide) {
             // Relationship slideMasters/slideMasterX.xml
             $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster', 'slideMasters/slideMaster' . $masterSlide['masterid'] . '.xml');
         }
     }
     // Add slide theme (only one!)
     // Relationship theme/theme1.xml
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', 'theme/theme1.xml');
     // Relationships with slides
     $slideCount = $pPhpPresentation->getSlideCount();
     for ($i = 0; $i < $slideCount; ++$i) {
         $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slides/slide' . ($i + 1) . '.xml');
     }
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps', 'presProps.xml');
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps', 'viewProps.xml');
     $this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles', 'tableStyles.xml');
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
 /**
  * Test save
  */
 public function testSave()
 {
     $filename = tempnam(sys_get_temp_dir(), 'PhpPresentation');
     $imageFile = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/images/PhpPresentationLogo.png';
     $oPhpPresentation = new PhpPresentation();
     $slide = $oPhpPresentation->getActiveSlide();
     $slide->createRichTextShape();
     $slide->createLineShape(10, 10, 10, 10);
     $slide->createChartShape()->getPlotArea()->setType(new \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D());
     $slide->createDrawingShape()->setName('Drawing')->setPath($imageFile);
     $slide->createTableShape()->createRow();
     $object = new ODPresentation($oPhpPresentation);
     $object->save($filename);
     $this->assertTrue(file_exists($filename));
     unlink($filename);
 }
Example #14
0
 /**
  */
 public function testMethod()
 {
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->addSlide(new Slide());
     $object = new Iterator($oPhpPresentation);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
     $this->assertEquals(0, $object->key());
     $this->assertNull($object->next());
     $this->assertEquals(1, $object->key());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
     $this->assertTrue($object->valid());
     $this->assertNull($object->next());
     $this->assertFalse($object->valid());
     $this->assertNull($object->rewind());
     $this->assertEquals(0, $object->key());
 }
Example #15
0
 public function testTypeArea()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oArea = new Area();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
     $oArea->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oArea);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
 }
Example #16
0
 /**
  * Write Meta file to XML format
  *
  * @param  PhpPresentation $pPhpPresentation
  * @return string        XML Output
  * @throws \Exception
  */
 public function writePart(PhpPresentation $pPhpPresentation)
 {
     // Create XML writer
     $objWriter = $this->getXMLWriter();
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // office:document-meta
     $objWriter->startElement('office:document-meta');
     $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
     $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
     $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
     $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
     $objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
     $objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
     $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
     $objWriter->writeAttribute('xmlns:officeooo', 'http://openoffice.org/2009/office');
     $objWriter->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
     $objWriter->writeAttribute('office:version', '1.2');
     // office:meta
     $objWriter->startElement('office:meta');
     // dc:creator
     $objWriter->writeElement('dc:creator', $pPhpPresentation->getProperties()->getLastModifiedBy());
     // dc:date
     $objWriter->writeElement('dc:date', gmdate('Y-m-d\\TH:i:s.000', $pPhpPresentation->getProperties()->getModified()));
     // dc:description
     $objWriter->writeElement('dc:description', $pPhpPresentation->getProperties()->getDescription());
     // dc:subject
     $objWriter->writeElement('dc:subject', $pPhpPresentation->getProperties()->getSubject());
     // dc:title
     $objWriter->writeElement('dc:title', $pPhpPresentation->getProperties()->getTitle());
     // meta:creation-date
     $objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\\TH:i:s.000', $pPhpPresentation->getProperties()->getCreated()));
     // meta:initial-creator
     $objWriter->writeElement('meta:initial-creator', $pPhpPresentation->getProperties()->getCreator());
     // meta:keyword
     $objWriter->writeElement('meta:keyword', $pPhpPresentation->getProperties()->getKeywords());
     // @todo : Where these properties are written ?
     // $pPhpPresentation->getProperties()->getCategory()
     // $pPhpPresentation->getProperties()->getCompany()
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Example #17
0
 public function testVisibility()
 {
     $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePage0\']/style:drawing-page-properties';
     $pres = TestHelperDOCX::getDocument($this->oPresentation, 'ODPresentation');
     $this->assertTrue($pres->elementExists($expectedElement, 'content.xml'));
     $this->assertFalse($pres->attributeElementExists($expectedElement, 'presentation:visibility', 'content.xml'));
     $oSlide = $this->oPresentation->getActiveSlide();
     $oSlide->setIsVisible(false);
     $pres = TestHelperDOCX::getDocument($this->oPresentation, 'ODPresentation');
     $this->assertTrue($pres->elementExists($expectedElement, 'content.xml'));
     $this->assertTrue($pres->attributeElementExists($expectedElement, 'presentation:visibility', 'content.xml'));
     $this->assertEquals('hidden', $pres->getElementAttribute($expectedElement, 'presentation:visibility', 'content.xml'));
 }
Example #18
0
 public function testStrokeDash()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oRichText1 = $oSlide->createRichTextShape();
     $oRichText1->getBorder()->setColor(new Color('FF4672A8'))->setLineStyle(Border::LINE_SINGLE);
     $arrayDashStyle = array(Border::DASH_DASH, Border::DASH_DASHDOT, Border::DASH_DOT, Border::DASH_LARGEDASH, Border::DASH_LARGEDASHDOT, Border::DASH_LARGEDASHDOTDOT, Border::DASH_SYSDASH, Border::DASH_SYSDASHDOT, Border::DASH_SYSDASHDOTDOT, Border::DASH_SYSDOT);
     foreach ($arrayDashStyle as $style) {
         $oRichText1->getBorder()->setDashStyle($style);
         $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
         $element = '/office:document-styles/office:styles/draw:stroke-dash[@draw:name=\'strokeDash_' . $style . '\']';
         $this->assertTrue($pres->elementExists($element, 'styles.xml'));
         $this->assertEquals('rect', $pres->getElementAttribute($element, 'draw:style', 'styles.xml'));
         $this->assertTrue($pres->attributeElementExists($element, 'draw:distance', 'styles.xml'));
         switch ($style) {
             case Border::DASH_DOT:
             case Border::DASH_SYSDOT:
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1-length', 'styles.xml'));
                 break;
             case Border::DASH_DASH:
             case Border::DASH_LARGEDASH:
             case Border::DASH_SYSDASH:
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2-length', 'styles.xml'));
                 break;
             case Border::DASH_DASHDOT:
             case Border::DASH_LARGEDASHDOT:
             case Border::DASH_LARGEDASHDOTDOT:
             case Border::DASH_SYSDASHDOT:
             case Border::DASH_SYSDASHDOTDOT:
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1-length', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2-length', 'styles.xml'));
                 break;
         }
     }
 }
Example #19
0
 public function testChartArea()
 {
     $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
     $oSeries->getFill()->setStartColor(new Color('FF93A9CE'));
     $oArea = new Area();
     $oArea->addSeries($oSeries);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oChart = $oSlide->createChartShape();
     $oChart->getPlotArea()->setType($oArea);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:chart/chart:chart';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\']/style:graphic-properties';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'draw:fill', 'Object 1/content.xml'));
     $this->assertTrue($pres->attributeElementExists($element, 'draw:fill-color', 'Object 1/content.xml'));
     $this->assertEquals('#93A9CE', $pres->getElementAttribute($element, 'draw:fill-color', 'Object 1/content.xml'));
 }
Example #20
0
 public function testChartBarHorizontal()
 {
     $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
     $oSeries->setShowSeriesName(true);
     $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
     $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
     $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
     $oBar = new Bar();
     $oBar->setBarDirection(Bar::DIRECTION_HORIZONTAL);
     $oBar->addSeries($oSeries);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oChart = $oSlide->createChartShape();
     $oChart->getPlotArea()->setType($oBar);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:chart/chart:chart';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:bar', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('true', $pres->getElementAttribute($element, 'chart:vertical', 'Object 1/content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'chart:three-dimensional', 'Object 1/content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'chart:right-angled-axes', 'Object 1/content.xml'));
 }
 /**
  * Read Shape RichText
  *
  * @param \DOMElement $oNodeFrame
  */
 protected function loadShapeRichText(\DOMElement $oNodeFrame)
 {
     // Core
     $oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
     $oShape->setParagraphs(array());
     $oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
     $oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
     $oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
     $oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
     foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) {
         $this->levelParagraph = 0;
         if ($oNodeParagraph->nodeName == 'text:p') {
             $this->readParagraph($oShape, $oNodeParagraph);
         }
         if ($oNodeParagraph->nodeName == 'text:list') {
             $this->readList($oShape, $oNodeParagraph);
         }
     }
     if (count($oShape->getParagraphs()) > 0) {
         $oShape->setActiveParagraph(0);
     }
 }
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\IOFactory;
// 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;
$objPHPPresentation->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 03 Title')->setSubject('Sample 03 Subject')->setDescription('Sample 03 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();
// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape()->setHeight(300)->setWidth(600)->setOffsetX(170)->setOffsetY(180);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun('Thank you for using PHPPresentation!');
$textRun->getFont()->setBold(true)->setSize(60)->setColor(new Color('FFE06B20'));
// Save serialized file
$basename = basename(__FILE__, '.php');
echo date('H:i:s') . ' Write to serialized format' . EOL;
$objWriter = IOFactory::createWriter($objPHPPresentation, 'Serialized');
Example #23
0
 protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
 {
     $this->append('<div class="infoBlk" id="divPhpPresentationInfo">');
     $this->append('<dl>');
     $this->append('<dt>Number of slides</dt><dd>' . $oPHPPpt->getSlideCount() . '</dd>');
     $this->append('<dt>Document Layout Name</dt><dd>' . (empty($oPHPPpt->getLayout()->getDocumentLayout()) ? 'Custom' : $oPHPPpt->getLayout()->getDocumentLayout()) . '</dd>');
     $this->append('<dt>Document Layout Height</dt><dd>' . $oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
     $this->append('<dt>Document Layout Width</dt><dd>' . $oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
     $this->append('<dt>Properties : Category</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCategory() . '</dd>');
     $this->append('<dt>Properties : Company</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCompany() . '</dd>');
     $this->append('<dt>Properties : Created</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCreated() . '</dd>');
     $this->append('<dt>Properties : Creator</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCreator() . '</dd>');
     $this->append('<dt>Properties : Description</dt><dd>' . $oPHPPpt->getDocumentProperties()->getDescription() . '</dd>');
     $this->append('<dt>Properties : Keywords</dt><dd>' . $oPHPPpt->getDocumentProperties()->getKeywords() . '</dd>');
     $this->append('<dt>Properties : Last Modified By</dt><dd>' . $oPHPPpt->getDocumentProperties()->getLastModifiedBy() . '</dd>');
     $this->append('<dt>Properties : Modified</dt><dd>' . $oPHPPpt->getDocumentProperties()->getModified() . '</dd>');
     $this->append('<dt>Properties : Subject</dt><dd>' . $oPHPPpt->getDocumentProperties()->getSubject() . '</dd>');
     $this->append('<dt>Properties : Title</dt><dd>' . $oPHPPpt->getDocumentProperties()->getTitle() . '</dd>');
     $this->append('</dl>');
     $this->append('</div>');
     foreach ($oPHPPpt->getAllSlides() as $oSlide) {
         $this->append('<div class="infoBlk" id="div' . $oSlide->getHashCode() . 'Info">');
         $this->append('<dl>');
         $this->append('<dt>HashCode</dt><dd>' . $oSlide->getHashCode() . '</dd>');
         $this->append('<dt>Slide Layout</dt><dd>Layout::' . $this->getConstantName('\\PhpOffice\\PhpPresentation\\Slide\\Layout', $oSlide->getSlideLayout()) . '</dd>');
         $this->append('<dt>Offset X</dt><dd>' . $oSlide->getOffsetX() . '</dd>');
         $this->append('<dt>Offset Y</dt><dd>' . $oSlide->getOffsetY() . '</dd>');
         $this->append('<dt>Extent X</dt><dd>' . $oSlide->getExtentX() . '</dd>');
         $this->append('<dt>Extent Y</dt><dd>' . $oSlide->getExtentY() . '</dd>');
         $oBkg = $oSlide->getBackground();
         if ($oBkg instanceof Slide\AbstractBackground) {
             if ($oBkg instanceof Slide\Background\Color) {
                 $this->append('<dt>Background Color</dt><dd>#' . $oBkg->getColor()->getRGB() . '</dd>');
             }
             if ($oBkg instanceof Slide\Background\Image) {
                 $sBkgImgContents = file_get_contents($oBkg->getPath());
                 $this->append('<dt>Background Image</dt><dd><img src="data:image/png;base64,' . base64_encode($sBkgImgContents) . '"></dd>');
             }
         }
         $this->append('</dl>');
         $this->append('</div>');
         foreach ($oSlide->getShapeCollection() as $oShape) {
             if ($oShape instanceof Group) {
                 foreach ($oShape->getShapeCollection() as $oShapeChild) {
                     $this->displayShapeInfo($oShapeChild);
                 }
             } else {
                 $this->displayShapeInfo($oShape);
             }
         }
     }
 }
Example #24
0
 /**
  * A container record that specifies a presentation slide or title master slide.
  * @param string $stream
  * @param int $pos
  * @link http://msdn.microsoft.com/en-us/library/dd946323(v=office.12).aspx
  */
 private function readRecordSlideContainer($stream, $pos)
 {
     // Core
     $this->oPhpPresentation->createSlide();
     $this->oPhpPresentation->setActiveSlideIndex($this->oPhpPresentation->getSlideCount() - 1);
     // *** slideAtom (32 bytes)
     $slideAtom = $this->readRecordSlideAtom($stream, $pos);
     if ($slideAtom['length'] == 0) {
         throw new \Exception('PowerPoint97 Reader : record SlideAtom');
     }
     $pos += $slideAtom['length'];
     // *** slideShowSlideInfoAtom (24 bytes)
     $slideShowInfoAtom = $this->readRecordSlideShowSlideInfoAtom($stream, $pos);
     $pos += $slideShowInfoAtom['length'];
     // *** perSlideHFContainer (variable) : optional
     $perSlideHFContainer = $this->readRecordPerSlideHeadersFootersContainer($stream, $pos);
     $pos += $perSlideHFContainer['length'];
     // *** rtSlideSyncInfo12 (variable) : optional
     $rtSlideSyncInfo12 = $this->readRecordRoundTripSlideSyncInfo12Container($stream, $pos);
     $pos += $rtSlideSyncInfo12['length'];
     // *** drawing (variable)
     $drawing = $this->readRecordDrawingContainer($stream, $pos);
     $pos += $drawing['length'];
     // *** slideSchemeColorSchemeAtom (40 bytes)
     $slideSchemeColorAtom = $this->readRecordSlideSchemeColorSchemeAtom($stream, $pos);
     if ($slideSchemeColorAtom['length'] == 0) {
         throw new \Exception('PowerPoint97 Reader : record SlideSchemeColorSchemeAtom');
     }
     $pos += $slideSchemeColorAtom['length'];
     // *** slideNameAtom (variable)
     $slideNameAtom = $this->readRecordSlideNameAtom($stream, $pos);
     $pos += $slideNameAtom['length'];
     // *** slideProgTagsContainer (variable).
     $slideProgTags = $this->readRecordSlideProgTagsContainer($stream, $pos);
     $pos += $slideProgTags['length'];
     // *** rgRoundTripSlide (variable)
 }
Example #25
0
/**
 * Creates a templated slide
 *
 * @param PHPPresentation $objPHPPresentation
 * @return \PhpOffice\PhpPresentation\Slide
 */
function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPPresentation)
{
    // Create slide
    $slide = $objPHPPresentation->createSlide();
    // Add logo
    $shape = $slide->createDrawingShape();
    $shape->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
    $shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
    // Return slide
    return $slide;
}
Example #26
0
 /**
  * Re-bind parent
  *
  * @param  \PhpOffice\PhpPresentation\PhpPresentation       $parent
  * @return \PhpOffice\PhpPresentation\Slide
  */
 public function rebindParent(PhpPresentation $parent)
 {
     $this->parent->removeSlideByIndex($this->parent->getIndex($this));
     $this->parent = $parent;
     return $this;
 }
    // 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';
Example #28
0
 protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $baseFile)
 {
     // Core
     $oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
     $oShape->setParagraphs(array());
     // Variables
     $fileRels = 'ppt/slides/_rels/' . $baseFile . '.rels';
     $oElement = $document->getElement('p:spPr/a:xfrm', $node);
     if ($oElement && $oElement->hasAttribute('rot')) {
         $oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot')));
     }
     $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
     if ($oElement) {
         if ($oElement->hasAttribute('x')) {
             $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x')));
         }
         if ($oElement->hasAttribute('y')) {
             $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y')));
         }
     }
     $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
     if ($oElement) {
         if ($oElement->hasAttribute('cx')) {
             $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx')));
         }
         if ($oElement->hasAttribute('cy')) {
             $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy')));
         }
     }
     $arrayElements = $document->getElements('p:txBody/a:p', $node);
     foreach ($arrayElements as $oElement) {
         // Core
         $oParagraph = $oShape->createParagraph();
         $oParagraph->setRichTextElements(array());
         $oSubElement = $document->getElement('a:pPr', $oElement);
         if ($oSubElement) {
             if ($oSubElement->hasAttribute('algn')) {
                 $oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn'));
             }
             if ($oSubElement->hasAttribute('fontAlgn')) {
                 $oParagraph->getAlignment()->setVertical($oSubElement->getAttribute('fontAlgn'));
             }
             if ($oSubElement->hasAttribute('marL')) {
                 $oParagraph->getAlignment()->setMarginLeft(CommonDrawing::emuToPixels($oSubElement->getAttribute('marL')));
             }
             if ($oSubElement->hasAttribute('marR')) {
                 $oParagraph->getAlignment()->setMarginRight(CommonDrawing::emuToPixels($oSubElement->getAttribute('marR')));
             }
             if ($oSubElement->hasAttribute('indent')) {
                 $oParagraph->getAlignment()->setIndent(CommonDrawing::emuToPixels($oSubElement->getAttribute('indent')));
             }
             if ($oSubElement->hasAttribute('lvl')) {
                 $oParagraph->getAlignment()->setLevel($oSubElement->getAttribute('lvl'));
             }
             $oElementBuFont = $document->getElement('a:buFont', $oSubElement);
             $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
             if ($oElementBuFont) {
                 if ($oElementBuFont->hasAttribute('typeface')) {
                     $oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface'));
                 }
             }
             $oElementBuChar = $document->getElement('a:buChar', $oSubElement);
             if ($oElementBuChar) {
                 $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
                 if ($oElementBuChar->hasAttribute('char')) {
                     $oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char'));
                 }
             }
             /*$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
               if ($oElementBuAutoNum) {
                   $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC);
                   if ($oElementBuAutoNum->hasAttribute('type')) {
                       $oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type'));
                   }
                   if ($oElementBuAutoNum->hasAttribute('startAt') && $oElementBuAutoNum->getAttribute('startAt') != 1) {
                       $oParagraph->getBulletStyle()->setBulletNumericStartAt($oElementBuAutoNum->getAttribute('startAt'));
                   }
               }*/
         }
         $arraySubElements = $document->getElements('(a:r|a:br)', $oElement);
         foreach ($arraySubElements as $oSubElement) {
             if ($oSubElement->tagName == 'a:br') {
                 $oParagraph->createBreak();
             }
             if ($oSubElement->tagName == 'a:r') {
                 $oElementrPr = $document->getElement('a:rPr', $oSubElement);
                 if (is_object($oElementrPr)) {
                     $oText = $oParagraph->createTextRun();
                     if ($oElementrPr->hasAttribute('b')) {
                         $oText->getFont()->setBold($oElementrPr->getAttribute('b') == 'true' ? true : false);
                     }
                     if ($oElementrPr->hasAttribute('i')) {
                         $oText->getFont()->setItalic($oElementrPr->getAttribute('i') == 'true' ? true : false);
                     }
                     if ($oElementrPr->hasAttribute('strike')) {
                         $oText->getFont()->setStrikethrough($oElementrPr->getAttribute('strike') == 'noStrike' ? false : true);
                     }
                     if ($oElementrPr->hasAttribute('sz')) {
                         $oText->getFont()->setSize((int) ($oElementrPr->getAttribute('sz') / 100));
                     }
                     if ($oElementrPr->hasAttribute('u')) {
                         $oText->getFont()->setUnderline($oElementrPr->getAttribute('u'));
                     }
                     // Color
                     $oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr);
                     if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
                         $oColor = new Color();
                         $oColor->setRGB($oElementSrgbClr->getAttribute('val'));
                         $oText->getFont()->setColor($oColor);
                     }
                     // Hyperlink
                     $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr);
                     if (is_object($oElementHlinkClick)) {
                         if ($oElementHlinkClick->hasAttribute('tooltip')) {
                             $oText->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip'));
                         }
                         if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')])) {
                             $oText->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]);
                         }
                     }
                     //} else {
                     // $oText = $oParagraph->createText();
                 }
                 $oSubSubElement = $document->getElement('a:t', $oSubElement);
                 $oText->setText($oSubSubElement->nodeValue);
             }
         }
     }
     if (count($oShape->getParagraphs()) > 0) {
         $oShape->setActiveParagraph(0);
     }
 }
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set the zoom to 200%
$objPHPPresentation->setZoom(3);
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();
$currentSlide->addShape(clone $oShapeDrawing);
$currentSlide->addShape(clone $oShapeRichText);
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Fill;
use PhpOffice\PhpPresentation\Style\Border;
// 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;
$objPHPPresentation->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 01 Title')->setSubject('Sample 01 Subject')->setDescription('Sample 01 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();
for ($inc = 1; $inc <= 4; $inc++) {
    // Create a shape (text)
    echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
    $shape = $currentSlide->createRichTextShape()->setHeight(200)->setWidth(300);
    if ($inc == 1 || $inc == 3) {
        $shape->setOffsetX(10);
    } else {
        $shape->setOffsetX(320);
    }
    if ($inc == 1 || $inc == 2) {
        $shape->setOffsetY(10);
    } else {
        $shape->setOffsetY(220);
    }