Download the PHP package workdevelop/presentation-replacer without Composer
On this page you can find all versions of the php package workdevelop/presentation-replacer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download workdevelop/presentation-replacer
More information about workdevelop/presentation-replacer
Files in workdevelop/presentation-replacer
Package presentation-replacer
Short Description This package replaces pre-defined variables in presentations with data
License MIT
Informations about the package presentation-replacer
PRESENTATION REPLACER
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
All versions of presentation-replacer with dependencies
ext-dom Version *
ext-simplexml Version *