Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPTX 2016 needs repairing when adding image #302

Closed
jvanoostrom opened this issue Dec 21, 2016 · 5 comments
Closed

PPTX 2016 needs repairing when adding image #302

jvanoostrom opened this issue Dec 21, 2016 · 5 comments
Milestone

Comments

@jvanoostrom
Copy link
Contributor

jvanoostrom commented Dec 21, 2016

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:

<?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");

?>
@Progi1984
Copy link
Member

@jvanoostrom Could you test this PR #303 ? Please and thanks for advance

@jvanoostrom
Copy link
Contributor Author

Will do this afternoon or tomorrow morning, thanks!

@Progi1984
Copy link
Member

@jvanoostrom You rocks 😄 ! I tested with all samples on PowerPoint 2007, but real issuer is better.

@jvanoostrom
Copy link
Contributor Author

Hi there,

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).

Thanks for the fix!

@Progi1984
Copy link
Member

@jvanoostrom The PR #303 has been merged in develop branch. Thanks.

@Progi1984 Progi1984 added this to the 0.8.0 milestone Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants