Sample 35 InternalLink

02:03:02 Create new PhpWord object
02:03:02 Write to Word2007 format
02:03:02 Write to ODText format
02:03:02 Write to RTF format
02:03:02 Write to HTML format
02:03:02 Write to PDF format
02:03:02 Done writing file(s)
02:03:02 Peak memory usage: 6 MB

 

Results: docx odt rtf html pdf


<?php

include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();

$section = $phpWord->addSection();
$section->addTitle('This is page 1', 1);
$linkIsInternal = true;
$section->addLink('MyBookmark', 'Take me to page 3', null, null, $linkIsInternal);
$section->addPageBreak();
$section->addTitle('This is page 2', 1);
$section->addPageBreak();
$section->addTitle('This is page 3', 1);
$section->addBookmark('MyBookmark');

// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}