FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PHPWord/samples/Sample_25_TextBox.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_25_TextBox.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (42 loc) · 1.56 KB
Breadcrumbs
PHPWord
/
samples
/
Sample_25_TextBox.php
Copy path
File metadata and controls
48 lines (42 loc) · 1.56 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
<?php
include_once
'
Sample_Header.php
'
;
// New Word Document
echo
date
(
'
H:i:s
'
),
'
Create new PhpWord object
'
,
EOL
;
$
phpWord
=
new
\
PhpOffice
\
PhpWord
\
PhpWord
();
// New section
$
section
=
$
phpWord
->
addSection
();
// In section
$
textbox
=
$
section
->
addTextBox
(
array
(
'
alignment
'
=> \
PhpOffice
\
PhpWord
\
SimpleType
\Jc::
CENTER
,
'
width
'
=>
400
,
'
height
'
=>
150
,
'
borderSize
'
=>
1
,
'
borderColor
'
=>
'
#FF0000
'
,
)
);
$
textbox
->
addText
(
'
Text box content in section.
'
);
$
textbox
->
addText
(
'
Another line.
'
);
$
cell
=
$
textbox
->
addTable
()->
addRow
()->
addCell
();
$
cell
->
addText
(
'
Table inside textbox
'
);
// Inside table
$
section
->
addTextBreak
(
2
);
$
cell
=
$
section
->
addTable
()->
addRow
()->
addCell
(
300
);
$
textbox
=
$
cell
->
addTextBox
(
array
(
'
borderSize
'
=>
1
,
'
borderColor
'
=>
'
#0000FF
'
,
'
innerMargin
'
=>
100
));
$
textbox
->
addText
(
'
Textbox inside table
'
);
// Inside header with textrun
$
header
=
$
section
->
addHeader
();
$
textbox
=
$
header
->
addTextBox
(
array
(
'
width
'
=>
600
,
'
borderSize
'
=>
1
,
'
borderColor
'
=>
'
#00FF00
'
));
$
textrun
=
$
textbox
->
addTextRun
();
$
textrun
->
addText
(
'
TextBox in header. TextBox can contain a TextRun
'
);
$
textrun
->
addText
(
'
with bold text
'
,
array
(
'
bold
'
=>
true
));
$
textrun
->
addText
(
'
,
'
);
$
textrun
->
addLink
(
'
https://github.com/PHPOffice/PHPWord
'
,
'
PHPWord on GitHub
'
);
$
textrun
->
addText
(
'
, and image
'
);
$
textrun
->
addImage
(
'
resources/_earth.jpg
'
,
array
(
'
width
'
=>
18
,
'
height
'
=>
18
));
$
textrun
->
addText
(
'
.
'
);
// Save file
echo
write
(
$
phpWord
,
basename
(
__FILE__
,
'
.php
'
),
$
writers
);
if
(!
CLI
) {
include_once
'
Sample_Footer.php
'
;
}
Back
|
FazBrowse Home
|
New Git URL