首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么所有的PhpPresentation示例都不起作用?

为什么所有的PhpPresentation示例都不起作用?
EN

Stack Overflow用户
提问于 2017-10-20 21:50:05
回答 1查看 590关注 0票数 0

我已经完成了PhpPresentation (主分支)的手动安装,我正在尝试运行软件包附带的一个简单示例,但我无法让它正常运行。我做了大量关于如何解决的研究,但都没有用。请看下面的代码以及我不断收到的错误。

代码语言:javascript
复制
<?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!‘在第34行的C:\wamp\www\Classes\PHPPresentation-master\PHPPresentation-master\src\PhpPresentation\Shape\Drawing\File.php中

虽然当我去看的时候,gif图像是there...any帮助理解这是赞赏的。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-08-08 15:42:03

在使用PHPpresentation时,我也经常遇到这种错误。gif图像必须放在resources文件夹中,而不是Pictures文件夹中。尝试通过在资源文件夹中创建具有相同名称的示例图像来执行。这对我很管用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46850552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档