2014-05-29 16:44:00 +02:00
|
|
|
<?php
|
2022-09-16 11:45:45 +02:00
|
|
|
|
2014-05-29 16:44:00 +02:00
|
|
|
include_once 'Sample_Header.php';
|
|
|
|
|
|
|
|
|
|
// New Word document
|
2015-01-01 20:41:42 +04:00
|
|
|
echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
2014-05-29 16:44:00 +02:00
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|
|
|
|
|
2016-06-04 20:06:37 +04:00
|
|
|
// New section
|
2014-05-29 16:44:00 +02:00
|
|
|
$section = $phpWord->addSection();
|
|
|
|
|
|
|
|
|
|
// Add Line elements
|
|
|
|
|
// See Element/Line.php for all options
|
2016-06-04 20:06:37 +04:00
|
|
|
$section->addText('Horizontal Line (Inline style):');
|
2014-05-29 16:44:00 +02:00
|
|
|
$section->addLine(
|
2022-09-16 11:45:45 +02:00
|
|
|
[
|
|
|
|
|
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
|
|
|
|
|
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
|
2015-01-01 20:41:42 +04:00
|
|
|
'positioning' => 'absolute',
|
2022-09-16 11:45:45 +02:00
|
|
|
]
|
2014-05-29 16:44:00 +02:00
|
|
|
);
|
2016-06-04 20:06:37 +04:00
|
|
|
$section->addText('Vertical Line (Inline style):');
|
2014-05-29 16:44:00 +02:00
|
|
|
$section->addLine(
|
2022-09-16 11:45:45 +02:00
|
|
|
[
|
|
|
|
|
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
|
|
|
|
|
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
|
2015-01-01 20:41:42 +04:00
|
|
|
'positioning' => 'absolute',
|
2022-09-16 11:45:45 +02:00
|
|
|
]
|
2014-05-29 16:44:00 +02:00
|
|
|
);
|
|
|
|
|
// Two text break
|
|
|
|
|
$section->addTextBreak(1);
|
|
|
|
|
|
2016-06-04 20:06:37 +04:00
|
|
|
$section->addText('Positioned Line (red):');
|
2014-05-29 16:44:00 +02:00
|
|
|
$section->addLine(
|
2022-09-16 11:45:45 +02:00
|
|
|
[
|
|
|
|
|
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
|
|
|
|
|
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
|
|
|
|
|
'positioning' => 'absolute',
|
2014-05-29 16:44:00 +02:00
|
|
|
'posHorizontalRel' => 'page',
|
2022-09-16 11:45:45 +02:00
|
|
|
'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',
|
|
|
|
|
]
|
2014-05-29 16:44:00 +02:00
|
|
|
);
|
|
|
|
|
|
2016-06-04 20:06:37 +04:00
|
|
|
$section->addText('Horizontal Formatted Line');
|
2014-05-29 16:44:00 +02:00
|
|
|
$section->addLine(
|
2022-09-16 11:45:45 +02:00
|
|
|
[
|
|
|
|
|
'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15),
|
|
|
|
|
'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
|
2014-05-29 16:44:00 +02:00
|
|
|
'positioning' => 'absolute',
|
2022-09-16 11:45:45 +02:00
|
|
|
'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,
|
|
|
|
|
]
|
2014-05-29 16:44:00 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Save file
|
|
|
|
|
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
|
|
|
|
if (!CLI) {
|
|
|
|
|
include_once 'Sample_Footer.php';
|
|
|
|
|
}
|