shapes_drawing.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. .. _shapes_drawing:
  2. Drawing
  3. =======
  4. To create a drawing, you have four sources : File, GD, Base64 and ZipFile.
  5. File
  6. ----
  7. To create a drawing, use `createDrawingShape` method of slide.
  8. .. code-block:: php
  9. $oShape = $oSlide->createDrawingShape();
  10. $oShape->setName('Unique name')
  11. ->setDescription('Description of the drawing')
  12. ->setPath('/path/to/drawing.filename');
  13. It's an alias for :
  14. .. code-block:: php
  15. use PhpOffice\PhpPresentation\Shape\Drawing\File;
  16. $oShape = new File();
  17. $oShape->setName('Unique name')
  18. ->setDescription('Description of the drawing')
  19. ->setPath('/path/to/drawing.filename');
  20. $oSlide->addShape($oShape);
  21. GD
  22. --
  23. .. code-block:: php
  24. use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
  25. $gdImage = @imagecreatetruecolor($width, $height);
  26. $oShape = new Gd();
  27. $oShape->setName('Sample image')
  28. ->setDescription('Sample image')
  29. ->setImageResource($gdImage)
  30. ->setRenderingFunction(Drawing\Gd::RENDERING_JPEG)
  31. ->setMimeType(Drawing\Gd::MIMETYPE_DEFAULT);
  32. $oSlide->addShape($oShape);
  33. Base64
  34. ------
  35. .. code-block:: php
  36. use PhpOffice\PhpPresentation\Shape\Drawing\Base64;
  37. $oShape = new Base64();
  38. $oShape->setName('Sample image')
  39. ->setDescription('Sample image')
  40. ->setImageResource($gdImage)
  41. ->setData('data:image/jpeg;base64,..........');
  42. $oSlide->addShape($oShape);
  43. ZipFile
  44. -------
  45. .. code-block:: php
  46. use PhpOffice\PhpPresentation\Shape\Drawing\ZipFile;
  47. $oShape = new ZipFile();
  48. $oShape->setName('Sample image')
  49. ->setDescription('Sample image')
  50. ->setPath('zip://myzipfile.zip#path/in/zip/img.ext')
  51. $oSlide->addShape($oShape);