izuzak / atom-pdf-view

Support for viewing PDF files in Atom.
https://atom.io/packages/pdf-view
MIT License
106 stars 30 forks source link

Links in PDF-files #149

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello, seems I cannot click links on PDF. Is it possible at all? If not, is it problem with this package or PDF.js?

izuzak commented 7 years ago

Hi @mkoske. I have to say I haven't tried that before myself, but I just tried it now and links don't work for me either.

Not really sure why that's so, to be honest. I won't have time to investigate this anytime soon, so if you or anyone else wants to see what might be the problem and open a PR to fix this -- I'd be happy to review such a PR.

ghost commented 7 years ago

Hello, at least with my Firefox (version 48.0.2) I was able to click links. I mean, isn't this package built on the same PDF.js project?

ghost commented 7 years ago

Now I found out, that the PDF-version in my Firefox is 1.4.258.

Edit: It seems that the version you're using is 1.3.146. I'll see if that's the problem.

ghost commented 7 years ago

It seems that if you wish to have such functionality, you should code it by yourself.

See here, files like annotation_layer_builder.js and pdf_link_service.js.

I am not familiar with this PDF.js project, but this is what it looks like to me. I have no time to look at this further, but hope this helps someone who has.

Thanks!

dpo commented 7 years ago

Just a comment: clicking on a link would be very useful and I would like to see that feature implemented as well, but for LaTeX documents, the user should be able to decide what happens when a link is clicked: follow the link, or sync with the LaTeX source file.

sherwoodinc commented 7 years ago

Note: reposting with my intended github user.

I also would like to have this feature. I might have some time to work on this (i.e. to procrastinate while writing my dissertation).

I have a question for @izuzak: Is it possible to reuse part the PDF.js web viewer (specifically the page viewer component)? It seems that it already implements everything needed to support any kind of links and annotations.

Currently, pdf-viewer has a PdfEditorView extending a basic ScrollView. It could extend PDFjs's PdfPageView... Of course, the pdf-viewer functionality already implemented would possibly need to be adapted... What do you think? Am I missing anything?

izuzak commented 7 years ago

Hey @sherwoodinc 👋

Is it possible to reuse part the PDF.js web viewer (specifically the page viewer component)?

I don't know -- I haven't looked into how PDF.js works more than what I needed to build the package as it is.

What do you think? Am I missing anything?

I wish I could give you a 👍 or 👎 on the idea, but I can't -- I just don't know because I haven't dug that deep into PDF.js. I think it should be possible, but I'm not sure. I guess the best way to get an answer would be to try and build it. Unfortunately, I just don't have the time to work on that right now, but would be neat if someone using the package would want to give it a shot. 🌟

marnen commented 6 years ago

I'd love to get this working, but it seems that PDF.js is so poorly documented and has such incomprehensible code that I don't even understand where to start.

@mkoske What are your references to annotation_layer_builder.js and pdf_link_service.js supposed to show? It's not clear to me that the annotation layer has anything to do with links, and I'm not sure that PDFLinkService is useful for anything but links in the same document.

It's really frustrating. Both here and in the PDF.js repository, there appears to be interest in links in a PDF file, but every time someone gets close to posting useful information on how such a thing might be implemented, the discussion ends.

dpo commented 6 years ago

The atom-latex package has a built-in PDF viewer with clickable links. I'm not sure how they did it but if you speak JavaScript (unlike me), you might be able to understand.

marnen commented 6 years ago

@dpo Thanks, that’s worth a look. I worry that they might have done something TeX-specific, but we’ll see.

marnen commented 6 years ago

@dpo Are you sure that atom-latex opens PDF files within Atom at all? I haven’t tried that package, but from issues such as https://github.com/thomasjo/atom-latex/issues/453, I gather that it uses an external PDF viewer. Am I wrong?

dpo commented 6 years ago

@marnen Yes, it opens in Atom. It's not an external PDF viewer.

dpo commented 6 years ago

I mean this one: https://atom.io/packages/atom-latex

marnen commented 6 years ago

@dpo Huh, OK. I'll take another look (I have no use for LaTeX and so have been reluctant to install a package for it). I certainly don't see where in the code it brings in a PDF viewer, so this should be interesting. :)

marnen commented 6 years ago

@dpo Wait, I see, different package: you meant https://github.com/James-Yu/Atom-LaTeX. OK, looking there.

marnen commented 6 years ago

Doubly interesting: that package also uses PDF.js, so perhaps we can ~steal~adapt a thing or two from it.

marnen commented 6 years ago

Looks like https://github.com/James-Yu/Atom-LaTeX/pull/94 will be a good starting point. I wonder if it's really that simple...

marnen commented 6 years ago

I can't get the PDF viewer in that package to work at all (and no errors are shown...). I'll keep looking at the implementation, but it looks like this package may do things very differently. Maybe it shouldn't; I'm not sure.

marnen commented 6 years ago

@sherwoodinc:

I have a question for @izuzak: Is it possible to reuse part the PDF.js web viewer (specifically the page viewer component)? It seems that it already implements everything needed to support any kind of links and annotations.

Sure looks like it should be. Maybe that's worth a try.

lumotroph commented 4 years ago

Bump! Need to have this working for the package to be really useful!