Learning & Integrating web technology and code help directory

How to use PHP & PowerPoint - Add/Insert Picture (AddPicture)

No comments
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
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7.   
  8. //*** Constant ***//  
  9. $ppLayoutTitleOnly = 11;  
  10.   
  11. //*** Font Color ***//  
  12. $wdColorLightGreen  = "&HCCFFCC";  
  13. $wdColorBlue = "&HFF0000";  
  14.   
  15. $ppApp = new COM("PowerPoint.Application");  
  16.   
  17. $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp  
  18. $ppName = "MyPP/MyPPt.ppt";  
  19.   
  20. $ppPres = $ppApp->Presentations->Add();  
  21.   
  22. $ppSlide1 = $ppPres->Slides->Add(1,$ppLayoutTitleOnly);  
  23. //*** AddTextbox, objControl.Left,objControl.Top,objControl.Width,objControl.Height ***//  
  24. $ppSlide1->Shapes->AddTextbox(1,50,100,700,100);  //***4  
  25. $ppSlide1->Shapes(1)->TextFrame->TextRange->Text = "I Love ShotDev.Com 1";  
  26. $ppSlide1->Shapes(1)->TextFrame->TextRange->Font->Name = "Arial";  
  27. $ppSlide1->Shapes(1)->TextFrame->TextRange->Font->Size = 10;  
  28. $ppSlide1->Shapes(1)->TextFrame->TextRange->Font->Color  = $wdColorLightGreen;  
  29.   
  30. $ppSlide1->Shapes->AddTextbox(1,50,150,700,100);  
  31. $ppSlide1->Shapes(2)->TextFrame->TextRange->Text = "I Love ShotDev.Com 2";  
  32. $ppSlide1->Shapes(2)->TextFrame->TextRange->Font->Name = "Arial";  
  33. $ppSlide1->Shapes(2)->TextFrame->TextRange->Font->Size = 20;  
  34.   
  35. $ppSlide1->Shapes->AddTextbox(1,50,200,700,100);  
  36. $ppSlide1->Shapes(3)->TextFrame->TextRange->Text = "I Love ShotDev.Com 3";  
  37. $ppSlide1->Shapes(3)->TextFrame->TextRange->Font->Name = "Arial";  
  38. $ppSlide1->Shapes(3)->TextFrame->TextRange->Font->Size = 30;  
  39.   
  40. $ppSlide1->Shapes->AddTextbox(1,50,250,700,100);  
  41. $ppSlide1->Shapes(4)->TextFrame->TextRange->Text = "I Love ShotDev.Com 4";  
  42. $ppSlide1->Shapes(4)->TextFrame->TextRange->Font->Name = "Arial";  
  43. $ppSlide1->Shapes(4)->TextFrame->TextRange->Font->Size = 40;  
  44.   
  45. $ppSlide1->Shapes->AddTextbox(1,50,300,700,100);  
  46. $ppSlide1->Shapes(5)->TextFrame->TextRange->Text = "I Love ShotDev.Com 5";  
  47. $ppSlide1->Shapes(5)->TextFrame->TextRange->Font->Name = "Arial";  
  48. $ppSlide1->Shapes(5)->TextFrame->TextRange->Font->Size = 50;  
  49. $ppSlide1->Shapes(5)->TextFrame->TextRange->Font->Color  = $wdColorBlue;  
  50.   
  51. $ppSlide1->Shapes->AddPicture(realpath("logo.gif"),0,1,250,330,200,100);   //*** Picture,Left,Top,Width,Height ***//  
  52.   
  53. $ppApp->Presentations[1]->SaveAs($strPath."/".$ppName);  
  54. //$ppApp->Presentations[1]->SaveAs(realpath($ppName));  
  55.   
  56. $ppApp->Quit;  
  57. $ppApp = null;  
  58. ?>  
  59. PowerPoint Created <a href="<?=$ppName?>">Click here</a> to Download.  
  60. </body>  
  61. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & PowerPoint - Create PowerPoint and Add/Insert Picture (AddPicture)
.

No comments :

Post a Comment