我已经完成了 PhpPresentation(master 分支)的手动安装,我正在尝试运行该软件包附带的一个简单示例,但我无法使其正常运行。我已经对如何解决进行了大量研究,但无济于事。请参阅下面的代码以及我不断收到的错误。
<?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");
?>
这是我收到的错误:
致命错误:未捕获的异常 'Exception' 带有消息 'File ./resources/phppowerpoint_logo.gif not found!' 在 C:\wamp\www\Classes\PHPPresentation-master\PHPPresentation-master\src\PhpPresentation\Shape\Drawing\File.php 第 34 行
虽然当我去寻找时,gif图像在那里......任何理解这一点的帮助表示赞赏。
谢谢