addText
- getTemplateVariables
- getTemplateVariablesType
- removeVariableAudio
- removeVariableImage
- removeVariableText
- removeVariableVideo
- replaceVariableAudio
- replaceVariableHtml
- replaceVariableImage
- replaceVariableList
- replaceVariablePptxFragment
- replaceVariableTable
- replaceVariableText
- replaceVariableVideo
- setTemplateSymbol
addText

Inserts a text into the PowerPoint presentation.
Description
public addText($contents, $position, $paragraphStyles = array(), $options = array())
This method inserts texts into the PowerPoint presentation.
Parameters
contents
Array of text contents and styles.
Key | Type | Description |
---|---|---|
text | string | Text content. |
bold | bool | |
characterSpacing | int | |
color | string | HEX color. |
font | string | Font family. |
fontSize | int | 8, 9, 10, 11... |
highlight | string | HEX color. |
hyperlink | string | Hyperlink. External, bookmark (#firstslide, #lastslide, #nextslide, #previousslide) or slide (#slide with position). |
italic | bool | |
lang | string | Language. |
strikethrough | bool | |
underline | string | Underline: single. |
position
Key | Type | Description |
---|---|---|
placeholder | array |
The content is added in a placeholder of the layout. One of the following options can be used to get the text box.
|
new | array |
A new position is generated.
|
paragraphStyles
Key | Type | Description |
---|---|---|
align | string | left, center, right, justify, distributed. |
indentation | int | EMUs (English Metric Unit) |
lineSpacing | int|float | 1, 1.5, 2... |
listLevel | int | 0, 1, 2... |
listStyles | array | view addList |
marginLeft | int | EMUs (English Metric Unit) |
noBullet | bool | No bullet added. Default as true |
parseLineBreaks | bool | If true parses the line breaks. Default as false |
spacingAfter | int | points (0 >= and <= 158400) |
spacingBefore | int | points (0 >= and <= 158400) |
options
Key | Type | Description |
---|---|---|
insertMode | string |
Insert mode if the position contains an existing content:
Default as append. |
Exceptions
Position not valid.
Hyperlink slide position not valid.
Code samples
x
1
require_once 'classes/CreatePptx.php';
2
3
$pptx = new CreatePptx();
4
5
$content = array(
6
'text' => 'My title',
7
);
8
$pptx->addText($content, array('placeholder' => array('name' => 'Title 1')));
9
10
$content = array(
11
'text' => 'My subtitle',
12
'bold' => true,
13
'underline' => 'single',
14
);
15
$pptx->addText($content, array('placeholder' => array('name' => 'Subtitle 2')));
16
17
$pptx->savePptx('output');
18
42
1
require_once 'classes/CreatePptx.php';
2
3
$pptx = new CreatePptx();
4
5
// text box position and styles
6
$position = array(
7
'coordinateX' => 770000,
8
'coordinateY' => 507000,
9
'sizeX' => 7000000,
10
'sizeY' => 450000,
11
'textBoxStyles' => array(
12
'border' => array(
13
'color' => 'FF0000',
14
'dash' => 'dash',
15
'width' => 48575,
16
),
17
),
18
);
19
// text box created in addText
20
$content = array(
21
array(
22
'text' => 'At vero',
23
'highlight' => '628A54',
24
),
25
array(
26
'text' => ' eos et ',
27
'bold' => true,
28
'italic' => true,
29
'font' => 'Times New Roman',
30
),
31
array(
32
'text' => 'accusamus et iusto.',
33
'strikethrough' => true,
34
'color' => '628A54',
35
'italic' => true,
36
),
37
);
38
// the getActiveSlideInformation method returns information about placeholders in the current active slide to add text contents
39
$pptx->addText($content, array('new' => $position));
40
41
$pptx->savePptx('output');
42
13
1
require_once 'classes/CreatePptx.php';
2
3
$pptx = new CreatePptx();
4
5
$content = array(
6
'text' => 'My link',
7
'hyperlink' => 'http://www.phppptx.com'
8
);
9
// the getActiveSlideInformation method returns information about placeholders in the current active slide to add text contents
10
$pptx->addText($content, array('placeholder' => array('name' => 'Title 1')));
11
12
$pptx->savePptx('output');
13
Release notes
- phppptx 3.5:
- distributed align.
- indentation, marginLeft, spacingAfter, spacingBefore, listLevel, listStyles options.
- phppptx 2.0:
- parseLineBreaks option.
- phppptx 1.0:
- new method.