In print contexts I used hyperlinks on texts and they worked very well when the output is a PDF. Now, I came across a request where I should put a link on an image. But an <a href=...><img src=....></a>
doesn’t seem to work in PDFs. Should that work or is it just something that doesn’t translate well to PDFs?
Perhaps certain PDF viewers don’t fully support the entire PDF standard, but if you open the output PDF with Acrobat Reader or even the latest Chrome browser, hyperlinks should work. This includes hyperlinks around images. Our code only looks at the wrapped content to determine its bounding box.
I did a quick test with an anchor targeting http://www.google.com around an image and it worked for me in both Acrobat and Chrome.
The PDF viewer doesn’t scan the text in the PDF to recognize portions that look like hyperlinks. A hyperlink in a PDF consists of an annotation with an area and a click target. If that annotation is not present the text is not considered a hyperlink even if it starts with http://. Our code iterates over all anchor tags and adds those annotations.
Things get more complicated when dealing with local links, i.e. links to elements on other pages and potentially even in other sections. But I assume we are talking about an external link here.
I am not sure that the links can only be the result of recognition by the viewer. Normally do not have a link in plain text like www.something.com but more like <a href="https://www.something.com/link/to/somewhere">{{customerNo}}</a>. These work fine in Adobe Reader and in the common browsers.
So my hopes where high for images as well… but I can’t get it to work. If someone can, please let me know.
Thanks @Sander. I just tried again and realized there is a linked area, just not over my picture but in a blank area in the upper left. Maybe the absolut positioned div is interfering?
I tried your snippet (thanks for that) but the output works for me, the link is in the right area. Perhaps your environment is different from my environment.
If you move the box, does the linked area get the same relative offset or is it fixed in the same position?
Since this is something that should work, please consider opening a support request.