Replies: 1   Views: 1137
Hyperlinks are not clickable in pdf
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 dev@ams  · 07-10-2020 - 07:40


When we generate .docx files containing hyperlinks, they are not 'clickble' when LibreOffice converts them to PDF. What we see, is that the docx that are generated by phpdocx (latest version) do not contain 

<w:rStyle w:val="Hyperlink"/>

within the hyperlink tag.

We have a word styles mapping, but that doesn't seem to do anything: '<a>' => 'Links'.

How can we get this to work by loading from html? 

<a href="">Hyperlink</a>


Posted by admin  · 07-10-2020 - 09:49


UPDATE: since phpdocx 11, addLink, embedHTML and replaceVariableByHTML methods add a default rStyle to hyperlinks that can be customized using the available options.

LibreOffice doesn't require Hyperlink as rStyle to generate the link when transforming DOCX to PDF. It needs any rStyle from the styles.xml file (Hyperlink style may not exists), you can create a custom one if needed using createCharacterStyle.

The current version of phpdocx allow appling a custom character style (rStyle) only to span tags, so you'd need to use (using DefaultParagraphFontPHPDOCX included in phpdocx default template, but you can use any other rStyle):

$html = '<a href=""><span class="DefaultParagraphFontPHPDOCX"></span></a>';

Without the rStyle, LibreOffice and MS Word display correctly the link, but LibreOffice doesn't include it when generating the PDF. The next release of phpdocx will include an automatic approach to this same task.