You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding an image, the PPTX needs repairing. When there is no image added, the PPTX works just fine. I am using PowerPoint 2016.
Please find the used code below. I have added a piece of text, to illustrate that, when the image part is commented, no errors occur.
Please note that whenever there is only one image present, it also gives an error saying "image not found". If the image code is duplicated in the code (no changes), the image DOES work, while the former still shows an error.
Any ideas?
Thanks!
The (simple) code:
<?php
// Include all necessary PHPPresentation files
require_once 'PHPPresentation/src/PhpPresentation/Autoloader.php';
\PhpOffice\PhpPresentation\Autoloader::register();
require_once 'PHPOffice/src/Common/Autoloader.php';
\PhpOffice\Common\Autoloader::register();
use PhpOffice\PhpPresentation\DocumentLayout;
use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Shape\Drawing;
use PhpOffice\PhpPresentation\Slide\Background\Image as BackgroundImage;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Fill;
// Start PPT
$objPHPPresentation = new PhpPresentation();
// Add Slide
$oSlide1 = $objPHPPresentation->getActiveSlide();
$oNameText = $oSlide1->createRichTextShape()
->setHeight(35)
->setWidth(535)
->setOffsetX(450)
->setOffsetY(110);
$oNameText->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_LEFT );
$oNameTextRun = $oNameText->createTextRun('MyText');
$oNameTextRun->getFont()
->setSize(16);
// Add another slide
$oSlide2 = $objPHPPresentation->createSlide();
// Image causes problems
$oImage = new Drawing\File();
$oImage->setPath('./image.png')
->setHeight(50)
->setWidth(50)
->setOffsetX(500)
->setOffsetY(300);
$oSlide2->addShape($oImage);
$oWriterPPTX = IOFactory::createWriter($objPHPPresentation, 'PowerPoint2007');
$oWriterPPTX->save(__DIR__ . "example.pptx");
$oWriterODP = IOFactory::createWriter($objPHPPresentation, 'ODPresentation');
$oWriterODP->save(__DIR__ . "example.odp");
?>
The text was updated successfully, but these errors were encountered:
I've reviewed the changes using my own written scripts. The "repair" error is gone in PPT2016. Furthermore, the "first" image on the slide now properly works (no "image cannot be displayed" error).
Hi,
When adding an image, the PPTX needs repairing. When there is no image added, the PPTX works just fine. I am using PowerPoint 2016.
Please find the used code below. I have added a piece of text, to illustrate that, when the image part is commented, no errors occur.
Please note that whenever there is only one image present, it also gives an error saying "image not found". If the image code is duplicated in the code (no changes), the image DOES work, while the former still shows an error.
Any ideas?
Thanks!
The (simple) code:
The text was updated successfully, but these errors were encountered: