Replies: 1   Views: 1084
Adding link and comment on same word
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 15-07-2021 - 08:21


You need to use a WordFragment and add it to the textDocument option. For example:

$docx = new CreateDocx();

$textFragment = new WordFragment($docx, 'comment');
$textFragment->addText('Text content.');

$linkFragment = new WordFragment($docx);
$linkFragment->addLink('Link to Google', array('url'=> ''));

$comment = new WordFragment($docx, 'document');
        'textDocument' => array('text' => array($linkFragment)),
        'textComment' => $textFragment,
        'author' => 'PHPDocX Team',
$text = array();
$text[] = array('text' => 'Here comes the ');
$text[] = $comment;
$text[] = array('text' => ' and some other text.');