[reportlab-users] External hyperlinks in SVG output

Peter peter at maubp.freeserve.co.uk
Thu Feb 12 18:09:22 EST 2009


On Thu, Feb 12, 2009 at 1:55 PM, Peter <peter at maubp.freeserve.co.uk> wrote:

>

> Trying to extend renderSVG to cope with links is on my to do list -

> but it would help to have an idea of how you would prefer to store the

> extra attributes within the basic shapes (discussed above).

>


I've got something with SVG links working here, but I had to make a
refinement to this bit of renderSVG.py:

#these suggested by Tim Roberts
self.svg.setAttribute("xmlns", "http://www.w3.org/2000/svg")
self.svg.setAttribute("xmlns:link", "http://www.w3.org/1999/xlink")
self.svg.setAttribute("version", "1.0")
self.svg.setAttribute("baseProfile", "full")

I found my links don't work (currently testing on Firefox 1.5 on
Linux) unless I change the "xmlns:link" to read "xmlns:xlink" instead.
This change is consistent with most online examples, e.g. the
official examples on http://www.w3.org/TR/SVG10/linking.html or
http://www.w3.org/TR/SVG/linking.html but some cases of the "wrong"
form do crop up via Google. With this fix the
http://validator.w3.org/ is also much happier - but still grumbles.

Apparently "version" and "baseProfile" shouldn't be there for the
currently used doctype. Interestingly renderSVG doesn't specify the
doctype, letting python's xml.dom decide, so it could vary with
version of python (and I am using python 2.4 on this machine). We
should be able to specify them when creating the DOM...

Peter


More information about the reportlab-users mailing list