如何使用PHPPowerPoint将图像添加到幻灯片?

时间:2012-12-19 18:49:41

标签: php phppowerpoint

PHPPowerPoint是一个很棒的图书馆,但它没有文档。将图像添加到幻灯片的正确语法是什么?

2 个答案:

答案 0 :(得分:2)

每个图形对象都被视为“形状”。这是将图像插入幻灯片的方法:

// Create slide 1
$currentSlide = createTemplatedSlide($objPHPPowerPoint); 
        //Slide Content
    $shape = $currentSlide->createDrawingShape();
    $shape->setName('Part page');
    $shape->setDescription('Page');
    $shape->setPath('D:\wamp\www\Project\PPTResource\Part2\Image.jpg'); //This being the directory, wont be the same as mine.
    $shape->setOffsetX(10); //Default values on position of image
    $shape->setOffsetY(10);
    $shape->getShadow()->setVisible(true);
    $shape->getShadow()->setDirection(45);
    $shape->getShadow()->setDistance(10);

答案 1 :(得分:2)

$currentSlide = createTemplatedSlide($objPHPPowerPoint); 
// createTemplatedSlide is manual function in PHPpowerPoint

// create a drawing shape object
$shape1 = $currentSlide->createDrawingShape();
$shape1->setName("set name here");
$shape1->setDescription('Link Image');
$shape1->setPath('provide image path here');
$shape1->setWidth(45); // set width
$shape1->setHeight(45); // set height
$shape1->setOffsetX($offset_X); // distance from the left side of the slide
$shape1->setOffsetY($offset_Y); // distance from top of the slide