PHPPresentation is a library written in pure PHP that provides a set of classes to write to different presentation file formats, i.e. Microsoft Office Open XML (.pptx) and OASIS Open Document Format for Office Applications (.odp).
PHPPresentation is an open source project licensed under the terms of LGPL version 3. PHPPresentation is aimed to be a high quality software product by incorporating continuous integration and unit testing. You can learn more about PHPPresentation by reading this Developers' Documentation.
Below are the supported features for each file formats.
"},{"location":"index.html#writers","title":"Writers","text":"Features HTML ODP PDF PPTX Document Mark as final Document Properties Standard Custom Slides Name Element Shape AutoShape Image Hyperlink Line MemoryImage RichText Table Text Charts Area Bar Bar3D Doughnut Line Pie Pie3D Radar Scatter"},{"location":"index.html#readers","title":"Readers","text":"Features ODP PPT PPTX Document Mark as final Document Properties Standard Custom Slides Name Element Shape AutoShape Image Hyperlink RichText Table Text Charts Area Bar Bar3D Doughnut Line Pie Pie3D Radar Scatter"},{"location":"index.html#contributing","title":"Contributing","text":"
We welcome everyone to contribute to PHPPresentation. Below are some of the things that you can do to contribute:
"},{"location":"faq.html","title":"Frequently asked questions","text":""},{"location":"faq.html#is-this-the-same-with-phppowerpoint-that-i-found-in-codeplex","title":"Is this the same with PHPPowerPoint that I found in CodePlex?","text":"
No. This one is much better with tons of new features that you can\u2019t find in PHPPowerPoint 0.1. The development in CodePlex is halted and switched to GitHub to allow more participation from the crowd. The more the merrier, right?
"},{"location":"faq.html#ive-been-running-phppowerpoint-from-codeplex-flawlessly-but-i-cant-use-the-latest-phppresentation-from-github-why","title":"I\u2019ve been running PHPPowerPoint from CodePlex flawlessly, but I can\u2019t use the latest PHPPresentation from GitHub. Why?","text":"
PHPPresentation requires PHP 5.3+ since v0.2, while PHPPowerPoint v0.1 from CodePlex can run with PHP 5.2.
There\u2019s a lot of new features that we can get from PHP 5.3 and it\u2019s been around since 2009! You should upgrade your PHP version to use PHPPresentation v0.2+.
"},{"location":"faq.html#why-am-i-getting-a-class-not-found-error","title":"Why am I getting a class not found error?","text":"
If you have followed the instructions for either adding this package to your composer.json or registering the autoloader, then perhaps you forgot to include a use statement for the class(es) you are trying to access.
Here's an example that allows you to refer to the MemoryDrawing class without having to specify the full class name in your code:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\MemoryDrawing as MemoryDrawing;\n
If you have followed the installation instructions and you have added the necessary use statements to your code, then maybe you are still referencing the PHPPowerPoint classes using the old PEAR/PSR-0 approach.
The 0.1 approach to naming classes used verbose class names to avoid namespace collisions with other libraries. For example, the MemoryDrawing class was actually called PHPPowerPoint_Shape_MemoryDrawing.
Version 0.2 of the library renamed the classes, moved to a namespaced approach and switched to the PSR-0 autoloader. Interestingly, old code that was still referencing classes using the verbose approach still worked (which was pretty cool!). This is because the PSR-0 autoloader was correctly translating the verbose class references into the correct file name and location. However, PHPPowerPoint now relies exclusively on the PSR-4 autoloader, so old code that may have been referencing the classes with the verbose class names will need to be updated accordingly.
"},{"location":"faq.html#why-phppowerpoint-become-phppresentation","title":"Why PHPPowerPoint become PHPPresentation ?","text":"
As Roman Syroeshko noticed us, PowerPoint is a trademark. For avoiding any problems with Microsoft, we decide to change the name to a more logic name, with our panel of readers/writers.
After installation, you can browse and use the samples that we've provided, either by command line or using browser. If you can access your PHPPresentation library folder using browser, point your browser to the samples folder, e.g. http://localhost/PhpPresentation/samples/.
PhpOffice\\PhpPresentation\\Writer\\ODPresentation : Move to Design Pattern Decorator - @Progi1984
PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007 : Move to Design Pattern Decorator - @Progi1984
PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\getData has been deprecated for PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\getSeries - @Progi1984 GH-169
PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\setData has been deprecated for PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\setSeries - @Progi1984 GH-169
Added documentation for chart series (font, outline, marker) - @Progi1984 GH-169
Internal Structure for Drawing Shape - @Progi1984 GH-192
Documentation about manual installation - @danielbair GH-254
PowerPoint2007 Writer : Write percentage values with a trailing percent sign instead of formatted as 1000th of a percent to comply with the standard - @k42b3 GH-307
You can add custom properties with the method setCustomProperty.
Multiple types are available: * DocumentProperties::PROPERTY_TYPE_STRING for string value, * DocumentProperties::PROPERTY_TYPE_BOOLEAN for boolean value, * DocumentProperties::PROPERTY_TYPE_FLOAT for float value, * DocumentProperties::PROPERTY_TYPE_INTEGER for integer value, * DocumentProperties::PROPERTY_TYPE_DATE for date value, * DocumentProperties::PROPERTY_TYPE_UNKNOWN for unknown type value.
<?php\n\nuse PhpOffice\\PhpPresentation\\DocumentProperties;\n\n$properties = $presentation->getProperties();\n\n// Set the custom property\n$properties->setCustomProperty('propertyName', 'propertyValue', DocumentProperties::PROPERTY_TYPE_STRING);\n\n// Check if a custom property exists\n$properties->isCustomPropertySet('unknown'); // return `false`\n$properties->isCustomPropertySet('propertyName'); // return `true`\n\n// Return all custom properties\n$properties->getCustomProperties(); // return `['propertyName']`\n\n// Return value from a custom property\n$properties->getCustomPropertyValue('unknown'); // return `null` if not set\n$properties->getCustomPropertyValue('propertyName'); // return `propertyValue`\n\n// Return type from a custom property\n$properties->getCustomPropertyType('unknown'); // return `null` if not set\n$properties->getCustomPropertyType('propertyName'); // return `DocumentProperties::PROPERTY_TYPE_STRING`\n
You can define if the presentation display or not the comments with the method setCommentVisible.
<?php\n\n$presentation = new PhpPresentation();\n$properties = $presentation->getPresentationProperties();\n// Get the display for comment\nvar_export($properties->isCommentVisible());\n// Output : false\n// Enable the display for comment\n$properties->setCommentVisible(true);\n// Get the display for comment\nvar_export($properties->isCommentVisible());\n// Output : true\n
You can define the last view of the presentation with the method setLastView.
<?php\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Get the last view of the presentation\necho $properties->getZoom();\n// Output : PresentationProperties::VIEW_SLIDE\n// Set the last view of the presentation\n$properties->setLastView(PresentationProperties::VIEW_NOTES);\n// Get the last view of the presentation\necho $properties->getZoom();\n// Output : PresentationProperties::VIEW_NOTES\n
"},{"location":"usage/presentation.html#mark-as-final","title":"Mark as final","text":"
You must define your presentation as final with the method markAsFinal()
You can define the type of slideshow you can with the method setSlideshowType.
Differents types are available:
PresentationProperties::SLIDESHOW_TYPE_PRESENT for Presented by a speaker
PresentationProperties::SLIDESHOW_TYPE_BROWSE for Browsed by an individual
PresentationProperties::SLIDESHOW_TYPE_KIOSK for Browsed at a kiosk
<?php\n\nuse PhpOffice\\PhpPresentation\\PresentationProperties;\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Set type of slideshow\n$properties->setSlideshowType(PresentationProperties::SLIDESHOW_TYPE_PRESENT);\n// Get type of slideshow\necho $properties->getSlideshowType();\n
You can define the thumbnail of the presentation with the method setThumbnailPath.
<?php\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Set path of the thumbnail\n$properties->setThumbnailPath(__DIR__.'\\resources\\phppowerpoint_logo.gif');\n// Get path of the thumbnail\necho $properties->getThumbnailPath();\n
You can define the zoom of the presentation with the method setZoom.
<?php\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Get zoom of the presentation\necho $properties->getZoom();\n// Output : 1\n// Set zoom of the presentation (3 = 300%)\n$properties->setZoom(3);\n// Get zoom of the presentation\necho $properties->getZoom();\n// Output : 3\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Alignment;\n\n$alignment = new Alignment();\n\n// Set alignment to RTL\n$alignment->setIsRTL(true);\n// Set alignment to LTR\n$alignment->setIsRTL(false);\n// Is the alignment RTL?\necho $alignment->isRTL();\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Font;\n\n$font = new Font();\n\n// Set capitalization of font\n$font->setCapitalization(Font::CAPITALIZATION_ALL);\n// Get capitalization of font\necho $font->getCapitalization();\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Font;\n\n$font = new Font();\n\n// Set format of font\n$font->setFormat(Font::FORMAT_EAST_ASIAN);\n// Get format of font\necho $font->getFormat();\n
You can define text of the geometric form with setText method.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\AutoShape;\n\n$shape = new AutoShape();\n// Define the text\n$shape->setText('ABC');\n// Return the text\n$shape->getText();\n
"},{"location":"usage/shapes/chart.html#customization","title":"Customization","text":""},{"location":"usage/shapes/chart.html#manage-how-blank-values-are-displayed","title":"Manage how blank values are displayed","text":"
You can define how blank values are displayed with the method setDisplayBlankAs.
Differents types are available:
Chart::BLANKAS_GAP for Leave a gap
Chart::BLANKAS_ZERO for Assume zero (default)
Chart::BLANKAS_SPAN for Continue line
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart;\n\n// Set the behavior\n$chart->setDisplayBlankAs(Chart::BLANKAS_GAP);\n// Get the behavior\necho $chart->getDisplayBlankAs();\n
You can define title for each axis (X & Y) with setTitle method. You can apply a rotation with the setTitleRotation method with an expected paremeter in degrees.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Gridlines;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n\n$shape->getPlotArea()->getAxisX()->setTitle('Axis X');\n$shape->getPlotArea()->getAxisX()->setTitleRotation(45);\n
You can define gridlines (minor and major) for each axis (X & Y). For each gridline, you can custom the width (in points), the fill type and the fill color.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Gridlines;\n\n$line = new Line();\n\n$gridlines = new Gridlines();\n$gridlines->getOutline()->setWidth(10);\n$gridlines->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisX()->setMajorGridlines($gridlines);\n
For Axis, you can define the min & max bounds with setMinBounds & setMaxBounds methods. For resetting them, you pass null as parameter to these methods.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Gridlines;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisX()->setMinBounds(0);\n$shape->getPlotArea()->getAxisX()->setMaxBounds(200);\n
For Axis, setCrossesAt can be used to define where it should be crossed by the perpendicular/ horizontal axis. The property can be defined by one of the three given constants or as an absolute value on the target axis.
use PhpOffice\\PhpPresentation\\Shape\\Axis;\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar;\n\n$bar = new Bar();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($bar);\n\n// Usage of constant: Horizontal axis will cross the Y-Axis at `0`\n$shape->getPlotArea()->getAxisY()->setCrossesAt(Axis::CROSSES_AUTO);\n\n// Usage of individual value: Horizontal axis will cross the Y-Axis at `3`\n$shape->getPlotArea()->getAxisY()->setCrossesAt('3');\n
Constant Description AXIS::CROSSES_AUTO Axis crosses at zero. AXIS::CROSSES_MIN Axis crosses at minimum. AXIS::CROSSES_MAX Axis crosses at maximum."},{"location":"usage/shapes/chart.html#reversed-order","title":"Reversed Order","text":"
You can reverse the order of a categorial or value axis trought setIsReversedOrder.
Notice: If you reverse the order of a axis, this automatically changes the position of the other axis. To reset this effect, the axis intersection point on the other axis must be set to Axis::CROSSES_MAX using setCrossesAt.
use PhpOffice\\PhpPresentation\\Shape\\Axis;\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar;\n\n$bar = new Bar();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($bar);\n\n// default value, will return false\n$shape->getPlotArea()->getAxisY()->isReversedOrder()\n\n// reverse order\n$shape->getPlotArea()->getAxisY()->setIsReversedOrder(true);\n\n// revert the automatic intersection switch on x axis\n$shape->getPlotArea()->getAxisX()->setCrossesAt(Axis::CROSSES_MAX);\n
You can define the tick label position with the setTickLabelPosition method. For resetting it, you pass Axis::TICK_LABEL_POSITION_NEXT_TO as parameter to this method.
Differents types are available:
Axis::TICK_LABEL_POSITION_HIGH: Labels are at the high end of the perpendicular axis
Axis::TICK_LABEL_POSITION_LOW: Labels are at the low end of the perpendicular axis
Axis::TICK_LABEL_POSITION_NEXT_TO: Labels are next to the axis (default)
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisY()->setTickLabelPosition(Axis::TICK_LABEL_POSITION_LOW);\n
For Axis Y, you can define tick mark with setMinorTickMark & setMajorTickMark methods. For resetting them, you pass Axis::TICK_MARK_NONE as parameter to these methods.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisY()->setMinorTickMark(Axis::TICK_MARK_NONE);\n$shape->getPlotArea()->getAxisY()->setMajorTickMark(Axis::TICK_MARK_INSIDE);\n
By default, the title of a chart is displayed. For hiding it, you define its visibility to false.
<?php\n\n$line = new Line();\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n// Hide the title\n$shape->getTitle()->setVisible(false);\n
You can define if some informations are displayed.
<?php\n\n$series = new Series('Downloads', $seriesData);\n$series->setSeparator(';');\n$series->setShowCategoryName(true);\n$series->setShowLeaderLines(true);\n$series->setShowLegendKey(true);\n$series->setShowPercentage(true);\n$series->setShowSeriesName(true);\n$series->setShowValue(true);\n
You can custom the line of a serie, for Line & Scatter charts.
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Outline;\n\n$outline = new Outline();\n// Define the color\n$outline->getFill()->setFillType(Fill::FILL_SOLID);\n$outline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));\n// Define the width (in points)\n$outline->setWidth(2);\n\n$series = new Series('Downloads', $seriesData);\n$series->setOutline($outline);\n
You can define the gap width between bar or columns clusters. It is relatively defined as percentage of a bars width. The default value is 150%. The value must be defined between 0 and 500.
<?php\n\n$barChart = new Bar();\n$barChart->setGapWidthPercent(250);\n
You can define the bar overlap within bar or column clusters. It is relatively defined as percentage of a bars width. The default value is 100% for stacked and 0% for grouped bar charts. The value must be defined between -100 and 100.
When setting the bar grouping type, the default overlap values will be set. Any change to the overlap must be made after setting the bar grouping type through setBarGrouping.
$barChart = new Bar();\n// will set the overlap to the default value for grouped bars: 0\n$barChart->setBarGrouping(Bar::GROUPING_CLUSTERED);\n\n// a positive value will result in an overlapping\n$barChart->setOverlapWidthPercent(25);\n\n// a negative value will result in a gap\n$barChart->setOverlapWidthPercent(-25);\n
You can stack multiples series in a same chart. After adding multiples series, you can define the bar grouping with setBarGrouping method of AbstractTypeBar.
<?php\n\n$barChart = new Bar();\n$barChart->addSeries($series1);\n$barChart->addSeries($series2);\n$barChart->addSeries($series3);\n$barChart->setBarGrouping(Bar::GROUPING_CLUSTERED);\n// OR\n$barChart->setBarGrouping(Bar::GROUPING_STACKED);\n// OR\n$barChart->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);\n
You can enable or disable the smooth line with setIsSmooth method from AbstractTypeLine. By default, smooth line is disabled.
<?php\n\n$chart = new Line();\n// Enable the smooth line\n$chart->setIsSmooth(true);\n// Disable the smooth line\n$chart->setIsSmooth(false);\n// Get status of smooth line\n$chart->isSmooth();\n
You can enable or disable the smooth line with setIsSmooth method from AbstractTypeLine. By default, smooth line is disabled.
<?php\n\n$chart = new Scatter();\n// Enable the smooth line\n$chart->setIsSmooth(true);\n// Disable the smooth line\n$chart->setIsSmooth(false);\n// Get status of smooth line\n$chart->isSmooth();\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\n\n$comment = new Comment();\n$slide->addShape($comment);\n
You can define text and date with setters.
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\n\n$comment = new Comment();\n$comment->setText('Text of the Comment');\n$comment->setDate(time());\n$slide->addShape($comment);\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\nuse PhpOffice\\PhpPresentation\\Shape\\Comment\\Author;\n\n$author = new Author();\n$comment = new Comment();\n$comment->setAuthor($author);\n$slide->addShape($comment);\n
You can define name and initials with setters.
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\nuse PhpOffice\\PhpPresentation\\Shape\\Comment\\Author;\n\n$author = new Author();\n$author->setName('Name of the author');\n$author->setInitals('Nota');\n$comment = new Comment();\n$comment->setAuthor($author);\n$slide->addShape($comment);\n
To create a drawing, use createDrawingShape method of slide.
<?php\n\n$shape = $slide->createDrawingShape();\n$shape->setName('Unique name')\n ->setDescription('Description of the drawing')\n ->setPath('/path/to/drawing.filename');\n
It's an alias for :
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Drawing\\File;\n\n$shape = new File();\n$shape->setName('Unique name')\n ->setDescription('Description of the drawing')\n ->setPath('/path/to/drawing.filename');\n$slide->addShape($shape);\n
Shapes are objects that can be added to a slide. There are five types of shapes that can be used, i.e. rich text, line, chart, drawing, and table. Read the corresponding section of this manual for detail information of each shape.
Every shapes have common properties that you can set by using fluent interface.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\RichText;\n\n$richText = new RichText();\n$richText->getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');\n
"},{"location":"usage/shapes/richtext.html#use-of-text-color","title":"Use of Text Color","text":"
Warning
Available only on the PowerPoint2007 Reader/Writer
Hyperlinks can be set to use the text color instead of the default theme color.
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\RichText;\n\n$richText = new RichText();\n$richText->getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');\n$richText->getHyperlink()->setIsTextColorUsed(true);\n
For a paragraph, you can define the line spacing. By default, mode is in percent (Paragraph::LINE_SPACING_MODE_PERCENT), but you can use the point mode (Paragraph::LINE_SPACING_MODE_POINT).
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph;\n\n$paragraph = new Paragraph();\n$paragraph->setLineSpacing(200);\n$lineSpacing = $paragraph->getLineSpacing();\n\n$paragraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT);\n$lineSpacingMode = $paragraph->getLineSpacingMode();\n
You can access cell objects with nextCell method of a Row object.
<?php\n\n$tableShape = $slide->createTableShape($columns);\n$row = $tableShape->createRow();\n// Get the first cell\n$cellA1 = $row->nextCell();\n// Get the second cell\n$cellA2 = $row->nextCell();\n
You can access cell object directly.
<?php\n\n$tableShape = $slide->createTableShape($columns);\n$row = $tableShape->createRow();\n// Get the first cell\n$cellA1 = $row->getCell(0);\n// Get the second cell\n$cellA2 = $row->getCell(1);\n
"},{"location":"usage/shapes/table.html#define-the-width","title":"Define the width","text":"
The width of cells are defined by the width of cell of the first row. If not defined, all cells widths are calculated from the width of the shape and the number of columns.
For defining the width of cell, you can use the setWidth method of a Cell object. The width is in pixels.
<?php\nuse PhpOffice\\PhpPresentation\\Slide\\Animation;\n\n$animation1 = new Animation();\n$animation1->addShape($drawing);\n$slide->addAnimation($animation1);\n\n$animation2 = new Animation();\n$animation2->addShape($richtext);\n$slide->addAnimation($animation2);\n
Slides are pages in a presentation. Slides are stored as a zero based array in PHPPresentation object. Use the method createSlide to create a new slide and retrieve the slide for other operation such as creating shapes for that slide.
The master slide upon which the slide is based : it specifies such properties as the font styles for the title, body, and footer, placeholder positions for text and objects, bullets styles, and background;
The slide layout which is applied to the the slide : it permits to override what is specified in the master slide;
The slide itself: it contains content and formatting that is not already specified by the master slide and the slide layout.
Placeholders permit to link these three components together in order that the override is possible.
You can define a shape as a placeholder for each level with the method setPlaceHolder. A shape defined in each level will have an override for its formatting in each level.
"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"index.html","title":"Introduction","text":"
PHPPresentation is a library written in pure PHP that provides a set of classes to write to different presentation file formats, i.e. Microsoft Office Open XML (.pptx) and OASIS Open Document Format for Office Applications (.odp).
PHPPresentation is an open source project licensed under the terms of LGPL version 3. PHPPresentation is aimed to be a high quality software product by incorporating continuous integration and unit testing. You can learn more about PHPPresentation by reading this Developers' Documentation.
Below are the supported features for each file formats.
"},{"location":"index.html#writers","title":"Writers","text":"Features HTML ODP PDF PPTX Document Mark as final Document Properties Standard Custom Slides Name Element Shape AutoShape Image Hyperlink Line MemoryImage RichText Table Text Charts Area Bar Bar3D Doughnut Line Pie Pie3D Radar Scatter"},{"location":"index.html#readers","title":"Readers","text":"Features ODP PPT PPTX Document Mark as final Document Properties Standard Custom Slides Name Element Shape AutoShape Image Hyperlink RichText Table Text Charts Area Bar Bar3D Doughnut Line Pie Pie3D Radar Scatter"},{"location":"index.html#contributing","title":"Contributing","text":"
We welcome everyone to contribute to PHPPresentation. Below are some of the things that you can do to contribute:
"},{"location":"faq.html","title":"Frequently asked questions","text":""},{"location":"faq.html#is-this-the-same-with-phppowerpoint-that-i-found-in-codeplex","title":"Is this the same with PHPPowerPoint that I found in CodePlex?","text":"
No. This one is much better with tons of new features that you can\u2019t find in PHPPowerPoint 0.1. The development in CodePlex is halted and switched to GitHub to allow more participation from the crowd. The more the merrier, right?
"},{"location":"faq.html#ive-been-running-phppowerpoint-from-codeplex-flawlessly-but-i-cant-use-the-latest-phppresentation-from-github-why","title":"I\u2019ve been running PHPPowerPoint from CodePlex flawlessly, but I can\u2019t use the latest PHPPresentation from GitHub. Why?","text":"
PHPPresentation requires PHP 5.3+ since v0.2, while PHPPowerPoint v0.1 from CodePlex can run with PHP 5.2.
There\u2019s a lot of new features that we can get from PHP 5.3 and it\u2019s been around since 2009! You should upgrade your PHP version to use PHPPresentation v0.2+.
"},{"location":"faq.html#why-am-i-getting-a-class-not-found-error","title":"Why am I getting a class not found error?","text":"
If you have followed the instructions for either adding this package to your composer.json or registering the autoloader, then perhaps you forgot to include a use statement for the class(es) you are trying to access.
Here's an example that allows you to refer to the MemoryDrawing class without having to specify the full class name in your code:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\MemoryDrawing as MemoryDrawing;\n
If you have followed the installation instructions and you have added the necessary use statements to your code, then maybe you are still referencing the PHPPowerPoint classes using the old PEAR/PSR-0 approach.
The 0.1 approach to naming classes used verbose class names to avoid namespace collisions with other libraries. For example, the MemoryDrawing class was actually called PHPPowerPoint_Shape_MemoryDrawing.
Version 0.2 of the library renamed the classes, moved to a namespaced approach and switched to the PSR-0 autoloader. Interestingly, old code that was still referencing classes using the verbose approach still worked (which was pretty cool!). This is because the PSR-0 autoloader was correctly translating the verbose class references into the correct file name and location. However, PHPPowerPoint now relies exclusively on the PSR-4 autoloader, so old code that may have been referencing the classes with the verbose class names will need to be updated accordingly.
"},{"location":"faq.html#why-phppowerpoint-become-phppresentation","title":"Why PHPPowerPoint become PHPPresentation ?","text":"
As Roman Syroeshko noticed us, PowerPoint is a trademark. For avoiding any problems with Microsoft, we decide to change the name to a more logic name, with our panel of readers/writers.
After installation, you can browse and use the samples that we've provided, either by command line or using browser. If you can access your PHPPresentation library folder using browser, point your browser to the samples folder, e.g. http://localhost/PhpPresentation/samples/.
PhpOffice\\PhpPresentation\\Writer\\ODPresentation : Move to Design Pattern Decorator - @Progi1984
PhpOffice\\PhpPresentation\\Writer\\PowerPoint2007 : Move to Design Pattern Decorator - @Progi1984
PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\getData has been deprecated for PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\getSeries - @Progi1984 GH-169
PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\setData has been deprecated for PhpOffice\\PhpPresentation\\Shape\\Type\\AbstracType\\setSeries - @Progi1984 GH-169
Added documentation for chart series (font, outline, marker) - @Progi1984 GH-169
Internal Structure for Drawing Shape - @Progi1984 GH-192
Documentation about manual installation - @danielbair GH-254
PowerPoint2007 Writer : Write percentage values with a trailing percent sign instead of formatted as 1000th of a percent to comply with the standard - @k42b3 GH-307
You can add custom properties with the method setCustomProperty.
Multiple types are available: * DocumentProperties::PROPERTY_TYPE_STRING for string value, * DocumentProperties::PROPERTY_TYPE_BOOLEAN for boolean value, * DocumentProperties::PROPERTY_TYPE_FLOAT for float value, * DocumentProperties::PROPERTY_TYPE_INTEGER for integer value, * DocumentProperties::PROPERTY_TYPE_DATE for date value, * DocumentProperties::PROPERTY_TYPE_UNKNOWN for unknown type value.
<?php\n\nuse PhpOffice\\PhpPresentation\\DocumentProperties;\n\n$properties = $presentation->getProperties();\n\n// Set the custom property\n$properties->setCustomProperty('propertyName', 'propertyValue', DocumentProperties::PROPERTY_TYPE_STRING);\n\n// Check if a custom property exists\n$properties->isCustomPropertySet('unknown'); // return `false`\n$properties->isCustomPropertySet('propertyName'); // return `true`\n\n// Return all custom properties\n$properties->getCustomProperties(); // return `['propertyName']`\n\n// Return value from a custom property\n$properties->getCustomPropertyValue('unknown'); // return `null` if not set\n$properties->getCustomPropertyValue('propertyName'); // return `propertyValue`\n\n// Return type from a custom property\n$properties->getCustomPropertyType('unknown'); // return `null` if not set\n$properties->getCustomPropertyType('propertyName'); // return `DocumentProperties::PROPERTY_TYPE_STRING`\n
You can define if the presentation display or not the comments with the method setCommentVisible.
<?php\n\n$presentation = new PhpPresentation();\n$properties = $presentation->getPresentationProperties();\n// Get the display for comment\nvar_export($properties->isCommentVisible());\n// Output : false\n// Enable the display for comment\n$properties->setCommentVisible(true);\n// Get the display for comment\nvar_export($properties->isCommentVisible());\n// Output : true\n
You can define the last view of the presentation with the method setLastView.
<?php\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Get the last view of the presentation\necho $properties->getZoom();\n// Output : PresentationProperties::VIEW_SLIDE\n// Set the last view of the presentation\n$properties->setLastView(PresentationProperties::VIEW_NOTES);\n// Get the last view of the presentation\necho $properties->getZoom();\n// Output : PresentationProperties::VIEW_NOTES\n
"},{"location":"usage/presentation.html#mark-as-final","title":"Mark as final","text":"
You must define your presentation as final with the method markAsFinal()
You can define the type of slideshow you can with the method setSlideshowType.
Differents types are available:
PresentationProperties::SLIDESHOW_TYPE_PRESENT for Presented by a speaker
PresentationProperties::SLIDESHOW_TYPE_BROWSE for Browsed by an individual
PresentationProperties::SLIDESHOW_TYPE_KIOSK for Browsed at a kiosk
<?php\n\nuse PhpOffice\\PhpPresentation\\PresentationProperties;\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Set type of slideshow\n$properties->setSlideshowType(PresentationProperties::SLIDESHOW_TYPE_PRESENT);\n// Get type of slideshow\necho $properties->getSlideshowType();\n
You can define the thumbnail of the presentation with the method setThumbnailPath.
<?php\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Set path of the thumbnail\n$properties->setThumbnailPath(__DIR__.'\\resources\\phppowerpoint_logo.gif');\n// Get path of the thumbnail\necho $properties->getThumbnailPath();\n
You can define the zoom of the presentation with the method setZoom.
<?php\n\n$presentation = new PhpPresentation();\n\n$properties = $presentation->getPresentationProperties();\n// Get zoom of the presentation\necho $properties->getZoom();\n// Output : 1\n// Set zoom of the presentation (3 = 300%)\n$properties->setZoom(3);\n// Get zoom of the presentation\necho $properties->getZoom();\n// Output : 3\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Alignment;\n\n$alignment = new Alignment();\n\n// Set alignment to RTL\n$alignment->setIsRTL(true);\n// Set alignment to LTR\n$alignment->setIsRTL(false);\n// Is the alignment RTL?\necho $alignment->isRTL();\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Font;\n\n$font = new Font();\n\n// Set capitalization of font\n$font->setCapitalization(Font::CAPITALIZATION_ALL);\n// Get capitalization of font\necho $font->getCapitalization();\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Font;\n\n$font = new Font();\n\n// Set format of font\n$font->setFormat(Font::FORMAT_EAST_ASIAN);\n// Get format of font\necho $font->getFormat();\n
You can define text of the geometric form with setText method.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\AutoShape;\n\n$shape = new AutoShape();\n// Define the text\n$shape->setText('ABC');\n// Return the text\n$shape->getText();\n
"},{"location":"usage/shapes/chart.html#customization","title":"Customization","text":""},{"location":"usage/shapes/chart.html#manage-how-blank-values-are-displayed","title":"Manage how blank values are displayed","text":"
You can define how blank values are displayed with the method setDisplayBlankAs.
Differents types are available:
Chart::BLANKAS_GAP for Leave a gap
Chart::BLANKAS_ZERO for Assume zero (default)
Chart::BLANKAS_SPAN for Continue line
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart;\n\n// Set the behavior\n$chart->setDisplayBlankAs(Chart::BLANKAS_GAP);\n// Get the behavior\necho $chart->getDisplayBlankAs();\n
You can define title for each axis (X & Y) with setTitle method. You can apply a rotation with the setTitleRotation method with an expected paremeter in degrees.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Gridlines;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n\n$shape->getPlotArea()->getAxisX()->setTitle('Axis X');\n$shape->getPlotArea()->getAxisX()->setTitleRotation(45);\n
You can define gridlines (minor and major) for each axis (X & Y). For each gridline, you can custom the width (in points), the fill type and the fill color.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Gridlines;\n\n$line = new Line();\n\n$gridlines = new Gridlines();\n$gridlines->getOutline()->setWidth(10);\n$gridlines->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisX()->setMajorGridlines($gridlines);\n
For Axis, you can define the min & max bounds with setMinBounds & setMaxBounds methods. For resetting them, you pass null as parameter to these methods.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Gridlines;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisX()->setMinBounds(0);\n$shape->getPlotArea()->getAxisX()->setMaxBounds(200);\n
For Axis, setCrossesAt can be used to define where it should be crossed by the perpendicular/ horizontal axis. The property can be defined by one of the three given constants or as an absolute value on the target axis.
use PhpOffice\\PhpPresentation\\Shape\\Axis;\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar;\n\n$bar = new Bar();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($bar);\n\n// Usage of constant: Horizontal axis will cross the Y-Axis at `0`\n$shape->getPlotArea()->getAxisY()->setCrossesAt(Axis::CROSSES_AUTO);\n\n// Usage of individual value: Horizontal axis will cross the Y-Axis at `3`\n$shape->getPlotArea()->getAxisY()->setCrossesAt('3');\n
Constant Description AXIS::CROSSES_AUTO Axis crosses at zero. AXIS::CROSSES_MIN Axis crosses at minimum. AXIS::CROSSES_MAX Axis crosses at maximum."},{"location":"usage/shapes/chart.html#reversed-order","title":"Reversed Order","text":"
You can reverse the order of a categorial or value axis trought setIsReversedOrder.
Notice: If you reverse the order of a axis, this automatically changes the position of the other axis. To reset this effect, the axis intersection point on the other axis must be set to Axis::CROSSES_MAX using setCrossesAt.
use PhpOffice\\PhpPresentation\\Shape\\Axis;\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Type\\Bar;\n\n$bar = new Bar();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($bar);\n\n// default value, will return false\n$shape->getPlotArea()->getAxisY()->isReversedOrder()\n\n// reverse order\n$shape->getPlotArea()->getAxisY()->setIsReversedOrder(true);\n\n// revert the automatic intersection switch on x axis\n$shape->getPlotArea()->getAxisX()->setCrossesAt(Axis::CROSSES_MAX);\n
You can define the tick label position with the setTickLabelPosition method. For resetting it, you pass Axis::TICK_LABEL_POSITION_NEXT_TO as parameter to this method.
Differents types are available:
Axis::TICK_LABEL_POSITION_HIGH: Labels are at the high end of the perpendicular axis
Axis::TICK_LABEL_POSITION_LOW: Labels are at the low end of the perpendicular axis
Axis::TICK_LABEL_POSITION_NEXT_TO: Labels are next to the axis (default)
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisY()->setTickLabelPosition(Axis::TICK_LABEL_POSITION_LOW);\n
For Axis Y, you can define tick mark with setMinorTickMark & setMajorTickMark methods. For resetting them, you pass Axis::TICK_MARK_NONE as parameter to these methods.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis;\n\n$line = new Line();\n\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n$shape->getPlotArea()->getAxisY()->setMinorTickMark(Axis::TICK_MARK_NONE);\n$shape->getPlotArea()->getAxisY()->setMajorTickMark(Axis::TICK_MARK_INSIDE);\n
By default, the title of a chart is displayed. For hiding it, you define its visibility to false.
<?php\n\n$line = new Line();\n$shape = $slide->createChartShape();\n$shape->getPlotArea()->setType($line);\n// Hide the title\n$shape->getTitle()->setVisible(false);\n
You can define if some informations are displayed.
<?php\n\n$series = new Series('Downloads', $seriesData);\n$series->setSeparator(';');\n$series->setShowCategoryName(true);\n$series->setShowLeaderLines(true);\n$series->setShowLegendKey(true);\n$series->setShowPercentage(true);\n$series->setShowSeriesName(true);\n$series->setShowValue(true);\n
You can custom the line of a serie, for Line & Scatter charts.
<?php\n\nuse PhpOffice\\PhpPresentation\\Style\\Outline;\n\n$outline = new Outline();\n// Define the color\n$outline->getFill()->setFillType(Fill::FILL_SOLID);\n$outline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));\n// Define the width (in points)\n$outline->setWidth(2);\n\n$series = new Series('Downloads', $seriesData);\n$series->setOutline($outline);\n
You can define the gap width between bar or columns clusters. It is relatively defined as percentage of a bars width. The default value is 150%. The value must be defined between 0 and 500.
<?php\n\n$barChart = new Bar();\n$barChart->setGapWidthPercent(250);\n
You can define the bar overlap within bar or column clusters. It is relatively defined as percentage of a bars width. The default value is 100% for stacked and 0% for grouped bar charts. The value must be defined between -100 and 100.
When setting the bar grouping type, the default overlap values will be set. Any change to the overlap must be made after setting the bar grouping type through setBarGrouping.
$barChart = new Bar();\n// will set the overlap to the default value for grouped bars: 0\n$barChart->setBarGrouping(Bar::GROUPING_CLUSTERED);\n\n// a positive value will result in an overlapping\n$barChart->setOverlapWidthPercent(25);\n\n// a negative value will result in a gap\n$barChart->setOverlapWidthPercent(-25);\n
You can stack multiples series in a same chart. After adding multiples series, you can define the bar grouping with setBarGrouping method of AbstractTypeBar.
<?php\n\n$barChart = new Bar();\n$barChart->addSeries($series1);\n$barChart->addSeries($series2);\n$barChart->addSeries($series3);\n$barChart->setBarGrouping(Bar::GROUPING_CLUSTERED);\n// OR\n$barChart->setBarGrouping(Bar::GROUPING_STACKED);\n// OR\n$barChart->setBarGrouping(Bar::GROUPING_PERCENTSTACKED);\n
You can enable or disable the smooth line with setIsSmooth method from AbstractTypeLine. By default, smooth line is disabled.
<?php\n\n$chart = new Line();\n// Enable the smooth line\n$chart->setIsSmooth(true);\n// Disable the smooth line\n$chart->setIsSmooth(false);\n// Get status of smooth line\n$chart->isSmooth();\n
You can enable or disable the smooth line with setIsSmooth method from AbstractTypeLine. By default, smooth line is disabled.
<?php\n\n$chart = new Scatter();\n// Enable the smooth line\n$chart->setIsSmooth(true);\n// Disable the smooth line\n$chart->setIsSmooth(false);\n// Get status of smooth line\n$chart->isSmooth();\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\n\n$comment = new Comment();\n$slide->addShape($comment);\n
You can define text and date with setters.
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\n\n$comment = new Comment();\n$comment->setText('Text of the Comment');\n$comment->setDate(time());\n$slide->addShape($comment);\n
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\nuse PhpOffice\\PhpPresentation\\Shape\\Comment\\Author;\n\n$author = new Author();\n$comment = new Comment();\n$comment->setAuthor($author);\n$slide->addShape($comment);\n
You can define name and initials with setters.
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Comment;\nuse PhpOffice\\PhpPresentation\\Shape\\Comment\\Author;\n\n$author = new Author();\n$author->setName('Name of the author');\n$author->setInitals('Nota');\n$comment = new Comment();\n$comment->setAuthor($author);\n$slide->addShape($comment);\n
To create a drawing, use createDrawingShape method of slide.
<?php\n\n$shape = $slide->createDrawingShape();\n$shape->setName('Unique name')\n ->setDescription('Description of the drawing')\n ->setPath('/path/to/drawing.filename');\n
It's an alias for :
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\Drawing\\File;\n\n$shape = new File();\n$shape->setName('Unique name')\n ->setDescription('Description of the drawing')\n ->setPath('/path/to/drawing.filename');\n$slide->addShape($shape);\n
Shapes are objects that can be added to a slide. There are five types of shapes that can be used, i.e. rich text, line, chart, drawing, and table. Read the corresponding section of this manual for detail information of each shape.
Every shapes have common properties that you can set by using fluent interface.
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\RichText;\n\n$richText = new RichText();\n$richText->getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');\n
"},{"location":"usage/shapes/richtext.html#use-of-text-color","title":"Use of Text Color","text":"
Warning
Available only on the PowerPoint2007 Reader/Writer
Hyperlinks can be set to use the text color instead of the default theme color.
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\RichText;\n\n$richText = new RichText();\n$richText->getHyperlink()->setUrl('https://phpoffice.github.io/PHPPresentation/');\n$richText->getHyperlink()->setIsTextColorUsed(true);\n
For a paragraph, you can define the line spacing. By default, mode is in percent (Paragraph::LINE_SPACING_MODE_PERCENT), but you can use the point mode (Paragraph::LINE_SPACING_MODE_POINT).
Example:
<?php\n\nuse PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph;\n\n$paragraph = new Paragraph();\n$paragraph->setLineSpacing(200);\n$lineSpacing = $paragraph->getLineSpacing();\n\n$paragraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT);\n$lineSpacingMode = $paragraph->getLineSpacingMode();\n
You can access cell objects with nextCell method of a Row object.
<?php\n\n$tableShape = $slide->createTableShape($columns);\n$row = $tableShape->createRow();\n// Get the first cell\n$cellA1 = $row->nextCell();\n// Get the second cell\n$cellA2 = $row->nextCell();\n
You can access cell object directly.
<?php\n\n$tableShape = $slide->createTableShape($columns);\n$row = $tableShape->createRow();\n// Get the first cell\n$cellA1 = $row->getCell(0);\n// Get the second cell\n$cellA2 = $row->getCell(1);\n
"},{"location":"usage/shapes/table.html#define-the-width","title":"Define the width","text":"
The width of cells are defined by the width of cell of the first row. If not defined, all cells widths are calculated from the width of the shape and the number of columns.
For defining the width of cell, you can use the setWidth method of a Cell object. The width is in pixels.
<?php\nuse PhpOffice\\PhpPresentation\\Slide\\Animation;\n\n$animation1 = new Animation();\n$animation1->addShape($drawing);\n$slide->addAnimation($animation1);\n\n$animation2 = new Animation();\n$animation2->addShape($richtext);\n$slide->addAnimation($animation2);\n
Slides are pages in a presentation. Slides are stored as a zero based array in PHPPresentation object. Use the method createSlide to create a new slide and retrieve the slide for other operation such as creating shapes for that slide.
The master slide upon which the slide is based : it specifies such properties as the font styles for the title, body, and footer, placeholder positions for text and objects, bullets styles, and background;
The slide layout which is applied to the the slide : it permits to override what is specified in the master slide;
The slide itself: it contains content and formatting that is not already specified by the master slide and the slide layout.
Placeholders permit to link these three components together in order that the override is possible.
You can define a shape as a placeholder for each level with the method setPlaceHolder. A shape defined in each level will have an override for its formatting in each level.