Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #120: Add support for setting hyperlink URL on a Cell #234

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

lambart
Copy link

@lambart lambart commented Jul 22, 2021

Just contributing back some changes made for my employer. I see this has also been requested as issue #120.

Call Cell.setUrl() to add a URI to your Cell; it will be rendered and clickable in the enclosing Table.

@JamJar00
Copy link

Would love to see this get merged! Would be a great bit of functionality to have available so we can remove long links from our PDFs

@vivaca77
Copy link

hi lambart, can you please give an example how to use it, I see your implementation is used as createImageCell, not sure if is possible using it as regular cell and just using text?

@johnmanko johnmanko added this to the 1.7.1 milestone Jun 15, 2022
@johnmanko
Copy link
Collaborator

@lambart / @JamJar00

Can you give me a little background on this? Is a cell URI a standard feature of PDFBox?

@JamJar00
Copy link

I'm not sure I understand the question, it's not a 'standard' feature because PDFBox doesn't natively support tables. That's why we use boxable 🙂

This is a quality of life change. IIRC currently you need to have the full link text in the cell (which then automatically hyperlinks in most readers) where as this would allow you to have some 'click here' text that takes you somewhere when you click the cell.

@theeogflip
Copy link
Contributor

We need this, its actual not possible to add a hyperlink to a Cell

@johnmanko
Copy link
Collaborator

I'll take a look at this PR this weekend. Hopefully we can get it merged and put out a new release.

@johnmanko
Copy link
Collaborator

@JamJar00 Do you have a test you can include with this?

@theeogflip
Copy link
Contributor

Test is here: #262

@lambart
Copy link
Author

lambart commented Sep 21, 2022

hi lambart, can you please give an example how to use it, I see your implementation is used as createImageCell, not sure if is possible using it as regular cell and just using text?

Hi vivica77, sorry for the slow response!

For our purposes, we have only used it in an ImageCell; I haven't tried it in a TableCell but it might work.

We just do something like this...

imageCell.setUrl(new URL("https://example.com"));

I'm happy to see this getting some traction, and that some people find it useful.

@lambart
Copy link
Author

lambart commented Sep 21, 2022

@lambart / @JamJar00

Can you give me a little background on this? Is a cell URI a standard feature of PDFBox?

Hi John,
PFBox has various classes which extend PDAction, with support for form manipulation, navigation etc. We're just using one of those, a PDActionURI, to make PDFBox provide a navigable hyperlink for any arbitrary URL.

@johnmanko johnmanko merged commit 03a241c into dhorions:master Sep 14, 2023
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.

5 participants