With the cairo update in bug 739096, the functions `cairo_tag_begin` and
`cairo_tag_end` become available, which can be used (with the "Link" tag
type) to generate links in PDF output.

There are two ways to use this. One approach is to issue
`cairo_tag_begin` with an associated URL, then do some drawing, and then
do `cairo_tag_end`; the PDF backend will collect the bounding rect of
whatever gets drawn in between the begin/end pair, and generate a link
for this area. The alternative is to explicitly pass a rect (or list of
rects) to `cairo_tag_begin`, rather than relying on the backend to
collect the affected area.

I've experimented with both options, and it seems to me that we get a
better result by explicitly passing the frame rect of whatever frame(s)
are associated with the link, rather than depending on cairo's
accumulation of the area between begin and end. This results in
clickable PDF links that better match the clickable areas of the HTML
document as viewed in the browser. (Which makes sense, as the active
area of an HTML link is determined by the frame's area, not by the
actual rendered ink.)

Currently, only the PDF backend supports generating links like this. On
macOS, our Save as PDF functionality actually goes via the cairo-quartz
backend and the macOS printing architecture, rather than cairo's PDF
backend. So to support links there, we'll need to add support for tag
begin/end to the quartz surface. Fortunately, we don't currently need to
implement everything that the PDF backend provides; just supporting
tag_begin with the Link type and an explicit rect will provide enough
functionality here.

(Eventually, it would be awesome to implement more Tagged PDF support --
e.g. to tag document structure, internal destinations, etc -- but that's
for another day, another bug.)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1551949

Title:
  Printing to PDF file loses URLs/links

To manage notifications about this bug go to:
https://bugs.launchpad.net/thunderbird/+bug/1551949/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to