我正在使用下面的代码来加载一个 pptx 文件并保存到一个新的 pptx 中。我的代码很简单。但是新的 pptx 文件中的样式被破坏了。任何人都可以帮忙吗?
<?php
require_once 'vendor/autoload.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Alignment;
function createPPT($template){
$pptLayout = new \PhpOffice\PhpPresentation\DocumentLayout();
$pptLayout->setDocumentLayout($pptLayout::LAYOUT_SCREEN_16X10);
$pptTMPL = \PhpOffice\PhpPresentation\IOFactory::createReader('PowerPoint2007');
//$ppt = $pptTMPL->load("./ppt-template.pptx");
$ppt = $pptTMPL->load("./$template");
$ppt->setLayout($pptLayout);
$oWriterPPTX = IOFactory::createWriter($ppt, 'PowerPoint2007');
$oWriterPPTX->save(__DIR__ . "/sample2.pptx");
}
createPPT("a.pptx", "PowerPoint2007");