定制 workdevelop/presentation-replacer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

workdevelop/presentation-replacer

最新稳定版本:v0.0.9

Composer 安装命令:

composer require workdevelop/presentation-replacer

包简介

This package replaces pre-defined variables in presentations with data

README 文档

README

Annotation

This package replaces pre-defined variables in presentations with data This package is suitable not only for vitalize presentation templates, but also for any other zip archives with files, contained pre-defined strings printing_args

Example

File example.pptx is template and has pre-defined variables at some src file
chart2_datatype1_0, chart2_datatype1_1, chart2_datatype1_2 like this

Preparation

$createPresentation = new \PresentationReplacer\CreatePresentation();
$templatePath = __DIR__.'/../storage/example.pptx';
$resultPath = __DIR__.'/../storage/result/result'.date('Ymd_His').'.pptx';
$createPresentation->setTemplatePath($templatePath);
$createPresentation->setResultPath($resultPath);
$createPresentation->setVariableRegex('/(\{char.*?\})/');

Get pre-defined variables at presentation

try {
    $allVariables = $createPresentation->getAllVariablesAtPresentation();
} catch (PresentationReplacer\PptException $exception) {
    //do something
}

To replace pre-defined variable real data and download

try {
    $createPresentation->replaceVariables([
        '{chart2_datatype1_0}' => 500,
        '{chart2_datatype1_1}' => 501
        '{chart2_datatype1_2}' => 100
    ]);
} catch (PresentationReplacer\PptException $exception) {
    //do something
}
$createPresentation->download('ready_presentation.pptx');

Get file content at presentation

try {
    $chartContent = $createPresentation->getFileContentByRelativePath('ppt/charts/chart1.xml');
} catch (\PresentationReplacer\PptException $exception) {
    //do something
}

Set file content at presentation

try {
    $createPresentation->setFileContentByRelativePath('ppt/charts/chart1.xml', $chartContent);
} catch (\PresentationReplacer\PptException $exception) {
    //do something
}

If you need replace file by Path, such as image
You know relative file pat which was replaced('ppt/media/image2.png')
And you have Absolute path to file where is new image located

$logoPath = __DIR__.'/../storage/image.png';
try {
    $createPresentation->setFileContentByRelativePath('ppt/media/image2.png', $logoPath);
} catch (\PresentationReplacer\PptException $exception) {
    //do something
}

How to prepare presentation template

coming soon

统计信息

  • 总下载量: 17.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-22