0

I've done the manual install of PhpPresentation (master branch) and I'm trying to run one of the simple examples that come with the package and I can't get it running properly. I've done tons of research on how to resolve, but to no avail. See the code below along with the errors I keep receiving.

<?php

require_once 'C:/wamp/www/Classes/PHPPresentation-master/PHPPresentation-master/src/PhpPresentation/Autoloader.php';
\PhpOffice\PhpPresentation\Autoloader::register();

require_once 'C:/wamp/www/Classes/Common-master/src/Common/Autoloader.php';
\PhpOffice\Common\Autoloader::register();

use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Alignment;

$objPHPPowerPoint = new PhpPresentation();

// Create slide
$currentSlide = $objPHPPowerPoint->getActiveSlide();

// Create a shape (drawing)
$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)
$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' ) );

$oWriterPPTX = IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
$oWriterPPTX->save(__DIR__ . "/sample.pptx");
$oWriterODP = IOFactory::createWriter($objPHPPowerPoint, 'ODPresentation');
$oWriterODP->save(__DIR__ . "/sample.odp");
?>

And here's the error I'm receiving:

Fatal error: Uncaught exception 'Exception' with message 'File ./resources/phppowerpoint_logo.gif not found!' in C:\wamp\www\Classes\PHPPresentation-master\PHPPresentation-master\src\PhpPresentation\Shape\Drawing\File.php on line 34

Though when I go looking, the gif image is there...any help in understand this is appreciated.

Thanks

1 Answers1

0

I too face this kind of errors most repeatedly while using PHPpresentation. The gif image has to be placed inside the resources folder but not in the Pictures folder. Try to execute by creating a sample image in the resources folder with the same name. It worked for me

John
  • 565
  • 8
  • 23