Code Monkey home page Code Monkey logo

pptx's Introduction

Cristal PPTX

Latest Stable Version GitHub issues GitHub license

Cristal PPTX is a PHP Library that allows you to manipulate slides from a Powerpoint PPTX file. Copy slides inside another pptx and templating it using mustache tags.

🚀 Installation using Composer

composer require cristal/pptx

👀 Quick view

<?php

use Cristal\Presentation\PPTX;

require 'vendor/autoload.php';

$basePPTX = new PPTX(__DIR__.'/source/base.pptx');
$endPPTX = new PPTX(__DIR__.'/source/endslide.pptx');

$basePPTX->addSlides($endPPTX->getSlides());

$basePPTX->template([
    'materiel' => [
        'libelle' => 'Bonjour'
    ]
]);

$basePPTX->saveAs(__DIR__.'/dist/presentation.pptx');

pptx's People

Contributors

ffouchier avatar tzk- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pptx's Issues

Call to a member function getStatusString() on int PPTX.php ligne 81

Fatal error:
Uncaught Error: Call to a member function getStatusString() on int in cristal/pptx/Presentation/PPTX.php:81 Stack trace: #0 cristal/pptx/Presentation/PPTX.php(67): Cristal\Presentation\PPTX->openFile()

My code :
$path = DIR.'/test.pptx';

$pptx = new Cristal\Presentation\PPTX($path);

$pptx->template([
'user' => [
'name' => 'Bill',
'age' => '26',
]
]);

$final_path = ws_get_temp_file(NULL, 'pptx');

$pptx->saveAs($final_path);

Layout information is lost for added slides

I open a pptx with a layout containing a background image using
$basePPTX = new PPTX($path1);
and save it
$basePPTX->saveAs($path2);

everything is fine.

I add the same pptx again:
$endPPTX = new PPTX($path1);
$basePPTX->addSlides($endPPTX->getSlides());

I get a message, if I want to repair the pptx, then I get a message, that certain slides cannot be displayed. for other slides no layout exists.

if I add different presentations I get the same messages, but only layouts are missing for the added slides.

do you have any idea?

Question : duplicated theme/slideMaster

Hello,

First of all, thank you for this library, I'm starting to play with it.

I have a question about the duplicated MasterSlides in the final presentation ;
I saw that when you merge slides, it copies the masters/themes in the final file. (I assumed it is safer to prevent broken presentation).
In case all the slides to be merged uses the same theme and master slides, would it be possible to use the existing ones and avoid duplicate them ?

Thank you !

How to remove slides

Hello,
I have the usecase that I want to remove a slide. Would this be possible and how?

$basePPTX->addSlides($endPPTX->getSlides()); simply not working

Describe the bug
Just tried the "Demo code" to merge 2 files and it doesn't work.

To Reproduce
My code is simple :

(some code before to set variable with file path)
$ppt_transition = $this->ppt_transition;
$basePPTX = new PPTX($ppt_transition);

$ppt_introduction = $this->ppt_introduction;
$endPPTX = new PPTX($ppt_introduction);

$basePPTX->addSlides($endPPTX->getSlides());

Expected behavior
Not throwing erros ...

Screenshots
Error is the following

Fatal error: Uncaught TypeError: Return value of Cristal\Presentation\Resource\XmlResource::getUniqueID() must be of the type integer, float returned in F:\Developpement\Page Oueb\abondonworship\classes\utils\ppt\Cristal\Presentation\Resource\XmlResource.php:229 Stack trace: #0 F:\Developpement\Page Oueb\abondonworship\classes\utils\ppt\Cristal\Presentation\Resource\Presentation.php(39): Cristal\Presentation\Resource\XmlResource::getUniqueID() #1 F:\Developpement\Page Oueb\abondonworship\classes\utils\ppt\Cristal\Presentation\PPTX.php(173): Cristal\Presentation\Resource\Presentation->addResource(Object(Cristal\Presentation\Resource\SlideMaster)) #2 F:\Developpement\Page Oueb\abondonworship\classes\utils\ppt\Cristal\Presentation\PPTX.php(125): Cristal\Presentation\PPTX->addResource(Object(Cristal\Presentation\Resource\Slide)) #3 F:\Developpement\Page Oueb\abondonworship\classes\utils\ppt\Cristal\Presentation\PPTX.php(212): Cristal\Presentation\PPTX->addSlide(Object(Cristal\Presentation\Resource\Slide)) #4 F:\Developpement\ in F:\Developpement\Page Oueb\abondonworship\classes\utils\ppt\Cristal\Presentation\Resource\XmlResource.php on line 229

Desktop (please complete the following information):

  • OS: [Windows]
  • PHP Version: [ PHP 7.1.3 x86]
  • Software used to open the final PPTX [Powerpoint]

Additional context
I can open "template" and save both files, but merging them trows an error that looks like a bug from your project

Table index regex bug

Describe the bug
When Slide.php in the table function is processing the index of the row of the table, it has a regex expression that has de digit part wrong, it should include the digits (pair) not one single digit, otherwise it will repeat the index above 10 and will repeat the data.

Actual code:

'/<([^>]+:?' . self::TABLE_ROW_TEMPLATE_NAME . '([\d])+\/>?)/'

Solution:

'/<([^>]+:?' . self::TABLE_ROW_TEMPLATE_NAME . '([\d]+)\/>?)/'

To Reproduce
Steps to reproduce the behavior:
Have an array with 10 or more elements to process into the table (with differents numeric index). Use table, boom, it will repeat those above 10.

[Documentation] - how to use table

Hi,

This library works very well for us. Thanks!

I saw table method in PPTX and it seems promising. I can't find anywhere how to use it. Can you provide some example?
Use case: duplicate rows in template and replace values in duplicated rows.

Thanks.

Defining the Slideposition where i add the Slides

Hello,

first of all thank you guys for this Libary, it its pretty much what we need in our project right now. I started playing around a little bit an managed to insert only certain slides:

use Cristal\Presentation\PPTX;

require 'vendor/autoload.php';

$basePPTX = new PPTX("mappenlager\Präsentation1.pptx");
$endPPTX = new PPTX("mappenlager\Präsentation2.pptx");

//Get the slides as an Array of Slides
$SlideArray = array();
$SlideArray = $endPPTX->getSlides();

//This adds only the first slide of the end pptx
$basePPTX->addSlide($SlideArray[0]);
//This adds only the second slide of the end pptx
$basePPTX->addSlide($SlideArray[1]);

So far so good, it works fast and fine ! Now my question: is there a possibility to tell the script where to insert those slides? For Example: Slide 1 in the endPPtx should be on Position 3 in the basePptx ? How would i approach this ?

Thank you very much
Fabian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.