No Description

Sample_35_InternalLink.php 715B

12345678910111213141516171819202122
  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. $section = $phpWord->addSection();
  7. $section->addTitle(htmlspecialchars('This is page 1'), 1);
  8. $linkIsInternal = true;
  9. $section->addLink('MyBookmark', htmlspecialchars('Take me to page 3'), null, null, $linkIsInternal);
  10. $section->addPageBreak();
  11. $section->addTitle(htmlspecialchars('This is page 2'), 1);
  12. $section->addPageBreak();
  13. $section->addTitle(htmlspecialchars('This is page 3'), 1);
  14. $section->addBookmark('MyBookmark');
  15. // Save file
  16. echo write($phpWord, basename(__FILE__, '.php'), $writers);
  17. if (!CLI) {
  18. include_once 'Sample_Footer.php';
  19. }