Closed alexshtf closed 5 years ago
Hi. I'd like to work on this feature for pdf.js.
However, I'm not overly familiar with the code base or API.
Does the API have the functionality to have an iframe load a URL? I guess I'm wondering what is a good starting place for this?
There is nothing in PDF.js so far to help with this feature. I think this would have to be implemented from scratch. Each link is an annotation of type Link
, so perhaps you could add an iframe on hover, much like how the Text
annotations work. However, I think an iframe is not the best solution, both for security and usability. An image render would be much better, but I'm not sure how easy or difficult that is to implement.
Could the following js library be used to accomplish this? rasterizeHTML.js
That looks like a better solution to me, yes.
There are internal links, that point to some destination inside the same PDF, and external. I think the latter shall not have a preview (and act like a hyperlink on a regular web page). Internal link point to some place on a PDF page -- the PDF.js render capabilities can be used to generate the required preview.
How does PDF.js differenctiate between internal and external links? Would I modify the link annotations to achieve this from within PDF.js itself? If not than which file would I look at?
Okay so inpecting a page loaded with a PDF that has both link types, I saw that it uses the annotLink
class to specify a link and the internalLink
class to differentiate between the links types.
So I'm thinking that I should have a toggle avalaibel to enable preview on hover and then create a PDFPreviewer like the var PDFViewerApplication
in the viewer.js.
I'd suggest closing this as WONTFIX, for a number of reasons:
FitR
type, which aren't very common in practice, rendering only the relevant section is basically impossible and the only thing that could be done is to display a preview of the entire page (which I assume would be quite pointless here).Hi @Snuffleupagus , thanks for your explanation. I am also very interested in this feature but I am only interested in previewing hyperlinks for bibliography. Could you please give some hints if I would like to implement this via Chrome Extension with javascript?
This would be a valuable feature for an implementation of PDF.js that is specialized for science papers. @mbbaig, @haichaoyu - wanna brainstorm about this?
I think a simple tooltip, like Tooltip.js would not be horrible for performance sake. However, I think that already the features discussed are out of scope of a general pdf reader, and we may want to take the discussion to a more specialized context.
Allow me to propose some cope creep: only a small minority of science papers have internal links for their in-body citations (let alone cross-references). A more broadly applicable solution would parse in text citations and let us "peek" at their associated bibliography items. I'd like to propose that as a parallel goal. Luckily there are tools and services that do this (see Resources, below). For inspiration, I think we can look at Readcube, a proprietary science paper reader that decorates papers with mouse over bibliographic tooltips.
Note: 'links' refer to hyperlinks (with either internal or external target) present in the pdf, while 'references' are in-text citations of bibliography items, or cross-references to footnotes, tables, figures, and so on.
Extraction tools like Crossref's pdfextract(retired, Cermine, Grobid or Zotero's Recognizer Server - would help identify and extract relevant text from bibliographic entities and in text references.
Citation matching tools like EXmatcher would let tooltips present external paper links, citation metrics, and abstracts.
pdf.js-hypothes.is - pdf.js distribution that supports collaborative research annotation. Perhaps a good jumping off point. They need help!
In general, processing PDF references in this way is a little heavy - we may need to build a server runtime to host the context detector, extractor, and formatter. Processing documents with links could be much lighter. A possible approach would be to convert unlinked documents into linked documents via a server, and simply render the link metadata in the viewer.
Other suggestions and input welcome! This issue is almost certainly the wrong place to discuss this - feel free to reach out to me or suggest a new forum :)
@maxsu @haichaoyu I would also be very interested in such a feature; did you discuss it further?
I have been reading a lot of scientific papers lately, and I would like to be able to see a small popup with the linked content when I hover over a PDF link. Usually, when there is a link to an equation of a theorem I don't want to go there, I just want a short reminder and continue reading. I believe that many people who read scientific papers would benefit.
It is something similar to Visual Studio's Peek Definition feature (http://channel9.msdn.com/Series/Visual-Studio-2012-Premium-and-Ultimate-Overview/Peek-Definition)