Learn phppptx in 5 minutes

Quickstart guide

Information

phppptx is the most comprehensive library for working with PPTX presentations. It comprises all the necessary methods to generate new presentations, customize templates, insert and modify contents, define and apply styles, transform formats such as HTML and CSS, convert to PDF, encrypt, digitally sign and many other functionalities.

All available methods are very easy to use, and they allow to perform effortlessly any task, from the simplest to the most complex one.

Creating new documents

The CreatePptx class generates a new PPTX in which to add contents.

The following example creates a new presentation with two contents and saves the PPTX to the file system:

Almost any MS PowerPoint content can be added with phppptx. That includes images, tables, charts, comments, lists, sections, audios, videos, settings...

When including the CreatePptx.php file, the phppptx internal Autoloader is automatically loaded in order to access all the available classes.

Advanced and Premium licences come with a PHP namespaces package, not available in the Trial one.

Working with templates

Instead of generating a presentation from scratch, it is possible to do it with MS PowerPoint, LibreOffice, Google Docs or any other program in order to create a PPTX in which to include placeholders and other contents. phppptx counts with the necessary methods to replace those placeholders with new contents using the CreatePptxFromTemplate class.

The following example opens a PPTX template, replaces the NAME placeholder with a new text and then saves the PPTX to the file system:

phppptx offers methods to replace placeholders in lists, tables, images, medias, PptxFragments...

By default, placeholders are defined by the $ symbol, which can be customized with others such as ${ }, #...

PptxFragments

In phppptx, a PptxFragment is an object that can contain one or more elements. This allows to add complex elements and to perform advanced replacements.

The following example creates a PptxFragment and then replaces a placeholder with it:

HTML and CSS

One of the most widely used features of phppptx is HTML and CSS to PowerPoint conversion. It is a really easy way of adding contents to new presentations, as well as replacing placeholders, and it is compatible with many tags and styles.

E.g., in order to add a paragraph that includes text contents and a link:

PDF and other document formats

Advanced and Premium licenses include the conversion plugin to transform PPTX to PDF, PPTX to PPTX, and other conversions.

The transformDocument method is the responsible of the task. E.g., this transforms a PPTX created from scratch with phppptx or with templates, to PDF:

For more information

Besides this brief guide, we recommend visiting the following pages to understand phppptx in depth: