Forum


Replies: 1   Views: 2128
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 admin  · 07-10-2020 - 09:49

Hello,

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="https://google.nl"><span class="DefaultParagraphFontPHPDOCX">www.link.com</span></a>';
$docx->embedHTML($html);

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.

Regards.