Forum


Replies: 1   Views: 1251
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.