Sample 15 Link

01:10:38 Create new PhpWord object
01:10:38 Write to Word2007 format
01:10:38 Write to ODText format
01:10:38 Write to RTF format
01:10:38 Write to HTML format
01:10:38 Write to PDF format
01:10:39 Done writing file(s)
01:10:39 Peak memory usage: 4 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, array('bold' => true'color' => '808000'));

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

// Add hyperlink elements
$section->addLink(
    
'https://github.com/PHPOffice/PHPWord',
    
'PHPWord on GitHub',
    array(
'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';
}