Well I know this one because I spent almost an hour just to fix it and I was embarrassed when i realized the solution was so simple
Two things that are most important when you are using tcpdf for converting HTML to PDF are
- Valid HTML
- Values you passed to the tcpdf functions should be totally understood and you should know what they does
ok lets see what the problem is with link
In my case
if you have a php string like
$html = "<a href='http://jaspreetchahal.org'>jaspreetchahal.org</a>";
above is valid string but somehow tcpdf with not take single quotes with great pleasure and you will see that even though It will colour “jaspreetchahal.org” part of anchor, when you try to click on that link it takes you nowhere
now the solution
$html = '<a href="http://jaspreetchahal.org">jaspreetchahal.org</a>'; OR $html =<<<LINK <a href="http://jaspreetchahal.org">jaspreetchahal.org</a> LINK;
Just replace single quote with double quotes and vice versa and you’re done
A clickable link
Hope this helps





JC WordPress Coupon Revealer Plugin Pro License
Australian Street Names with City, State and Display Names only, Single Server License
Your solution does not wor for me.
I can’t see any Anchors in my output pdf anyway.
However I found out that using sigle quotes i can display them, at least ( if not using them because are not clickable).
And I am displaying the anchors with href in single quotes and with preg_replace i am adding the href attribute content inside anchor tag. This way i display the link and the url.
It is not so pretty but a solution.
Well that’s awesome that you got it working for yourself
Please post your code too to help others
Cheers
Sorry. I didn’t know how this form processes characters. Here is what I wanted to write: http://pastebin.com/LN5vGyzw
I thought I found the answer cause my links are also not displayed but it seems that my problem is with very long text in urls. Any solution for that?
Can you tell me how long is your text.
Try rendering It with writeHTMLCell() http://www.tcpdf.org/doc/classTCPDF.html#a8458280d15b73d3baffb28eebe2d9246
Or you can also use addHtmlLink() depending on how you are rendering your pdf. read more here http://www.tcpdf.org/doc/classTCPDF.html#af26dfbff2e1507f87a2fae64eebe08e1
Thank you so very much! I spent embarrassingly longer than an hour – on trying to get images working – and couldn’t find a fix until I found this.
No Worries! I am glad that I could be of any help. I was stuck out there too before I found out what mistake I was making