Geen omschrijving

Sample_05_Multicolumn.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '
  7. . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. '
  8. . 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. '
  9. . 'Suspendisse congue congue leo sed pellentesque.';
  10. // Normal
  11. $section = $phpWord->addSection();
  12. $section->addText(htmlspecialchars("Normal paragraph. {$filler}"));
  13. // Two columns
  14. $section = $phpWord->addSection(
  15. array(
  16. 'colsNum' => 2,
  17. 'colsSpace' => 1440,
  18. 'breakType' => 'continuous',
  19. )
  20. );
  21. $section->addText(htmlspecialchars("Two columns, one inch (1440 twips) spacing. {$filler}"));
  22. // Normal
  23. $section = $phpWord->addSection(array('breakType' => 'continuous'));
  24. $section->addText(htmlspecialchars("Normal paragraph again. {$filler}"));
  25. // Three columns
  26. $section = $phpWord->addSection(
  27. array(
  28. 'colsNum' => 3,
  29. 'colsSpace' => 720,
  30. 'breakType' => 'continuous',
  31. )
  32. );
  33. $section->addText(htmlspecialchars("Three columns, half inch (720 twips) spacing. {$filler}"));
  34. // Normal
  35. $section = $phpWord->addSection(array('breakType' => 'continuous'));
  36. $section->addText(htmlspecialchars('Normal paragraph again.'));
  37. // Save file
  38. echo write($phpWord, basename(__FILE__, '.php'), $writers);
  39. if (!CLI) {
  40. include_once 'Sample_Footer.php';
  41. }