addShape

addShape

BASIC / ADVANCED / PREMIUM

Inserts a shape into the PowerPoint presentation.

Description
public addShape($type, $position, $options = array())

This method inserts shapes into the PowerPoint presentation.

Parameters

type

Shape type:

  • accentBorderCallout1, accentBorderCallout2, accentBorderCallout3, accentCallout1, accentCallout2, accentCallout3, actionButtonBackPrevious, actionButtonBeginning, actionButtonBlank, actionButtonDocument, actionButtonEnd, actionButtonForwardNext, actionButtonHelp, actionButtonHome, actionButtonInformation, actionButtonMovie, actionButtonReturn, actionButtonSound, arc
  • bentArrow, bentConnector2, bentConnector3, bentConnector4, bentConnector5, bentUpArrow, bevel, blockArc, borderCallout1, borderCallout2, borderCallout3, bracePair, bracketPair
  • callout1, callout2, callout3, can, chartPlus, chartStar, chartX, chevron, chord, circularArrow, cloud, cloudCallout, corner, cornerTabs, cube, curvedConnector2, curvedConnector3, curvedConnector4, curvedConnector5, curvedDownArrow, curvedLeftArrow, curvedRightArrow, curvedUpArrow
  • decagon, diagStripe, diamond, dodecagon, donut, doubleWave, downArrow, downArrowCallout
  • ellipse, ellipseRibbon, ellipseRibbon2
  • flowChartAlternateProcess, flowChartCollate, flowChartConnector, flowChartDecision, flowChartDelay, flowChartDisplay, flowChartDocument, flowChartExtract, flowChartInputOutput, flowChartInternalStorage, flowChartMagneticDisk, flowChartMagneticDrum, flowChartMagneticTape, flowChartManualInput, flowChartManualOperation, flowChartMerge, flowChartMultidocument, flowChartOfflineStorage, flowChartOffpageConnector, flowChartOnlineStorage, flowChartOr, flowChartPredefinedProcess, flowChartPreparation, flowChartProcess, flowChartPunchedCard, flowChartPunchedTape, flowChartSort, flowChartSummingJunction, flowChartTerminator, folderCorner, frame, funnel
  • gear6, gear9
  • halfFrame, heart, heptagon, hexagon, homePlate, horizontalScroll
  • irregularSeal1, irregularSeal2
  • leftArrow, leftArrowCallout, leftBrace, leftBracket, leftCircularArrow, leftRightArrow, leftRightArrowCallout, leftRightCircularArrow, leftRightRibbon, leftRightUpArrow, leftUpArrow, lightningBolt, line, lineInv
  • mathDivide, mathEqual, mathMinus, mathMultiply, mathNotEqual, mathPlus, moon
  • nonIsoscelesTrapezoid, noSmoking, notchedRightArrow
  • octagon
  • parallelogram, pentagon, pie, pieWedge, plaque, plaqueTabs, plus
  • quadArrow, quadArrowCallout
  • rect, ribbon, ribbon2, rightArrow, rightArrowCallout, rightBrace, rightBracket, round1Rect, round2DiagRect, round2SameRect, roundRect, rtTriangle
  • smileyFace, snip1Rect, snip2DiagRect, snip2SameRect, snipRoundRect, squareTabs, star10, star12, star16, star24, star32, star4, star5, star6, star7, star8, straightConnector1, stripedRightArrow, sun, swooshArrow
  • teardrop, trapezoid, triangle
  • upArrow, upArrowCallout, upDownArrow, upDownArrowCallout, uturnArrow
  • verticalScroll
  • wave, wedgeEllipseCallout, wedgeRectCallout, wedgeRoundRectCallout

position

Key Type Description
coordinateX int EMUs (English Metric Unit).
coordinateY int EMUs (English Metric Unit).
sizeX int EMUs (English Metric Unit).
sizeY int EMUs (English Metric Unit).
name string Internal name. If not set, a random name is generated.
order int Set the display order. Default after existing contents. 0 is the first order position. If the order position doesn't exist add after existing contents.

options

Key Type Description
customGeom string Custom geometry.
fillColor string #FF0000, #00FFFF...
flipH bool Flip horizontally. Default as false
flipV bool Flip vertically. Default as false
imageContent mixed Image path, base64, stream or GdImage.
name string Set a name value.
outlineColor string #FF0000, #00FFFF...
rotation int 60.000ths of a degree.
shapeGuide array
  • 'fmla' (string) shape guide formula
  • 'guide' (string) shape guide name
tailEnd string
  • arrow
  • diamond
  • none
  • oval
  • stealth
  • triangle
textDirection string
  • horz
  • vert
  • vert270
  • wordArtVert
  • eaVert
  • mongolianVert
  • wordArtVertRtl
textContents PptxFragment Text contents as PptxFragment.
verticalAlign string
  • top
  • middle
  • bottom
Exceptions

Image doesn't exist.

Image format is not supported.

Position not valid.

Code samples

Example #1

The resulting PPTX looks like:

Release notes
  • phppptx 4.5:
    • rotation uses 60.000ths of a degree.
  • phppptx 4.0:
    • flipH, flipV, shapeGuide, textDirection and verticalAlign options.
    • extra check to avoid duplicated shape internal ids.
    • removed PHP Warnings when images to be added do not exist.
  • phppptx 3.0:
    • GdImage as image source.
  • phppptx 2.5:
    • new method.