-
Notifications
You must be signed in to change notification settings - Fork 533
Description
I'm trying to describe two bugs here.
-
I generated test.pptx file using writer with background.jpg and logo.png (logo file is transparent). I can open this file in Powerpoint 2007 without any problem.
-
Read this test.pptx and write to test_copy.pptx, Powerpoint 2007 can't open it with the error message:
PowerPoint found unreadable content in test_copy.pptx.
This file may have become corrupt or damaged for the following reasons:
Third-party XML editors sometimes create files that are not compatible with Microsoft Office XML specifications.
The file has been purposely corrupted with the intent to harm your computer or your data.
Be cautious when opening a file from an unknown source.
PowerPoint can attempt to recover data from the file, but some presentation data, such as shapes, text,and formatting, may be lost.
After lick fix, it opens, but the logo became opaque.
My code is below:
public function test()
{
$objPHPPowerPoint = new PhpPresentation();
// Set 16:9 layout
// --------------------------------------------------------------------------------
$pptLayout = new \PhpOffice\PhpPresentation\DocumentLayout();
$pptLayout->setDocumentLayout($pptLayout::LAYOUT_SCREEN_16X9);
$objPHPPowerPoint->setLayout($pptLayout);
// Create a master layout
$oMasterSlide = $objPHPPowerPoint->getAllMasterSlides()[0];
$shape = $oMasterSlide->createDrawingShape();
$shape->setPath(public_path() . "/logo.png")
->setHeight(50)
->setOffsetX(60)
->setOffsetY(475);
// Background Img
// --------------------------------------------------------------------------------
$oBkgImageSlide = new Image();
$oBkgImageSlide->setPath(public_path() . "/background.jpg");
$oMasterSlide->setBackground($oBkgImageSlide);
// Write PPTX
// --------------------------------------------------------------------------------
$oWriterPPTX = IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
$oWriterPPTX->save(public_path() . "/" . "test.pptx");
// read the pptx and make a copy
$pptReader = IOFactory::createReader('PowerPoint2007');
$oPHPPresentation = $pptReader->load(public_path() . "/" . "test.pptx");
$oWriterPPTX = IOFactory::createWriter($oPHPPresentation, 'PowerPoint2007');
$oWriterPPTX->save(public_path() . "/" . "test_copy.pptx");
}
I'm also uploading all files I'm using.
test.pptx
test_copy.pptx