0

我正在尝试使用 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

有什么建议么?

4

1 回答 1

0

您无法从阅读器 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(); 
于 2017-06-13T13:42:02.327 回答