OpenTBS/PPTX 删除母版幻灯片和所有关联的幻灯片(从已删除的母版幻灯片生成)

问题描述 投票:0回答:1

如何删除母版幻灯片以及依赖于这些母版幻灯片的所有应删除的幻灯片?

如果删除不起作用,也许有解决方法? 例如

  • 隐藏具体...
  • 复制特定于新的 pptx 文件...

我尝试用这种方式删除母版幻灯片: 如果我从包含布局子文件 xml 数据的数组(参见下面我使用的函数)执行此操作,则 powerpoint 文件会损坏,并且在打开它时必须修复它。然后我看到删除的母版幻灯片已被一张空的(默认)幻灯片替换。

$files = $TBS->Plugin(OPENTBS_GET_FILES);

感谢您的任何想法

php powerpoint opentbs tinybutstrong
1个回答
0
投票

您可以使用

删除幻灯片

$TBS->插件(OPENTBS_DELETE_SLIDES, …);

您可以使用

隐藏(或显示)幻灯片

$TBS->插件(OPENTBS_DISPLAY_SLIDES, …);

OpenTBS 没有提供查找与特定主幻灯片相对应的幻灯片的功能,但以下代码为您提供 PPTX 中的幻灯片列表及其布局/主幻灯片信息:

// Establish the list of Layouts an their associated MasterSlides
$layout_lst = array();
$file_master_lst = $TBS->Plugin(OPENTBS_GET_FILES_BY_TYPE, 'slidem');
foreach ($file_master_lst as $file) {
    $name = basename($file); // name of the file
    $rel_file = dirname($file) . '/_rels/' . $name . '.rels'; // path of the corresponding rel file
    $TBS->PlugIn(OPENTBS_SELECT_FILE, $rel_file); // open a read the rel file
    $pattern = '|Target=\"\.\.\/slideLayouts\/([^"]*)|'; // layouts of the master slide
    preg_match_all($pattern, $TBS->Source, $matches);
    foreach ($matches[1] as $m) {
        $layout_lst[$m] = $name;
    }
}

// Establish the list of Slides an their associated MasterSlides and Layouts
$slide_lst  = array();
$file_slide_lst = $TBS->Plugin(OPENTBS_GET_FILES_BY_TYPE, 'slide');
foreach ($file_slide_lst as $file) {
    $name = basename($file); // name of the file
    $rel_file = dirname($file) . '/_rels/' . $name . '.rels'; // path of the corresponding rel file
    $TBS->PlugIn(OPENTBS_SELECT_FILE, $rel_file); // open a read the rel file
    $pattern = '|Target=\"\.\.\/slideLayouts\/([^"]*)|'; // layout of the slide
    preg_match_all($pattern, $TBS->Source, $matches);
    foreach ($matches[1] as $m) {
        $slide_lst[] = array(
            'file_path' =>   $file,
            'file_name' =>   $name,
            'layout' =>      $m,
            'masterSlide' => $layout_lst[$m],
        );
    }
}

var_export($slide_lst);
© www.soinside.com 2019 - 2024. All rights reserved.