Skip to content

Commit 33efb79

Browse files
committed
undo changes in sample
1 parent 429ea46 commit 33efb79

File tree

1 file changed

+71
-10
lines changed

1 file changed

+71
-10
lines changed

samples/Sample_01_SimpleText.php

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,79 @@
99
$languageEnGb = new \PhpOffice\PhpWord\Style\Language(\PhpOffice\PhpWord\Style\Language::EN_GB);
1010

1111
$phpWord = new \PhpOffice\PhpWord\PhpWord();
12+
$phpWord->getSettings()->setThemeFontLang($languageEnGb);
1213

14+
$fontStyleName = 'rStyle';
15+
$phpWord->addFontStyle($fontStyleName, array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true));
16+
17+
$paragraphStyleName = 'pStyle';
18+
$phpWord->addParagraphStyle($paragraphStyleName, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER, 'spaceAfter' => 100));
19+
20+
$phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
21+
22+
// New portrait section
1323
$section = $phpWord->addSection();
14-
$section->addText(
15-
'"Learn from yesterday, live for today, hope for tomorrow. '
16-
. 'The important thing is not to stop questioning." '
17-
. '(Albert Einstein)',
18-
[],
19-
[
20-
'spacing' => \PhpOffice\Common\Font::pointSizeToTwips(1),
21-
'spacingLineRule' => \PhpOffice\PhpWord\SimpleType\LineSpacingRule::EXACT
22-
]
23-
);
24+
25+
// Simple text
26+
$section->addTitle('Welcome to PhpWord', 1);
27+
$section->addText('Hello World!');
28+
29+
// $pStyle = new Font();
30+
// $pStyle->setLang()
31+
$section->addText('Ce texte-ci est en français.', array('lang' => \PhpOffice\PhpWord\Style\Language::FR_BE));
32+
33+
// Two text break
34+
$section->addTextBreak(2);
35+
36+
// Define styles
37+
$section->addText('I am styled by a font style definition.', $fontStyleName);
38+
$section->addText('I am styled by a paragraph style definition.', null, $paragraphStyleName);
39+
$section->addText('I am styled by both font and paragraph style.', $fontStyleName, $paragraphStyleName);
40+
41+
$section->addTextBreak();
42+
43+
// Inline font style
44+
$fontStyle['name'] = 'Times New Roman';
45+
$fontStyle['size'] = 20;
46+
47+
$textrun = $section->addTextRun();
48+
$textrun->addText('I am inline styled ', $fontStyle);
49+
$textrun->addText('with ');
50+
$textrun->addText('color', array('color' => '996699'));
51+
$textrun->addText(', ');
52+
$textrun->addText('bold', array('bold' => true));
53+
$textrun->addText(', ');
54+
$textrun->addText('italic', array('italic' => true));
55+
$textrun->addText(', ');
56+
$textrun->addText('underline', array('underline' => 'dash'));
57+
$textrun->addText(', ');
58+
$textrun->addText('strikethrough', array('strikethrough' => true));
59+
$textrun->addText(', ');
60+
$textrun->addText('doubleStrikethrough', array('doubleStrikethrough' => true));
61+
$textrun->addText(', ');
62+
$textrun->addText('superScript', array('superScript' => true));
63+
$textrun->addText(', ');
64+
$textrun->addText('subScript', array('subScript' => true));
65+
$textrun->addText(', ');
66+
$textrun->addText('smallCaps', array('smallCaps' => true));
67+
$textrun->addText(', ');
68+
$textrun->addText('allCaps', array('allCaps' => true));
69+
$textrun->addText(', ');
70+
$textrun->addText('fgColor', array('fgColor' => 'yellow'));
71+
$textrun->addText(', ');
72+
$textrun->addText('scale', array('scale' => 200));
73+
$textrun->addText(', ');
74+
$textrun->addText('spacing', array('spacing' => 120));
75+
$textrun->addText(', ');
76+
$textrun->addText('kerning', array('kerning' => 10));
77+
$textrun->addText('. ');
78+
79+
// Link
80+
$section->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub');
81+
$section->addTextBreak();
82+
83+
// Image
84+
$section->addImage('resources/_earth.jpg', array('width'=>18, 'height'=>18));
2485

2586
// Save file
2687
echo write($phpWord, basename(__FILE__, '.php'), $writers);

0 commit comments

Comments
 (0)