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

Click to open link on pdf when link not hyperlink #129

Closed
JSurquin opened this issue Apr 28, 2020 · 13 comments · Fixed by #144
Closed

Click to open link on pdf when link not hyperlink #129

JSurquin opened this issue Apr 28, 2020 · 13 comments · Fixed by #144
Labels
enhancement New feature or request
Milestone

Comments

@JSurquin
Copy link

Hello, I did a test by creating a simple example of pdf without hyperlink, I put https://google.fr and check it in the pdf reader, the link is not clickable, however, if the link is in hyperlink via libreoffice or other, the link is clickable :)

I did the same test with the native pdf reader of google chrome and whether in hyperlink or not, it detects that it is a link and allows to be able to click on it

Would it be possible to think of this scenario?

Indeed, the standard is respected but I do not think that the agents (I work for a company recognized as a training organization / education) will have the idea of ​​creating hyperlinks while they make their pdf

I could put a very quick example on a codesanbox or share the two pdf to dissociate the two cases, if necessary :)

Thank you again for taking the time to read me.

@phuocng
Copy link
Member

phuocng commented Apr 28, 2020

@JSurquin
Thanks for reaching out. I am rewriting the entire annotation layers (see #100) which also cover your use case.
Can you upload the sample document here and I'll ping you when there's a PR to fix that.

@phuocng phuocng added this to the v1.6.0 milestone Apr 28, 2020
@phuocng phuocng added the enhancement New feature or request label Apr 28, 2020
@JSurquin
Copy link
Author

thanks for the quick response :)

aSamplePdf_With_Hyperlink.pdf

aSamplePdf_Without_Hyperlink.pdf

@phuocng
Copy link
Member

phuocng commented Apr 30, 2020

@JSurquin
It was fixed in PR #144 and will be available in in the next 1.6.0.

Demo

link

@phuocng
Copy link
Member

phuocng commented May 4, 2020

@JSurquin Please upgrade to the latest version 1.6.0 which fixes the issue.

@JSurquin
Copy link
Author

JSurquin commented May 5, 2020

I update to 1.6.0 and I always have the same behavior :/

with the file without hyperlink

@JSurquin
Copy link
Author

JSurquin commented May 5, 2020

ezgif com-video-to-gif

@phuocng
Copy link
Member

phuocng commented May 5, 2020

I just download the document, and drag drop it to https://react-pdf-viewer.dev, and it works as expected. You can try to see.

Does it work if you place the viewer in the page, not inside the modal?

Updated
I tried the file with the hyperlink. Clicking the hyperlink will bring us to the target link.
What is your expectation if you open the file without hyperlink?

@JSurquin
Copy link
Author

JSurquin commented May 5, 2020

https://codesandbox.io/s/react-pdf-viewer-160-with-sample-pdf-without-hyperlink-added-kevqi?file=/src/App.js

I created a codesanbox to confirm that without obstructing css rules, it is still the case
I tested without the modal completely and I tested without the SVG layer but with the canvas (which by the way, is great, a very good job)

In fact, on the native pdf reader of chrome or firefox, when a pdf has been generated with a line containing an http / https link but without using a "hyperlink", the pdf reader recognizes it anyway and offers the link as clickable

@JSurquin
Copy link
Author

JSurquin commented May 5, 2020

As I told you above, I work for a training center, so the teachers creating the pdf could actually use hyperlinks in the document but what do you want? :p

This type of profile is not comfortable with IT and I think this feature is interesting anyway, in addition to the excellent work already provided :)

@phuocng
Copy link
Member

phuocng commented May 5, 2020

@JSurquin I am clear now.

  • The hyper link is parsed and rendered as a link annotation, and it's a standard PDF format.
    The previous version v1.5.0 doesn't support that, and the latest fixes the issue.

  • Now, for the text which isn't actually a hyperlink, but indeed should be treated as a link.
    In order to support that, we have to use an external library to parse the text, and turn the link-like text into hyperlinks.

There're some libraries such as

I'll try to create an example for you using one of these libraries with the viewer.

@phuocng
Copy link
Member

phuocng commented May 5, 2020

@JSurquin Here is a working example.

Demo

(take a look at the bottom of the screenshot below, and you'll see that the text is replaced with a link)

Screen Shot 2020-05-05 at 22 49 00

@JSurquin
Copy link
Author

JSurquin commented May 6, 2020

Awesome, it works well and it's the perfect behavior
Thank you again, subject closed :)

@phuocng
Copy link
Member

phuocng commented May 6, 2020

Great. Let me know if you have any questions or suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants