首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用powerpoint作为PhpPowerpoint阅读器

使用powerpoint作为PhpPowerpoint阅读器
EN

Stack Overflow用户
提问于 2017-06-12 19:25:05
回答 1查看 888关注 0票数 0

我试图使用PhpPowerpoint API动态地将powerpoint嵌入到我的网页,但没有成功。

这是我的代码:

代码语言:javascript
复制
<?php     
    use PhpOffice\PhpPresentation\PhpPresentation;
    use PhpOffice\PhpPresentation\IOFactory;
    use PhpOffice\PhpPresentation\Style\Alignment;
    use PhpOffice\PhpPresentation\Style\Color;
    use PhpOffice\PhpPresentation\Shape\MemoryDrawing;
    use PhpOffice\PhpPresentation\Style\Fill;

    require_once 'PhpPresentation/src/PhpPresentation/Autoloader.php';
    \PhpOffice\PhpPresentation\Autoloader::register();

    require_once 'Common/src/Common/Autoloader.php';
    \PhpOffice\Common\Autoloader::register();

    $pptReader = IOFactory::createReader('PowerPoint2007');
    $oPHPPresentation = $pptReader->load('http://webitcloud.net/PW/1617/weduc/Teste.pptx');

    $oTree = new PhpPptTree($oPHPPresentation);
    echo $oTree->display();       
?>

出现的错误是:

“不能打开http://webitcloud.net/PW/1617/weduc/Teste.pptx来读取!文件不存在。”在/home/webitcloud/public_html/PW/1617/weduc/PhpPresentation/src/PhpPresentation/Reader/PowerPoint2007.php:97中

有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2017-06-13 13:42:02

您不能从读取器PowerPoint2007打开一个URI,因为它试图用ZipArchive (它不接受URI)打开它。

解决方案是在本地复制文件:

代码语言:javascript
复制
$file = 'http://remote/url/file.zip';
$newfile = 'tmp_file.zip';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}
$pptReader = IOFactory::createReader('PowerPoint2007');
$oPHPPresentation = $pptReader->load($newfile);

$oTree = new PhpPptTree($oPHPPresentation);
echo $oTree->display(); 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44507273

复制
相关文章

相似问题

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