0

I am using PHPPowerpoint which is manually installed (without composer). the lib works but not when using a template.

I tried this code:

$pptReader = PHPPowerPoint_IOFactory::createReader('PowerPoint2007');
$objPHPPowerPoint = $pptReader->load('temp.pptx');

but the browser shows:

Warning: require_once(PHPPowerPoint/Reader/PowerPoint2007.php): failed to open stream: No such file or directory in C:\xampp\htdocs\PHPPowerPoint-master\Classes\PHPPowerPoint\IOFactory.php on line 161
Fatal error: require_once(): Failed opening required 'PHPPowerPoint/Reader/PowerPoint2007.php' (include_path='C:\xampp\php\PEAR;../Classes/') in C:\xampp\htdocs\PHPPowerPoint-master\Classes\PHPPowerPoint\IOFactory.php on line 161

I also tried this:

$objPHPPowerPoint = PHPPowerPoint_IOFactory::load("temp.pptx");

And both of these as a required file and both works fine when not using a template:

require_once '../Classes/PHPPowerPoint/Autoloader.php';
PHPPowerPoint_Autoloader::register();

include '../Classes/PHPPowerPoint.php';

but it did not work when I tried to load a template.

I need to use a template (pptx file) for PHPPowerpoint. Please help. thanks.

  • It seems like a basic (autoload?) include problem, which has nothing to do with loading a template, but I could be mistaken. Do you still get the warning and error when you comment out the second line of code? – KIKO Software Apr 10 '19 at 07:53
  • thanks for your answer, but when I tried to use this code `$objPHPPowerPoint = new PHPPowerPoint();` the lib works fine, please help if you have any other solution, thanks – Rudy Catamora Apr 10 '19 at 08:00
  • That's nice, but not what I asked. My question was what happened if you only executed `$pptReader = PHPPowerPoint_IOFactory::createReader('PowerPoint2007');` from the first code segment in your question (in the same context as before, of course). My point is: You think the second line is the problem, whereas it could be the first line. – KIKO Software Apr 10 '19 at 08:11
  • I tried to comment out the second line and shows the same error. the error is on the first line `$pptReader = PHPPowerPoint_IOFactory::createReader('PowerPoint2007');`. Please help with any workaround. thanks @KIKOSoftware – Rudy Catamora Apr 10 '19 at 08:26
  • OK, that's what I expected. The problem is probably related to your manual install of PHPPowerpoint: It cannot find its files. Please read: [Installing/configuring](https://phppowerpoint.readthedocs.io/en/latest/installing.html) and make sure you include the code there. Note that you need to change the `path/to` twice! – KIKO Software Apr 10 '19 at 08:30
  • Thanks, I tried this `require_once '../Classes/PHPPowerPoint/Autoloader.php'; \PhpOffice\PhpPresentation\Autoloader::register();` but it shows an error: `Fatal error: Uncaught Error: Class 'PhpOffice\PhpPresentation\Autoloader' not found in C:\xampp\htdocs\PHPPowerPoint-master\Examples\myppt.php:37 Stack trace: #0 {main} thrown in C:\xampp\htdocs\PHPPowerPoint-master\Examples\myppt.php on line 37`, the original line that I removed is : `include '../Classes/PHPPowerPoint.php';` – Rudy Catamora Apr 10 '19 at 08:42
  • Please help, thanks – Rudy Catamora Apr 10 '19 at 08:43
  • So the file you run is located at `'C:\xampp\htdocs\PHPPowerPoint-master\Examples\myppt.php'`. And from there `'../Classes/PHPPowerPoint/Autoloader.php'` cannot be found. Instead try: `'../src/PhpPresentation/Autoloader.php'`. That's where I think it is probably located. However, you can see your own file structure, I cannot, so only you can really know the correct path. – KIKO Software Apr 10 '19 at 09:25
  • It found the autoloader.php and the phppowerpoint.php file, please consider that I already tried the lib without a template and it works fine. the problem is when loading a template. I tried this to find the autoloader: `require_once '../Classes/PHPPowerPoint/Autoloader.php'; PHPPowerPoint_Autoloader::register();` and it works when not using a template. help , thanks – Rudy Catamora Apr 10 '19 at 09:38

0 Answers0