Sample_09_SlideNote.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. include_once 'Sample_Header.php';
  3. use PhpOffice\PhpPresentation\PhpPresentation;
  4. use PhpOffice\PhpPresentation\Style\Alignment;
  5. use PhpOffice\PhpPresentation\Style\Color;
  6. use PhpOffice\PhpPresentation\Style\Fill;
  7. use PhpOffice\PhpPresentation\Style\Border;
  8. // Create new PHPPresentation object
  9. echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
  10. $objPHPPresentation = new PhpPresentation();
  11. $oLayout = $objPHPPresentation->getLayout();
  12. // Set properties
  13. echo date('H:i:s') . ' Set properties' . EOL;
  14. $objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 01 Title')->setSubject('Sample 01 Subject')->setDescription('Sample 01 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
  15. // Create slide
  16. echo date('H:i:s') . ' Create slide' . EOL;
  17. $currentSlide = $objPHPPresentation->getActiveSlide();
  18. // Create a shape (drawing)
  19. echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
  20. $shape = $currentSlide->createDrawingShape();
  21. $shape->setName('PHPPresentation logo')
  22. ->setDescription('PHPPresentation logo')
  23. ->setPath('./resources/phppowerpoint_logo.gif')
  24. ->setHeight(36)
  25. ->setOffsetX(10)
  26. ->setOffsetY(10);
  27. $shape->getShadow()->setVisible(true)
  28. ->setDirection(45)
  29. ->setDistance(10);
  30. $shape->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')->setTooltip('PHPPresentation');
  31. // Create a shape (text)
  32. echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
  33. $shape = $currentSlide->createRichTextShape()
  34. ->setHeight(300)
  35. ->setWidth(600)
  36. ->setOffsetX(170)
  37. ->setOffsetY(180);
  38. $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
  39. $textRun = $shape->createTextRun('Thank you for using PHPPresentation!');
  40. $textRun->getFont()->setBold(true)
  41. ->setSize(60)
  42. ->setColor(new Color('FFE06B20'));
  43. // Set Note
  44. echo date('H:i:s') . ' Set Note' . EOL;
  45. $oNote = $currentSlide->getNote();
  46. $oRichText = $oNote->createRichTextShape()
  47. ->setHeight($oLayout->getCY($oLayout::UNIT_PIXEL))
  48. ->setWidth($oLayout->getCX($oLayout::UNIT_PIXEL))
  49. ->setOffsetX(170)
  50. ->setOffsetY(180);
  51. $oRichText->createTextRun('A class library');
  52. $oRichText->createParagraph()->createTextRun('Written in PHP');
  53. $oRichText->createParagraph()->createTextRun('Representing a presentation');
  54. $oRichText->createParagraph()->createTextRun('Supports writing to different file formats');
  55. // Save file
  56. echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
  57. if (!CLI) {
  58. include_once 'Sample_Footer.php';
  59. }