dompdf / dompdf

HTML to PDF converter for PHP
https://dompdf.github.io/
GNU Lesser General Public License v2.1
10.54k stars 1.8k forks source link

A Tag Link and Anchoring is not working #1147

Open harishsalian05 opened 8 years ago

harishsalian05 commented 8 years ago

A Tag link & Anchoring is not working, on PDF generation the text gets highlighted blue but its not clickable.

Kindly help!! Tried latest beta release, version 0.6.2, 0.6.0. Cant get through.

Any help is appreciated.

bsweeney commented 8 years ago

There does appear to be a bug in the 0.7.0 beta where dompdf attempts to construct a full URI before rendering the link. This is causing dompdf to use the wrong linking mechanism.

Named anchors work in v0.6.2 and earlier, but there is a minor issue you have to work around. In those versions named anchors are removed if they're empty.

So instead of something like:

<p><a href="#ch2">Chapter 2</a></p>
<!-- lots of content -->
<a name="ch2"></a>
<h2>Chapter 2</h2>

you'll need to do this:

<p><a href="#ch2">Chapter 2</a></p>
<!-- lots of content -->
<h2><a name="ch2">Chapter 2</a></h2>
bsweeney commented 8 years ago

The bug in 0.7.0 beta was due to the change introduced by df0bc000c5e0ecaf33ba1e3eb234632f427909cc, which I have fixed.

Still, the anchor linking could use a bit more work. I'll leave this open as a reminder to address the issue around empty named anchors elements and lack of support for ID linking. We should also try to better target the PDF action that takes you to the anchor.

harishsalian05 commented 8 years ago

Thanks for the update Brian :-) I will check and update you. Thanks again for your inputs.

u01jmg3 commented 8 years ago

@bsweeney: sorry for jumping on an old issue but I am having a problem with dompdf v0.7.0 rendering a simple link such as <a href="http://www.google.co.uk">Google</a>. The resulting PDF contains the link but it is not clickable. Switching to v0.6.2 and dompdf works fine. Am I missing something? Thanks

bsweeney commented 8 years ago

@u01jmg3 seems to be working ok. Do you have a sample HTML document and the resulting PDF? Are you running the final 0.7.0 release?

u01jmg3 commented 8 years ago

False alarm - I tried again from the beginning and it is working without issue. User error. Apologies for wasting your time.

bsweeney commented 8 years ago

No worries, glad it worked out.

isaacfennell commented 7 years ago

@u01jmg3 What was causing the issue for you? I have the same problem…

u01jmg3 commented 7 years ago

This is from a while ago but I think I just reloaded my dependencies from scratch. I would suggest doing the same with the latest version of dompdf.

parshavshah commented 6 years ago

@bsweeney Thanks. It works.