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

How can i open links to new tab / window #7779

Closed
azetutu opened this issue Nov 3, 2016 · 4 comments
Closed

How can i open links to new tab / window #7779

azetutu opened this issue Nov 3, 2016 · 4 comments

Comments

@azetutu
Copy link

azetutu commented Nov 3, 2016

Everything works fine but i cannot change behavior for links. I found LinkTarget in pdf.js file but how i supposed to change this string to get it really works?

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Nov 3, 2016

Since there's no information provided about how you're using PDF.js, e.g. just the API or the entire default viewer, the general approach for specifying the target attribute is to place e.g.

PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK;

somewhere before the PDFJS.getDocument(...) call in your code.
Please refer to global.js for a list of the possible values that PDFJS.externalLinkTarget accepts.

Closing as answered.

@mickberber
Copy link

I don't know if this helps anybody, but in a few examples in this repository PDFJSLIB.PDFLinkService is used to render links. Setting PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK; did not work with this implementation but the below code did.

    pdfLinkService = new PDFJSLIB.PDFLinkService({
      externalLinkTarget: 2
    });

@markusd1984
Copy link

markusd1984 commented Jun 12, 2018

@Snuffleupagus I tried

PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK;

instead of:

PDFJS.openExternalLinksInNewWindow = ( PDFJS.openExternalLinksInNewWindow === undefined ? false : PDFJS.openExternalLinksInNewWindow);

but unfortunately to no effect :( What else can I do to check or try?

Running Opigno LMS = Drupal 7 which uses /sites/all/libraries/pdf.js/build/pdf.js

UPDATE:
After I upgraded from pdf 7.x-1.9 to the current 7.x-1.x-dev version with drush and cleared the cache it is working now :)

Actually having removed it again it's still working, perhaps it's integrated in the new dev version of the drupal module.

@whxleemdddd
Copy link

whxleemdddd commented May 28, 2020

app.js:
let pdfLinkService = new PDFLinkService({ eventBus, externalLinkTarget: 2, externalLinkRel: AppOptions.get('externalLinkRel'), });

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

No branches or pull requests

5 participants