I have a requirement where I need to portray an image using xsl-fo and the user should be able to click within the text / particular location of the image. To explain it further,
- I have an image
- It contains text
- I have the co-ordinates of where the text occurs and need to provide hyper-link for those co-ordinates.
So, when I click on the text, I should be able to traverse to another location in the PDF document.
I have tried with <area>
tag mentioning the co-ordinates within <fo:block>
, but it does not work.
My Fo structure is as follows:
<fo:block> <fo:external-graphic content-width="scale-to-fit" content-height="100%" width="100%" src="figures/test.png"/><area shape="rect" coords="148,147,195,162" <fo:basic-link>xyz</fo:basic-link></area>
</fo:block>
Could you please let me know if anyone has tried something like this and help me out?
While XSL-FO does not have image maps (something analogous to the
MAP
element in HTML), it is possible to use an embedded SVG document to achieve the same result.Have a look at this example:
Inside the svg document:
image
element places the bitmap image, having the same size of the document viewBoxa
element defines the link destinationrect
element inside thea
defines the clickable areaI tested this example with FOP 2.1 and it works, with a couple of caveat:
opacity="0"
; I tried usingfill="none" stroke="none"
but this was not working, probably because the rectangle was completely discarded / ignored not having any visible markellipse
element in the SVG