PHPWord/samples/Sample_35_InternalLink.php

24 lines
644 B
PHP
Raw Permalink Normal View History

2014-07-04 15:31:48 +02:00
<?php
2022-09-16 11:45:45 +02:00
2014-07-04 15:31:48 +02:00
include_once 'Sample_Header.php';
// New Word document
2015-01-01 20:41:42 +04:00
echo date('H:i:s'), ' Create new PhpWord object', EOL;
2014-07-04 15:31:48 +02:00
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
2016-06-04 20:06:37 +04:00
$section->addTitle('This is page 1', 1);
2014-07-04 15:31:48 +02:00
$linkIsInternal = true;
2016-06-04 20:06:37 +04:00
$section->addLink('MyBookmark', 'Take me to page 3', null, null, $linkIsInternal);
2014-07-04 15:31:48 +02:00
$section->addPageBreak();
2016-06-04 20:06:37 +04:00
$section->addTitle('This is page 2', 1);
2014-07-04 15:31:48 +02:00
$section->addPageBreak();
2016-06-04 20:06:37 +04:00
$section->addTitle('This is page 3', 1);
2014-07-04 15:31:48 +02:00
$section->addBookmark('MyBookmark');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}