[cairo] Howto: insert anchors into cairo-generated PDF or SVG graphics ?

Behdad Esfahbod behdad at behdad.org
Wed Feb 6 10:17:24 PST 2008


Yeah, see:

http://lists.cairographics.org/archives/cairo/2007-November/012026.html

behdad

On Wed, 2008-02-06 at 13:09 -0500, John Ellson wrote:
> Carl Worth wrote:
> > On Tue, 05 Feb 2008 12:49:38 -0500, John Ellson wrote:
> >   
> >> Is there a cairo-api that can be used to place anchor annotations around
> >> blocks of cairo graphic objects in output formats that support them,
> >> such as SVG or PDF ?
> >>     
> >
> > There's not any API for this yet. But we've had an item on our TODO
> > list for just about forever saying that it would definitely be a nice
> > thing to have.
> >
> > I think we're just waiting for someone to take it from the "it would
> > be nice" stage to something more concrete by starting an
> > implementation.
> >
> >   
> >> Or can anyone suggest any hacks or kludges that would let me do
> >> this?
> >>     
> >
> > I hope you'll get some feedback to this question, since hacks and
> > kludges might actually help direct the way toward a real solution.
> >
> > -Carl
> >   
> 
> Carl,
> 
> 
> Here are some thoughts to try get a development discussion started:
> 
> Goal:
> 
>    Support for "anchors" in cairo's various output formats.  i.e. 
> regions that are sensitive
>    to the mouse and which can raise a tooltip or map to a URL.
> 
>    This proposal is based on experience with generating anchors and maps 
> in graphviz
>    (and is pragmatically designed to minimally support the needs of 
> graphviz).
> 
> 
> Examples:
> 
>    SVG:
> 
>      [<!ATTLIST svg xmlns:xlink CDATA #FIXED 
> "http://www.w3.org/1999/xlink">]
>      ...
>      <a xlink:href="some_url" xlink:title="some_tooltip" 
> target="some_target">
>         ... graphics ...
>      </a>
> 
>    VML:
> 
>       <a href="some_url" title="some_tooltip" target="some_target">
>         ... graphics ...
>       </a>
> 
>    PDF:
> 
>       [ /Rect [ x1 y1 x2 y2 ]
>         /Border [ 0 0 0 ]
>         /Action << /Subtype /URI /URI some_url
>         /Subtype /Link
>       /ANN pdfmark
> 
>    Imagemaps
> 
>       <area shape="poly" href="some_url" title="some_tooltip" alt="" 
> coords="x1 y1 ..... " />
> 
> 
> Observations:
> 
>    SVG and VML anchors enclose the graphic primitives, PDF and Imagemaps
>    describe a separate shape for the sensitive area.
> 
>    Imagemaps are just a surface with anchors, but no other graphics.  
> Once anchors
>    are supported it makes sense for cairo to support imagemaps as an 
> output surface type.
> 
> 
> 
> Proposal for cairo api:
> 
>         typedef struct {
>                 char *url;        /* null permitted for case of tooltip 
> only */
>                 char *tooltip;    /* null permitted */
>                 char *target;     /* null permitted */
>         } cairo_anchor_data_t;
> 
>         cairo_status_t cairo_begin_anchor(cairo_t, cairo_anchor_data_t);
>         cairo_status_t cairo_end_anchor(cairo_t);
> 
> 
>     cairo_begin_anchor() ... cairo_end_anchor() would enclose the set of 
> graphics
>     that are to be mouse sensitive in the output format.
> 
>     Each backend would emit output using the fields in the 
> cairo_anchor_data_t
>     in the appropriate syntax for that format.   Null property values 
> will cause
>     the entire property=value to be omitted from the output.
> 
>     Backends have access to the contained graphics and so can calculate 
> bounding shapes
>     as needed.
> 
> 
> John
> 
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list