Sample 15 Link

04:32:33 Create new PhpWord object
04:32:33 Write to Word2007 format
04:32:33 Write to ODText format
04:32:33 Write to RTF format
04:32:33 Write to HTML format
04:32:33 Write to PDF format
04:32:34 Done writing file(s)
04:32:34 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();

// Define styles
$linkFontStyleName 'myOwnLinStyle';
$phpWord->addLinkStyle($linkFontStyleName, ['bold' => true'color' => '808000']);

// New section
$section $phpWord->addSection();

// Add hyperlink elements
$section->addLink(
    
'https://github.com/PHPOffice/PHPWord',
    
'PHPWord on GitHub',
    [
'color' => '0000FF''underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE]
);
$section->addTextBreak(2);
$section->addLink('http://www.bing.com'null$linkFontStyleName);
$section->addLink('http://www.yahoo.com'null$linkFontStyleName);

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