Skip to content

Conversation

@tonymarklove
Copy link
Contributor

@tonymarklove tonymarklove commented Nov 4, 2025

Add links using Prawn's link_annotation. This works with any element that defines a bounding box, and also text. We transform the bounding box into PDF page space and then fit the link area as tightly as we can around the resulting box. This means the link area will tightly fit a rotated rectangle, for example.

One thing that isn't supported is adding links inside a text element. If you have the following markup:

<text>Text with a <a href="...">link</a> inside.</text>

I believe this is a valid SVG, but the current parser in prawn-svg doesn't handle this nesting, so it is beyond the scope of this PR.

Add links using Prawn's `link_annotation`. This works with any element that defines a bounding box, and also text. We transform the bounding box into PDF page space so that the link area will tightly fit a rotated rectangle, for example.

One thing that isn't supported is adding links inside a text element, for example:

```svg
<text>Text with a <a href="...">link</a> inside.</text>
```

I believe this is valid SVG, but the current parser in prawn-svg doesn't handle this nesting, so it is beyond the scope of this change.
@mogest
Copy link
Owner

mogest commented Nov 14, 2025

@tonymarklove, thank you so much for this very useful and beautifully written PR!

@mogest mogest merged commit 2169c9e into mogest:main Nov 14, 2025
6 checks passed
@tonymarklove tonymarklove deleted the link-anchors branch November 17, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants