[cairo] Howto: insert anchors into cairo-generated PDF or SVG graphics ?
Alp Toker
alp at atoker.com
Thu Feb 7 20:16:52 PST 2008
John Ellson wrote:
> Behdad Esfahbod wrote:
>> Yeah, see:
>>
>> http://lists.cairographics.org/archives/cairo/2007-November/012026.html
>>
>> behdad
>>
>
> Good. Is there an implemenation developing?
No implementation going. I got as far as studying the specs, not even
writing an initial patch this time.
>
> I was hoping for something slightly more abstract, that could support
> anchors as enclosing blocks in
> SVG and VML, not just as shapes as in PDF or imagemaps.
Most of the backends do seem to support attaching anchors to existing
elements.
>
> Also, I was thinking that the cairo user should not have to define a new
> path for the sensitive area; that instead an appropriate bounding
> region could extracted from a pushed group, or a mini surface, or
> something like that. No coordinates are required in the case of SVG.
I was expecting when I wrote the proposal that the backend would do the
right thing and attach the hyperlink to the already-existing PDF/SVG
etc. object/element created by the previous cairo_fill_preserve() where
possible. If not possible, it'd create create a new rectangular or
shaped hyperlink object.
>
> A question of style: cairo doesn't need to know anything about URLs,
> targets, tooltips, etc. Is it better to introduce (a possibly evolving
> set of)
> getters and setters for these properties, or just to have the user
> populate a structure that cairo can pass transparently through to the
> backends?
I had an original proposal that did almost exactly what you suggest,
through a "document metadata context". I forgot the exact details, but
cairo_metadata_t* had a bunch of setters to support the full set of PDF
actions.
The problem with this is that it rapidly grew to become an uncomfortable
abstraction trying to map different concepts of PDF and SVG into one API.
It didn't look good and didn't seem to belong in Cairo at all. I bet
most users are just looking for hyperlink embedding, for which we can
aim to support (1) in-document links (2) external hyperlinks.
Although Carl doesn't like to look at other graphics systems for
inspiration, I did check with CG, and it indeed only supports
rectangular PDF hyperlinks which aren't even attached to any object. So
we can do a little better than that, as I proposed, but I don't think we
can do a lot better.
Of course, if you can devise a compact and easily supported interface
for document metadata, I'd love to be proven wrong.
More information about the cairo
mailing list