8000 [ENH]: Better URL support for PDF backend · Issue #23152 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[ENH]: Better URL support for PDF backend #23152
Open
@oscargus

Description

@oscargus

Problem

The SVG backend supports URLs for all objects, which is quite easy as the URL is connected to the object in SVG (if I understand things correctly).

The PDF backend supports URLs for texts, but not for any other objects. One problem here is that the link seems to be connected to an area rather than an object.

It should be reasonably feasible to add support for images, markers, and bars.

Proposed solution

This is the code for adding an URL to a text object:

if gc.get_url() is not None:
link_annotation = {
'Type': Name('Annot'),
'Subtype': Name('Link'),
'Rect': (x, y, x + width, y + height),
'Border': [0, 0, 0],
'A': {
'S': Name('URI'),
'URI': gc.get_url(),
},
}
self.file._annotations[-1][1].append(link_annotation)

Basically, if one knows the coordinates, it should just be to copy this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0