Replies: 1   Views: 376
Text with hyperlink change the style while convert docx to 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 dipeshc  · 22-09-2021 - 11:22

If my word document contains a text with a hyperlink then a word to pdf using phpdocx change font color to blue and underline on text. How can I remove those default behavior and keep the exact style that exists in my word(LibreOffice) document?

Posted by admin  · 22-09-2021 - 12:10


How are you adding the hyperlink and what conversion plugin are you using?

Hyperlinks allow applying custom character styles and other styles. For example:

$docx = new CreateDocx();
$linkOptions = array(
    'url'=> '',
    'color' => 'B70000',
    'underline' => 'none',
    'strikeThrough' => false,
$docx->addLink('Link to Google in red color and not underlined', $linkOptions);
$docx->transformDocument('document.docx', 'document.pdf');

The PDF is generated with the same styles as the DOCX source: the link has B70000 color and no underline.

Or using HTML:

$docx->embedHTML('<a href="" style="color: green;">My link</a>');

If you are using a template, the existing styles aren't removed unless you request it using DOCXPath, DOCXCustomizer or other similar feature.

If you need to customize the styles of an existing hyperlink on-the-fly, you need to use customizeWordContent available in Premium licenses.