Sample 35 InternalLink

05:50:33 Create new PhpWord object
05:50:33 Write to Word2007 format
05:50:33 Write to ODText format
05:50:33 Write to RTF format
05:50:33 Write to HTML format
05:50:33 Write to PDF format ... NOT DONE!
05:50:33 Write to EPub3 format
05:50:33 Done writing file(s)
05:50:33 Peak memory usage: 4 MB

 

Results: docx odt rtf html epub


<?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'nullnull$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($phpWordbasename(__FILE__'.php'), $writers);
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}