oPhpPresentation = $oPHPPpt; } public function renderHtml() { $this->append('
'); $this->append('
'); $this->append('
'); $this->append('
'); $this->append('
    '); $this->displayPhpPresentation($this->oPhpPresentation); $this->append('
'); $this->append('
'); $this->append('
'); $this->append('
'); $this->displayPhpPresentationInfo($this->oPhpPresentation); $this->append('
'); $this->append('
'); $this->append('
'); return $this->htmlOutput; } protected function append($sHTML) { $this->htmlOutput .= $sHTML; } protected function displayPhpPresentation(PhpPresentation $oPHPPpt) { $this->append('
  • PhpPresentation'); $this->append(''); $this->append('
  • '); } protected function displayShape(AbstractShape $shape) { if ($shape instanceof Drawing\Gd) { $this->append('
  • Shape "Drawing\Gd"
  • '); } elseif ($shape instanceof Drawing\File) { $this->append('
  • Shape "Drawing\File"
  • '); } elseif ($shape instanceof Drawing\Base64) { $this->append('
  • Shape "Drawing\Base64"
  • '); } elseif ($shape instanceof Drawing\ZipFile) { $this->append('
  • Shape "Drawing\Zip"
  • '); } elseif ($shape instanceof RichText) { $this->append('
  • Shape "RichText"
  • '); } else { var_dump($shape); } } protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt) { $this->append('
    '); $this->append('
    '); $this->append('
    Number of slides
    ' . $oPHPPpt->getSlideCount() . '
    '); $this->append('
    Document Layout Name
    ' . (empty($oPHPPpt->getLayout()->getDocumentLayout()) ? 'Custom' : $oPHPPpt->getLayout()->getDocumentLayout()) . '
    '); $this->append('
    Document Layout Height
    ' . $oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER) . ' mm
    '); $this->append('
    Document Layout Width
    ' . $oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER) . ' mm
    '); $this->append('
    Properties : Category
    ' . $oPHPPpt->getDocumentProperties()->getCategory() . '
    '); $this->append('
    Properties : Company
    ' . $oPHPPpt->getDocumentProperties()->getCompany() . '
    '); $this->append('
    Properties : Created
    ' . $oPHPPpt->getDocumentProperties()->getCreated() . '
    '); $this->append('
    Properties : Creator
    ' . $oPHPPpt->getDocumentProperties()->getCreator() . '
    '); $this->append('
    Properties : Description
    ' . $oPHPPpt->getDocumentProperties()->getDescription() . '
    '); $this->append('
    Properties : Keywords
    ' . $oPHPPpt->getDocumentProperties()->getKeywords() . '
    '); $this->append('
    Properties : Last Modified By
    ' . $oPHPPpt->getDocumentProperties()->getLastModifiedBy() . '
    '); $this->append('
    Properties : Modified
    ' . $oPHPPpt->getDocumentProperties()->getModified() . '
    '); $this->append('
    Properties : Subject
    ' . $oPHPPpt->getDocumentProperties()->getSubject() . '
    '); $this->append('
    Properties : Title
    ' . $oPHPPpt->getDocumentProperties()->getTitle() . '
    '); $this->append('
    '); $this->append('
    '); foreach ($oPHPPpt->getAllSlides() as $oSlide) { $this->append('
    '); $this->append('
    '); $this->append('
    HashCode
    ' . $oSlide->getHashCode() . '
    '); $this->append('
    Slide Layout
    Layout::' . $this->getConstantName('\PhpOffice\PhpPresentation\Slide\Layout', $oSlide->getSlideLayout()) . '
    '); $this->append('
    Offset X
    ' . $oSlide->getOffsetX() . '
    '); $this->append('
    Offset Y
    ' . $oSlide->getOffsetY() . '
    '); $this->append('
    Extent X
    ' . $oSlide->getExtentX() . '
    '); $this->append('
    Extent Y
    ' . $oSlide->getExtentY() . '
    '); $oBkg = $oSlide->getBackground(); if ($oBkg instanceof Slide\AbstractBackground) { if ($oBkg instanceof Slide\Background\Color) { $this->append('
    Background Color
    #' . $oBkg->getColor()->getRGB() . '
    '); } if ($oBkg instanceof Slide\Background\Image) { $sBkgImgContents = file_get_contents($oBkg->getPath()); $this->append('
    Background Image
    '); } } $oNote = $oSlide->getNote(); if ($oNote->getShapeCollection()->count() > 0) { $this->append('
    Notes
    '); foreach ($oNote->getShapeCollection() as $oShape) { if ($oShape instanceof RichText) { $this->append('
    ' . $oShape->getPlainText() . '
    '); } } } $this->append('
    '); $this->append('
    '); foreach ($oSlide->getShapeCollection() as $oShape) { if ($oShape instanceof Group) { foreach ($oShape->getShapeCollection() as $oShapeChild) { $this->displayShapeInfo($oShapeChild); } } else { $this->displayShapeInfo($oShape); } } } } protected function displayShapeInfo(AbstractShape $oShape) { $this->append('
    '); $this->append('
    '); $this->append('
    HashCode
    ' . $oShape->getHashCode() . '
    '); $this->append('
    Offset X
    ' . $oShape->getOffsetX() . '
    '); $this->append('
    Offset Y
    ' . $oShape->getOffsetY() . '
    '); $this->append('
    Height
    ' . $oShape->getHeight() . '
    '); $this->append('
    Width
    ' . $oShape->getWidth() . '
    '); $this->append('
    Rotation
    ' . $oShape->getRotation() . '°
    '); $this->append('
    Hyperlink
    ' . ucfirst(var_export($oShape->hasHyperlink(), true)) . '
    '); $this->append('
    Fill
    '); if (is_null($oShape->getFill())) { $this->append('
    None
    '); } else { switch ($oShape->getFill()->getFillType()) { case \PhpOffice\PhpPresentation\Style\Fill::FILL_NONE: $this->append('
    None
    '); break; case \PhpOffice\PhpPresentation\Style\Fill::FILL_SOLID: $this->append('
    Solid ('); $this->append('Color : #' . $oShape->getFill()->getStartColor()->getRGB()); $this->append(' - Alpha : ' . $oShape->getFill()->getStartColor()->getAlpha() . '%'); $this->append(')
    '); break; } } $this->append('
    Border
    @Todo
    '); $this->append('
    IsPlaceholder
    ' . ($oShape->isPlaceholder() ? 'true' : 'false') . '
    '); if ($oShape instanceof Drawing\Gd) { $this->append('
    Name
    ' . $oShape->getName() . '
    '); $this->append('
    Description
    ' . $oShape->getDescription() . '
    '); ob_start(); call_user_func($oShape->getRenderingFunction(), $oShape->getImageResource()); $sShapeImgContents = ob_get_contents(); ob_end_clean(); $this->append('
    Mime-Type
    ' . $oShape->getMimeType() . '
    '); $this->append('
    Image
    '); if ($oShape->hasHyperlink()) { $this->append('
    Hyperlink URL
    ' . $oShape->getHyperlink()->getUrl() . '
    '); $this->append('
    Hyperlink Tooltip
    ' . $oShape->getHyperlink()->getTooltip() . '
    '); } } elseif ($oShape instanceof Drawing\AbstractDrawingAdapter) { $this->append('
    Name
    ' . $oShape->getName() . '
    '); $this->append('
    Description
    ' . $oShape->getDescription() . '
    '); } elseif ($oShape instanceof RichText) { $this->append('
    # of paragraphs
    ' . count($oShape->getParagraphs()) . '
    '); $this->append('
    Inset (T / R / B / L)
    ' . $oShape->getInsetTop() . 'px / ' . $oShape->getInsetRight() . 'px / ' . $oShape->getInsetBottom() . 'px / ' . $oShape->getInsetLeft() . 'px
    '); $this->append('
    Text
    '); $this->append('
    '); foreach ($oShape->getParagraphs() as $oParagraph) { $this->append('Paragraph
    '); $this->append('
    Alignment Horizontal
    Alignment::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Alignment', $oParagraph->getAlignment()->getHorizontal()) . '
    '); $this->append('
    Alignment Vertical
    Alignment::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Alignment', $oParagraph->getAlignment()->getVertical()) . '
    '); $this->append('
    Alignment Margin (L / R)
    ' . $oParagraph->getAlignment()->getMarginLeft() . ' px / ' . $oParagraph->getAlignment()->getMarginRight() . 'px
    '); $this->append('
    Alignment Indent
    ' . $oParagraph->getAlignment()->getIndent() . ' px
    '); $this->append('
    Alignment Level
    ' . $oParagraph->getAlignment()->getLevel() . '
    '); $this->append('
    Bullet Style
    Bullet::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Bullet', $oParagraph->getBulletStyle()->getBulletType()) . '
    '); if (Bullet::TYPE_NONE != $oParagraph->getBulletStyle()->getBulletType()) { $this->append('
    Bullet Font
    ' . $oParagraph->getBulletStyle()->getBulletFont() . '
    '); $this->append('
    Bullet Color
    ' . $oParagraph->getBulletStyle()->getBulletColor()->getARGB() . '
    '); } if (Bullet::TYPE_BULLET == $oParagraph->getBulletStyle()->getBulletType()) { $this->append('
    Bullet Char
    ' . $oParagraph->getBulletStyle()->getBulletChar() . '
    '); } if (Bullet::TYPE_NUMERIC == $oParagraph->getBulletStyle()->getBulletType()) { $this->append('
    Bullet Start At
    ' . $oParagraph->getBulletStyle()->getBulletNumericStartAt() . '
    '); $this->append('
    Bullet Style
    ' . $oParagraph->getBulletStyle()->getBulletNumericStyle() . '
    '); } $this->append('
    Line Spacing
    ' . $oParagraph->getLineSpacing() . '
    '); $this->append('
    RichText
    '); foreach ($oParagraph->getRichTextElements() as $oRichText) { if ($oRichText instanceof BreakElement) { $this->append('
    Break
    '); } else { if ($oRichText instanceof TextElement) { $this->append('
    TextElement
    '); } else { $this->append('
    Run
    '); } $this->append('
    ' . $oRichText->getText()); $this->append('
    '); $this->append('
    Font Name
    ' . $oRichText->getFont()->getName() . '
    '); $this->append('
    Font Size
    ' . $oRichText->getFont()->getSize() . '
    '); $this->append('
    Font Color
    #' . $oRichText->getFont()->getColor()->getARGB() . '
    '); $this->append('
    Font Transform
    '); $this->append('Bold : ' . ($oRichText->getFont()->isBold() ? 'Y' : 'N') . ' - '); $this->append('Italic : ' . ($oRichText->getFont()->isItalic() ? 'Y' : 'N') . ' - '); $this->append('Underline : Underline::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Font', $oRichText->getFont()->getUnderline()) . ' - '); $this->append('Strikethrough : ' . ($oRichText->getFont()->isStrikethrough() ? 'Y' : 'N') . ' - '); $this->append('SubScript : ' . ($oRichText->getFont()->isSubScript() ? 'Y' : 'N') . ' - '); $this->append('SuperScript : ' . ($oRichText->getFont()->isSuperScript() ? 'Y' : 'N')); $this->append('
    '); if ($oRichText instanceof TextElement) { if ($oRichText->hasHyperlink()) { $this->append('
    Hyperlink URL
    ' . $oRichText->getHyperlink()->getUrl() . '
    '); $this->append('
    Hyperlink Tooltip
    ' . $oRichText->getHyperlink()->getTooltip() . '
    '); } } $this->append('
    '); $this->append('
    '); } } $this->append('
    '); } $this->append('
    '); } else { // Add another shape } $this->append('
    '); $this->append('
    '); } protected function getConstantName($class, $search, $startWith = '') { $fooClass = new \ReflectionClass($class); $constants = $fooClass->getConstants(); $constName = null; foreach ($constants as $key => $value) { if ($value == $search) { if (empty($startWith) || (!empty($startWith) && 0 === strpos($key, $startWith))) { $constName = $key; } break; } } return $constName; } }