Sample_17_Comment.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. include_once 'Sample_Header.php';
  3. use PhpOffice\PhpPresentation\PhpPresentation;
  4. use PhpOffice\PhpPresentation\Slide\Background\Color;
  5. use PhpOffice\PhpPresentation\Style\Color as StyleColor;
  6. use \PhpOffice\PhpPresentation\Slide\Background\Image;
  7. // Create new PHPPresentation object
  8. echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
  9. $objPHPPresentation = new PhpPresentation();
  10. // Create slide
  11. echo date('H:i:s') . ' Create slide'.EOL;
  12. $oSlide1 = $objPHPPresentation->getActiveSlide();
  13. $oSlide1->addShape(clone $oShapeDrawing);
  14. $oSlide1->addShape(clone $oShapeRichText);
  15. $oAuthor = new \PhpOffice\PhpPresentation\Shape\Comment\Author();
  16. $oAuthor->setName('Progi1984');
  17. $oAuthor->setInitials('P');
  18. // Add Comment 1
  19. echo date('H:i:s') . ' Add Comment 1'.EOL;
  20. $oComment1 = new \PhpOffice\PhpPresentation\Shape\Comment();
  21. $oComment1->setText('Text A');
  22. $oComment1->setOffsetX(10);
  23. $oComment1->setOffsetY(55);
  24. $oComment1->setDate(time());
  25. $oComment1->setAuthor($oAuthor);
  26. $oSlide1->addShape($oComment1);
  27. // Add Comment
  28. echo date('H:i:s') . ' Add Comment 2'.EOL;
  29. $oComment2 = new \PhpOffice\PhpPresentation\Shape\Comment();
  30. $oComment2->setText('Text B');
  31. $oComment2->setOffsetX(170);
  32. $oComment2->setOffsetY(180);
  33. $oComment2->setDate(time());
  34. $oComment2->setAuthor($oAuthor);
  35. $oSlide1->addShape($oComment2);
  36. // Save file
  37. echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
  38. if (!CLI) {
  39. include_once 'Sample_Footer.php';
  40. }