説明なし

Sample_19_TextBreak.php 1.2KB

1234567891011121314151617181920212223242526272829303132
  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. $fontStyle = array('size' => 24);
  8. $paragraphStyle = array('spacing' => 240, 'size' => 24);
  9. $phpWord->addFontStyle('fontStyle', array('size' => 9));
  10. $phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480));
  11. $fontStyle = array('size' => 24);
  12. $section = $phpWord->addSection();
  13. $section->addText(htmlspecialchars('Text break with no style:'));
  14. $section->addTextBreak();
  15. $section->addText(htmlspecialchars('Text break with defined font style:'));
  16. $section->addTextBreak(1, 'fontStyle');
  17. $section->addText(htmlspecialchars('Text break with defined paragraph style:'));
  18. $section->addTextBreak(1, null, 'paragraphStyle');
  19. $section->addText(htmlspecialchars('Text break with inline font style:'));
  20. $section->addTextBreak(1, $fontStyle);
  21. $section->addText(htmlspecialchars('Text break with inline paragraph style:'));
  22. $section->addTextBreak(1, null, $paragraphStyle);
  23. $section->addText(htmlspecialchars('Done.'));
  24. // Save file
  25. echo write($phpWord, basename(__FILE__, '.php'), $writers);
  26. if (!CLI) {
  27. include_once 'Sample_Footer.php';
  28. }