FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PHPWord/samples/Sample_01_SimpleText.php at develop · ynphp/PHPWord · GitHub
ynphp
PHPWord
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PHPWord
/
samples
/
Sample_01_SimpleText.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
90 lines (72 loc) · 3.1 KB
Breadcrumbs
PHPWord
/
samples
/
Sample_01_SimpleText.php
Copy path
File metadata and controls
90 lines (72 loc) · 3.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
use
PhpOffice
\
PhpWord
\
Style
\
Font
;
include_once
'
Sample_Header.php
'
;
// New Word Document
echo
date
(
'
H:i:s
'
) ,
'
Create new PhpWord object
'
,
EOL
;
$
languageEnGb
=
new
\
PhpOffice
\
PhpWord
\
Style
\
Language
(\
PhpOffice
\
PhpWord
\
Style
\Language::
EN_GB
);
$
phpWord
=
new
\
PhpOffice
\
PhpWord
\
PhpWord
();
$
phpWord
->
getSettings
()->
setThemeFontLang
(
$
languageEnGb
);
$
fontStyleName
=
'
rStyle
'
;
$
phpWord
->
addFontStyle
(
$
fontStyleName
,
array
(
'
bold
'
=>
true
,
'
italic
'
=>
true
,
'
size
'
=>
16
,
'
allCaps
'
=>
true
,
'
doubleStrikethrough
'
=>
true
));
$
paragraphStyleName
=
'
pStyle
'
;
$
phpWord
->
addParagraphStyle
(
$
paragraphStyleName
,
array
(
'
alignment
'
=> \
PhpOffice
\
PhpWord
\
SimpleType
\Jc::
CENTER
,
'
spaceAfter
'
=>
100
));
$
phpWord
->
addTitleStyle
(
1
,
array
(
'
bold
'
=>
true
),
array
(
'
spaceAfter
'
=>
240
));
// New portrait section
$
section
=
$
phpWord
->
addSection
();
// Simple text
$
section
->
addTitle
(
'
Welcome to PhpWord
'
,
1
);
$
section
->
addText
(
'
Hello World!
'
);
// $pStyle = new Font();
// $pStyle->setLang()
$
section
->
addText
(
'
Ce texte-ci est en français.
'
,
array
(
'
lang
'
=> \
PhpOffice
\
PhpWord
\
Style
\Language::
FR_BE
));
// Two text break
$
section
->
addTextBreak
(
2
);
// Define styles
$
section
->
addText
(
'
I am styled by a font style definition.
'
,
$
fontStyleName
);
$
section
->
addText
(
'
I am styled by a paragraph style definition.
'
,
null
,
$
paragraphStyleName
);
$
section
->
addText
(
'
I am styled by both font and paragraph style.
'
,
$
fontStyleName
,
$
paragraphStyleName
);
$
section
->
addTextBreak
();
// Inline font style
$
fontStyle
[
'
name
'
] =
'
Times New Roman
'
;
$
fontStyle
[
'
size
'
] =
20
;
$
textrun
=
$
section
->
addTextRun
();
$
textrun
->
addText
(
'
I am inline styled
'
,
$
fontStyle
);
$
textrun
->
addText
(
'
with
'
);
$
textrun
->
addText
(
'
color
'
,
array
(
'
color
'
=>
'
996699
'
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
bold
'
,
array
(
'
bold
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
italic
'
,
array
(
'
italic
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
underline
'
,
array
(
'
underline
'
=>
'
dash
'
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
strikethrough
'
,
array
(
'
strikethrough
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
doubleStrikethrough
'
,
array
(
'
doubleStrikethrough
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
superScript
'
,
array
(
'
superScript
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
subScript
'
,
array
(
'
subScript
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
smallCaps
'
,
array
(
'
smallCaps
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
allCaps
'
,
array
(
'
allCaps
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
fgColor
'
,
array
(
'
fgColor
'
=>
'
yellow
'
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
scale
'
,
array
(
'
scale
'
=>
200
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
spacing
'
,
array
(
'
spacing
'
=>
120
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addText
(
'
kerning
'
,
array
(
'
kerning
'
=>
10
));
$
textrun
->
addText
(
'
.
'
);
// Link
$
section
->
addLink
(
'
https://github.com/PHPOffice/PHPWord
'
,
'
PHPWord on GitHub
'
);
$
section
->
addTextBreak
();
// Image
$
section
->
addImage
(
'
resources/_earth.jpg
'
,
array
(
'
width
'
=>
18
,
'
height
'
=>
18
));
// Save file
echo
write
(
$
phpWord
,
basename
(
__FILE__
,
'
.php
'
),
$
writers
);
if
(!
CLI
) {
include_once
'
Sample_Footer.php
'
;
}
Back
|
FazBrowse Home
|
New Git URL