Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: URL-area not rotated in PDFs #23205

Closed
@oscargus

Description

@oscargus

Bug summary

The URL-sensitive area is not rotated in the PDF output

Code for reproduction

import matplotlib.pyplot as plt

plt.text(0.5, 0.5, "Long text with link", rotation=45, url="https://matplotlib.org")
plt.savefig("link.pdf")

Actual outcome

Note that the link area is still the horizontal part as if the text was not rotated (this makes sense from reading the code).

Expected outcome

Clicking on the text, not where the non-rotated text would have been would activate the URL.

Additional information

In https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf this is described in 12.5.6.5

From PDF version 1.6 it is possible to specify a "QuadPoints", i.e. a "rectangle" with four corners rather than just x, y, height, width as the current Rect has.

However it says:

If this entry is not present or the conforming reader does not recognize
it, the region specified by the Rect entry should be used. QuadPoints
shall be ignored if any coordinate in the array lies outside the region
specified by Rect.

So one would also need to provide a larger Rect, which, for viewers not supporting QuadPoints will lead to that the total rectangle outlined by the rotated text will be clickable.

This also holds for mathtexts.

Operating system

No response

Matplotlib Version

main

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

git checkout

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueOpen a pull request against these issues if there are no active ones!backend: pdf

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions