[reportlab-users] External hyperlinks in SVG output

Peter peter at maubp.freeserve.co.uk
Tue Feb 24 12:42:28 EST 2009


On Thu, Jan 29, 2009 at 4:38 PM, Andy Robinson <andy at reportlab.com> wrote:

>

> 2009/1/29 Peter <peter at maubp.freeserve.co.uk>:

>> I imagine there are parallels here with PDF output, which can in

>> theory also include externals URLs.  Is any of this currently possible

>> in ReportLab?  I've been looking over the documentation and the source

>> code, but have concluded that it is not yet supported.

>

> No.   A few people have asked us about charts with click-throughs

> and drill-downs, but we never did it.

>

> There are two parts to this.  First, the shapes hierarchy in

> reportlab/graphics would need some extra properties so that

> a shape could have link properties.  This is straightforward for

> manually constructed shapes, but presumably for charts one

> would need to allow some subclass or callback mechanism so the caller

> can define what URLs a data point or bar would link to.


What's in SVN now defines two optional attributes on the shape
objects, hrefURL and hrefTitle, which do nothing unless the render
code is aware of them.


> Secondly, each renderer would need to do the right thing.

> I can see this would be really easy with SVG.


Yes, this does now seem to be working pretty well for SVG.


> If you're willing to do a little work on this and contribute

> patches for core and SVG back end, we'd be happy to help out and

> maybe do the same in PDF in step with it.


I've been looking at ReportLab's PDF code, in particular the PDF
canvas object (which lives in reportlab/pdfgen/canvas.py rather than
reportlab/graphics/renderPDF.py) and see there is some code for "PDF
Actions" (a rather general feature which includes linking to an
external URL, or URI as Adobe seem to prefer). In the PDF canvas
linkURL method a "PDF Action" is associated with an invisible "PDF
Annotation", which is a rectangular region. If am I reading the code
right, this "link region" has to be a rectangle - it can't be a
rotated rectangle where the edges are not parallel to the page edges.
Can a "PDF Action" be attached to an ordinary shape, like a visible
(rotated) rectangle, or any closed path?

Peter


More information about the reportlab-users mailing list