PhpOffice\PhpPresentation\PhpPresentation::getSlide PHP Method

getSlide() public method

Get slide by index
public getSlide ( integer $index ) : Slide
$index integer Slide index
return Slide
    public function getSlide($index = 0)
    {
        if ($index > count($this->slideCollection) - 1) {
            throw new \Exception("Slide index is out of bounds.");
        } else {
            return $this->slideCollection[$index];
        }
    }

Usage Example

Example #1
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
         if ($pPhpPresentation->getSlide($i)->getShapeCollection()->count() > 0) {
             $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;
 }
All Usage Examples Of PhpOffice\PhpPresentation\PhpPresentation::getSlide