No Description

Sample_29_Line.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. include_once 'Sample_Header.php';
  3. // New Word document
  4. echo date('H:i:s'), ' Create new PhpWord object', EOL;
  5. $phpWord = new \PhpOffice\PhpWord\PhpWord();
  6. // Begin code
  7. $section = $phpWord->addSection();
  8. // Add Line elements
  9. // See Element/Line.php for all options
  10. $section->addText(htmlspecialchars('Horizontal Line (Inline style):'));
  11. $section->addLine(
  12. array(
  13. 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
  14. 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
  15. 'positioning' => 'absolute',
  16. )
  17. );
  18. $section->addText(htmlspecialchars('Vertical Line (Inline style):'));
  19. $section->addLine(
  20. array(
  21. 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
  22. 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
  23. 'positioning' => 'absolute',
  24. )
  25. );
  26. // Two text break
  27. $section->addTextBreak(1);
  28. $section->addText(htmlspecialchars('Positioned Line (red):'));
  29. $section->addLine(
  30. array(
  31. 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(4),
  32. 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(1),
  33. 'positioning' => 'absolute',
  34. 'posHorizontalRel' => 'page',
  35. 'posVerticalRel' => 'page',
  36. 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(10),
  37. 'marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(8),
  38. 'wrappingStyle' => \PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE,
  39. 'color' => 'red',
  40. )
  41. );
  42. $section->addText(htmlspecialchars('Horizontal Formatted Line'));
  43. $section->addLine(
  44. array(
  45. 'width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(15),
  46. 'height' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(0),
  47. 'positioning' => 'absolute',
  48. 'beginArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_BLOCK,
  49. 'endArrow' => \PhpOffice\PhpWord\Style\Line::ARROW_STYLE_OVAL,
  50. 'dash' => \PhpOffice\PhpWord\Style\Line::DASH_STYLE_LONG_DASH_DOT_DOT,
  51. 'weight' => 10,
  52. )
  53. );
  54. // Save file
  55. echo write($phpWord, basename(__FILE__, '.php'), $writers);
  56. if (!CLI) {
  57. include_once 'Sample_Footer.php';
  58. }