我试图使用PhpPowerpoint API动态地将powerpoint嵌入到我的网页,但没有成功。
这是我的代码:
<?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中
有什么建议吗?
发布于 2017-06-13 13:42:02
您不能从读取器PowerPoint2007打开一个URI,因为它试图用ZipArchive (它不接受URI)打开它。
解决方案是在本地复制文件:
$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(); https://stackoverflow.com/questions/44507273
复制相似问题