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?
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.
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
});
@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.
app.js:
let pdfLinkService = new PDFLinkService({
eventBus,
externalLinkTarget: 2,
externalLinkRel: AppOptions.get('externalLinkRel'),
});
Most helpful comment
I don't know if this helps anybody, but in a few examples in this repository
PDFJSLIB.PDFLinkService
is used to render links. SettingPDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK;
did not work with this implementation but the below code did.