Forum


Replies: 1   Views: 1041
Problem with href using external file links and embedhtml when transforming 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 vrietz  · 09-06-2021 - 10:10

Hello

I'm trying to add links in my document that opens other files, like this:

$docx->embedHTML('<a href="'.$filename.'" target="_blank">'.$val.'</a>', array('baseURL'=>"./annex/"));

It works fine in a DOCX, but when I transform the document into a PDF the link becomes url encoded (like this: "%2Fannex%2F") and doesn't open.

I also noticed that it doesn't happen when the path contains an accent. For example: 

$docx->embedHTML('<a href="'.$filename.'" target="_blank">'.$val.'</a>', array('baseURL'=>"./annèx/"));
//or
$docx->embedHTML('<a href="é'.$filename.'" target="_blank">'.$val.'</a>', array('baseURL'=>"./annex/"));

edit: the accent are misinterpreted in the code snippet

I don't understand what is happening.

I'm using phpdocx 7.5.

Can you help me ?

Thanks.

 

Posted by admin  · 09-06-2021 - 10:35

Hello,

You may need to apply a character style to the link content to generate the PDF link correctly using the conversion plugin based on LibreOffice. Please check the documentation available on https://www.phpdocx.com/faqs/forum/default/topic/2012. phpdocx 11 adds a custom character style to links automatically, but previous versions require adding them using the wordStyles option.

If you send to contact[at]phpdocx.com a DOCX sample we'll check it. As your username doesn't have a license tied, also please send the username or email of the user that purchased the license you are using.

Regards.