forked from PHPOffice/PHPWord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_29_Line.php
64 lines (58 loc) · 2.3 KB
/
Sample_29_Line.php
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
<?php
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code
$section = $phpWord->addSection();
// Add Line elements
// See Element/Line.php for all options
$section->addText(htmlspecialchars('Horizontal Line (Inline style):', ENT_COMPAT, 'UTF-8'));
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
'positioning' => 'absolute',
)
);
$section->addText(htmlspecialchars('Vertical Line (Inline style):', ENT_COMPAT, 'UTF-8'));
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
'positioning' => 'absolute',
)
);
// Two text break
$section->addTextBreak(1);
$section->addText(htmlspecialchars('Positioned Line (red):', ENT_COMPAT, 'UTF-8'));
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
'positioning' => 'absolute',
'posHorizontalRel' => 'page',
'posVerticalRel' => 'page',
'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(10),
'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(8),
'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE,
'color' => 'red',
)
);
$section->addText(htmlspecialchars('Horizontal Formatted Line', ENT_COMPAT, 'UTF-8'));
$section->addLine(
array(
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15),
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
'positioning' => 'absolute',
'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK,
'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL,
'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT,
'weight' => 10,
)
);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}