mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.33k stars 9.97k forks source link

Seems links with target="_blank" do not work anymore? #3812

Closed DanielRuf closed 8 years ago

DanielRuf commented 11 years ago

The target attribute is missing in the latest version but in LibreOffice and the generated PDF the links have the target attribute.

Was this removed? Or is this a Google Chrome bug?

timvandermeij commented 11 years ago

I have noticed this too (that links do not open in a new window) in another PDF, however I'm not sure if that worked before or if we just don't handle this correctly...

Snuffleupagus commented 11 years ago

Based on this comment: https://github.com/mozilla/pdf.js/blob/master/src/shared/annotation.js#L636, I would say that it has never worked.

sriram-dev commented 11 years ago

Is it better to have every link(URL's) to be opened in new tab ? Will that default behavior be better than opening it in the same tab and thereby disrupting reading/viewing the document

DanielRuf commented 11 years ago

This is exactly what I meant (target=_blank not used in the PDF). I have the same opinion, it would be much better to open (external) links in new tabs.

sriram-dev commented 11 years ago

@yurydelendik @brendandahl : your opinion on this issue ? can opening links in new tab be made the default behavior ?

timvandermeij commented 11 years ago

I also think that opening links in a new tab (target="_blank") is better.

yurydelendik commented 11 years ago

http://irclog.gr/#show/irc.mozilla.org/pdfjs/73479

DanielRuf commented 11 years ago

Yes, I've seen this. http://irclog.gr/#show/irc.mozilla.org/pdfjs/73494 But I have set the target as _blank in LibreOffice

It seems weird, that also the PDF file in Chrome does not open links in new tab but in the same tab if opened directly in the browser.

Snuffleupagus commented 11 years ago

You can use this nice tool to browse the structure of a PDF file: http://brendandahl.github.io/pdf.js.utils/browser/. Using that to open the file, I cannot find any references to target='_blank' or anything else that would case that behaviour. Just because it works in LibreOffice, that doesn't mean that the generated PDF file behaves the same way.

Snuffleupagus commented 11 years ago

Again, please note that there is no mentioning of this in the actual PDF file.

Snuffleupagus commented 11 years ago

As far as I'm reading the PDF specification1, there is no support for opening in a new window with URI actions (section 12.6.4.7). There is however an optional newWindow parameter for GoToR actions (section 12.6.4.3), but PDF.js doesn't implement this.

@DanielRuf Your files all have links of the URI kind, so based on the specification I don't believe that this will ever work like you seem to want. Even if we implement GoToR action properly, this will unfortunately not help with your files!

[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf

DanielRuf commented 11 years ago

So, all this is just handled by the application where the PDF file is displayed so this will never change and is not a bug but feature?

Good to know that they did not add this to the specification =(

timvandermeij commented 11 years ago

Reopened because opening external links in a new tab seems really useful to me. If this is not wanted as default behaviour, I think we should really at least add a preference to do so.

Snuffleupagus commented 11 years ago

Reopened because opening external links in a new tab seems really useful to me.

Or you could just either middle-click or use the context menu for this functionality, just as you would on any website.

timvandermeij commented 11 years ago

Sure, but I think it's quite tedious to constantly use the context menu to open links in a new tab. I don't think adding a simple preference for this would hurt UX. Note that I'm not saying it should be default behaviour, but just adding a preference to do it would help a lot. :-)

This can of course be done at a later time when preferences are implemented.

aseemsharma16 commented 10 years ago

Any Updates on this issue? External links not working.

timvandermeij commented 10 years ago

Not really. This will probably have to wait until #3850 lands.

yurydelendik commented 10 years ago

Similar discussion at https://groups.google.com/forum/#!topic/mozilla.dev.pdf-js/miBFrMR1DIE

yurydelendik commented 10 years ago

Can somebody submit the link to a test PDF document with action that has NewWindow attribute? OpenOffice exports PDFs without such information.