How to use PHP & PowerPoint - Add/Insert Picture (AddPicture) The Learn / Tutorial / Sctipts php programming how to using PHP Create PowerPoint and Add/Insert Picture (AddPicture)
ShotDev Focus:
- PHP & Create PowerPoint and Add/Insert Picture (AddPicture)
Example
php_ppt_picture.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? //*** Constant ***// $ppLayoutTitleOnly = 11; //*** Font Color ***// $wdColorLightGreen = "&HCCFFCC"; $wdColorBlue = "&HFF0000"; $ppApp = new COM("PowerPoint.Application"); $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp $ppName = "MyPP/MyPPt.ppt"; $ppPres = $ppApp->Presentations->Add(); $ppSlide1 = $ppPres->Slides->Add(1,$ppLayoutTitleOnly); //*** AddTextbox, objControl.Left,objControl.Top,objControl.Width,objControl.Height ***// $ppSlide1->Shapes->AddTextbox(1,50,100,700,100); //***4 $ppSlide1->Shapes(1)->TextFrame->TextRange->Text = "I Love ShotDev.Com 1"; $ppSlide1->Shapes(1)->TextFrame->TextRange->Font->Name = "Arial"; $ppSlide1->Shapes(1)->TextFrame->TextRange->Font->Size = 10; $ppSlide1->Shapes(1)->TextFrame->TextRange->Font->Color = $wdColorLightGreen; $ppSlide1->Shapes->AddTextbox(1,50,150,700,100); $ppSlide1->Shapes(2)->TextFrame->TextRange->Text = "I Love ShotDev.Com 2"; $ppSlide1->Shapes(2)->TextFrame->TextRange->Font->Name = "Arial"; $ppSlide1->Shapes(2)->TextFrame->TextRange->Font->Size = 20; $ppSlide1->Shapes->AddTextbox(1,50,200,700,100); $ppSlide1->Shapes(3)->TextFrame->TextRange->Text = "I Love ShotDev.Com 3"; $ppSlide1->Shapes(3)->TextFrame->TextRange->Font->Name = "Arial"; $ppSlide1->Shapes(3)->TextFrame->TextRange->Font->Size = 30; $ppSlide1->Shapes->AddTextbox(1,50,250,700,100); $ppSlide1->Shapes(4)->TextFrame->TextRange->Text = "I Love ShotDev.Com 4"; $ppSlide1->Shapes(4)->TextFrame->TextRange->Font->Name = "Arial"; $ppSlide1->Shapes(4)->TextFrame->TextRange->Font->Size = 40; $ppSlide1->Shapes->AddTextbox(1,50,300,700,100); $ppSlide1->Shapes(5)->TextFrame->TextRange->Text = "I Love ShotDev.Com 5"; $ppSlide1->Shapes(5)->TextFrame->TextRange->Font->Name = "Arial"; $ppSlide1->Shapes(5)->TextFrame->TextRange->Font->Size = 50; $ppSlide1->Shapes(5)->TextFrame->TextRange->Font->Color = $wdColorBlue; $ppSlide1->Shapes->AddPicture(realpath("logo.gif"),0,1,250,330,200,100); //*** Picture,Left,Top,Width,Height ***// $ppApp->Presentations[1]->SaveAs($strPath."/".$ppName); //$ppApp->Presentations[1]->SaveAs(realpath($ppName)); $ppApp->Quit; $ppApp = null; ?> PowerPoint Created <a href="<?=$ppName?>">Click here</a> to Download. </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_ppt_picture.php
Screenshot