Adding an image to a slide gives me a blank image object

Jul 9, 2013 at 4:00 PM
I must be doing something wrong, but when I try to add an image to a slide then i down load and open the ppt i get a blank image shape in the slide.

I am running the latest version of phppowerpoint from trunk.

and here is the code I am using to create my slide with image:

//creating next slide
$currentSlide = $powerpoint->getActiveSlide();
$slide = $powerpoint->createSlide();
$shape = $slide->createRichTextShape();
$shape->setHeight(200);
$shape->setWidth(900);
$shape->setOffsetX(30);
$shape->setOffsetY(50);
$shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER );
$textRun = $shape->createTextRun("Numbers of Cases and proportion (%) of Any FASD in " . $_SESSION["NUMBIRTHS"] . " Women from ". $_SESSION["LOCATION"] . " in " . $_SESSION["DATE"] . ".");
$textRun->getFont()->setBold(true);
$textRun->getFont()->setSize(30);
$textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( '555555' ) );

//adding an image to the slide
$shape2 = $slide->createDrawingShape();
$shape2->setName('Alcohol Exposure');
$shape2->setDescription('Pie Chart');
$shape2->setPath('./pictures/51dab21966436.jpg');
$shape2->setHeight(170);
$shape2->setOffsetX(100);
$shape2->setOffsetY(100);

If any one can tell me where I am going off the path or give me some pointers I would be grateful.

-Joel
Oct 10, 2013 at 7:22 AM
Solution :

For a single slide, we have to follow certain rules..

All the images should be added first, ( that is any text can be added to slide only once all images adding codes are completed.

Means

In your code..

//adding an image to the slide
$shape2 = $slide->createDrawingShape();
$shape2->setName('Alcohol Exposure');
$shape2->setDescription('Pie Chart');
$shape2->setPath('./pictures/51dab21966436.jpg');
$shape2->setHeight(170);
$shape2->setOffsetX(100);
$shape2->setOffsetY(100);

should come first
then only

$shape = $slide->createRichTextShape();
$shape->setHeight(200);
$shape->setWidth(900);
$shape->setOffsetX(30);
$shape->setOffsetY(50);
$shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER );
$textRun = $shape->createTextRun("Numbers of Cases and proportion (%) of Any FASD in " . $_SESSION["NUMBIRTHS"] . " Women from ". $_SESSION["LOCATION"] . " in " . $_SESSION["DATE"] . ".");
$textRun->getFont()->setBold(true);
$textRun->getFont()->setSize(30);
$textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( '555555' ) );



Order of codes does matter with PHP powerpoint. :)

Hope it helps