wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
8.97k stars 861 forks source link

Addition of onClick Event Handler for Links #1806

Open abadijo1 opened 1 month ago

abadijo1 commented 1 month ago

Before you start - checklist

Description

Right now, there's no built-in way to add onClick events to links in the rendered PDFs. This means we can't easily make links do custom actions when clicked.

I'm curious if there's interest in adding support for onClick events for links in React-PDF. With this feature, we could make PDFs more interactive by allowing custom actions or event triggering when links are clicked.

Proposed solution

We can enhance LinkService.ts by incorporating an onClick attribute. We would also need to expose a new prop named onLinkClick, which can be utilized within the document to execute custom functions.

Alternatives

No response

Additional information

No response

preveenraj commented 1 month ago

This can add value. May help to show a confirmation dialogue before taking anyone to an external link.