|
|
@ -105,17 +105,18 @@ var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; |
|
|
|
|
|
|
|
|
|
|
|
function configure(PDFJS) { |
|
|
|
function configure(PDFJS) { |
|
|
|
PDFJS.imageResourcesPath = './images/'; |
|
|
|
PDFJS.imageResourcesPath = './images/'; |
|
|
|
//#if (FIREFOX || MOZCENTRAL || GENERIC || CHROME)
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
//PDFJS.workerSrc = '../build/pdf.worker.js';
|
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL || GENERIC || CHROME')) { |
|
|
|
//#endif
|
|
|
|
PDFJS.workerSrc = '../build/pdf.worker.js'; |
|
|
|
//#if !PRODUCTION
|
|
|
|
} |
|
|
|
|
|
|
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) { |
|
|
|
PDFJS.cMapUrl = '../external/bcmaps/'; |
|
|
|
PDFJS.cMapUrl = '../external/bcmaps/'; |
|
|
|
PDFJS.cMapPacked = true; |
|
|
|
PDFJS.cMapPacked = true; |
|
|
|
PDFJS.workerSrc = '../src/worker_loader.js'; |
|
|
|
PDFJS.workerSrc = '../src/worker_loader.js'; |
|
|
|
//#else
|
|
|
|
} else { |
|
|
|
//PDFJS.cMapUrl = '../web/cmaps/';
|
|
|
|
PDFJS.cMapUrl = '../web/cmaps/'; |
|
|
|
//PDFJS.cMapPacked = true;
|
|
|
|
PDFJS.cMapPacked = true; |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var DefaultExernalServices = { |
|
|
|
var DefaultExernalServices = { |
|
|
@ -437,12 +438,13 @@ var PDFViewerApplication = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
get supportsFullscreen() { |
|
|
|
get supportsFullscreen() { |
|
|
|
//#if MOZCENTRAL
|
|
|
|
var support; |
|
|
|
// var support = document.fullscreenEnabled === true ||
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) { |
|
|
|
// document.mozFullScreenEnabled === true;
|
|
|
|
support = document.fullscreenEnabled === true || |
|
|
|
//#else
|
|
|
|
document.mozFullScreenEnabled === true; |
|
|
|
|
|
|
|
} else { |
|
|
|
var doc = document.documentElement; |
|
|
|
var doc = document.documentElement; |
|
|
|
var support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || |
|
|
|
support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || |
|
|
|
doc.webkitRequestFullScreen || doc.msRequestFullscreen); |
|
|
|
doc.webkitRequestFullScreen || doc.msRequestFullscreen); |
|
|
|
|
|
|
|
|
|
|
|
if (document.fullscreenEnabled === false || |
|
|
|
if (document.fullscreenEnabled === false || |
|
|
@ -451,7 +453,7 @@ var PDFViewerApplication = { |
|
|
|
document.msFullscreenEnabled === false) { |
|
|
|
document.msFullscreenEnabled === false) { |
|
|
|
support = false; |
|
|
|
support = false; |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
if (support && pdfjsLib.PDFJS.disableFullscreen === true) { |
|
|
|
if (support && pdfjsLib.PDFJS.disableFullscreen === true) { |
|
|
|
support = false; |
|
|
|
support = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -481,8 +483,9 @@ var PDFViewerApplication = { |
|
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys; |
|
|
|
return this.externalServices.supportedMouseWheelZoomModifierKeys; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//#if (FIREFOX || MOZCENTRAL || CHROME)
|
|
|
|
|
|
|
|
initPassiveLoading: function pdfViewInitPassiveLoading() { |
|
|
|
initPassiveLoading: function pdfViewInitPassiveLoading() { |
|
|
|
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
|
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) { |
|
|
|
this.externalServices.initPassiveLoading({ |
|
|
|
this.externalServices.initPassiveLoading({ |
|
|
|
onOpenWithTransport: function (url, length, transport) { |
|
|
|
onOpenWithTransport: function (url, length, transport) { |
|
|
|
PDFViewerApplication.open(url, {range: transport}); |
|
|
|
PDFViewerApplication.open(url, {range: transport}); |
|
|
@ -512,8 +515,10 @@ var PDFViewerApplication = { |
|
|
|
PDFViewerApplication.progress(loaded / total); |
|
|
|
PDFViewerApplication.progress(loaded / total); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new Error('Not implemented: initPassiveLoading'); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { |
|
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { |
|
|
|
this.url = url; |
|
|
|
this.url = url; |
|
|
@ -584,12 +589,11 @@ var PDFViewerApplication = { |
|
|
|
* is opened. |
|
|
|
* is opened. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
open: function pdfViewOpen(file, args) { |
|
|
|
open: function pdfViewOpen(file, args) { |
|
|
|
//#if GENERIC
|
|
|
|
if ((typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) && |
|
|
|
if (arguments.length > 2 || typeof args === 'number') { |
|
|
|
(arguments.length > 2 || typeof args === 'number')) { |
|
|
|
return Promise.reject( |
|
|
|
return Promise.reject( |
|
|
|
new Error('Call of open() with obsolete signature.')); |
|
|
|
new Error('Call of open() with obsolete signature.')); |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
|
|
|
|
if (this.pdfLoadingTask) { |
|
|
|
if (this.pdfLoadingTask) { |
|
|
|
// We need to destroy already opened document.
|
|
|
|
// We need to destroy already opened document.
|
|
|
|
return this.close().then(function () { |
|
|
|
return this.close().then(function () { |
|
|
@ -707,12 +711,8 @@ var PDFViewerApplication = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
fallback: function pdfViewFallback(featureId) { |
|
|
|
fallback: function pdfViewFallback(featureId) { |
|
|
|
//#if !PRODUCTION
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (true) { |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
|
|
|
|
// Only trigger the fallback once so we don't spam the user with messages
|
|
|
|
// Only trigger the fallback once so we don't spam the user with messages
|
|
|
|
// for one PDF.
|
|
|
|
// for one PDF.
|
|
|
|
if (this.fellback) { |
|
|
|
if (this.fellback) { |
|
|
@ -727,7 +727,7 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
PDFViewerApplication.download(); |
|
|
|
PDFViewerApplication.download(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -763,7 +763,8 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//#if !(FIREFOX || MOZCENTRAL)
|
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
|
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
var errorWrapperConfig = this.appConfig.errorWrapper; |
|
|
|
var errorWrapperConfig = this.appConfig.errorWrapper; |
|
|
|
var errorWrapper = errorWrapperConfig.container; |
|
|
|
var errorWrapper = errorWrapperConfig.container; |
|
|
|
errorWrapper.removeAttribute('hidden'); |
|
|
|
errorWrapper.removeAttribute('hidden'); |
|
|
@ -796,10 +797,10 @@ var PDFViewerApplication = { |
|
|
|
moreInfoButton.removeAttribute('hidden'); |
|
|
|
moreInfoButton.removeAttribute('hidden'); |
|
|
|
lessInfoButton.setAttribute('hidden', 'true'); |
|
|
|
lessInfoButton.setAttribute('hidden', 'true'); |
|
|
|
errorMoreInfo.value = moreInfoText; |
|
|
|
errorMoreInfo.value = moreInfoText; |
|
|
|
//#else
|
|
|
|
} else { |
|
|
|
// console.error(message + '\n' + moreInfoText);
|
|
|
|
console.error(message + '\n' + moreInfoText); |
|
|
|
// this.fallback();
|
|
|
|
this.fallback(); |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
progress: function pdfViewProgress(level) { |
|
|
|
progress: function pdfViewProgress(level) { |
|
|
@ -851,15 +852,14 @@ var PDFViewerApplication = { |
|
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint; |
|
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint; |
|
|
|
var store = this.store = new ViewHistory(id); |
|
|
|
var store = this.store = new ViewHistory(id); |
|
|
|
|
|
|
|
|
|
|
|
//#if GENERIC
|
|
|
|
var baseDocumentUrl; |
|
|
|
var baseDocumentUrl = null; |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
//#endif
|
|
|
|
baseDocumentUrl = null; |
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
// var baseDocumentUrl = this.url.split('#')[0];
|
|
|
|
baseDocumentUrl = this.url.split('#')[0]; |
|
|
|
//#endif
|
|
|
|
} else if (PDFJSDev.test('CHROME')) { |
|
|
|
//#if CHROME
|
|
|
|
baseDocumentUrl = location.href.split('#')[0]; |
|
|
|
// var baseDocumentUrl = location.href.split('#')[0];
|
|
|
|
} |
|
|
|
//#endif
|
|
|
|
|
|
|
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl); |
|
|
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl); |
|
|
|
|
|
|
|
|
|
|
|
var pdfViewer = this.pdfViewer; |
|
|
|
var pdfViewer = this.pdfViewer; |
|
|
@ -1017,12 +1017,8 @@ var PDFViewerApplication = { |
|
|
|
self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.forms); |
|
|
|
self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.forms); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//#if !PRODUCTION
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (true) { |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
|
|
|
|
var versionId = String(info.PDFFormatVersion).slice(-1) | 0; |
|
|
|
var versionId = String(info.PDFFormatVersion).slice(-1) | 0; |
|
|
|
var generatorId = 0; |
|
|
|
var generatorId = 0; |
|
|
|
var KNOWN_GENERATORS = [ |
|
|
|
var KNOWN_GENERATORS = [ |
|
|
@ -1049,7 +1045,7 @@ var PDFViewerApplication = { |
|
|
|
generator: generatorId, |
|
|
|
generator: generatorId, |
|
|
|
formType: formType |
|
|
|
formType: formType |
|
|
|
}); |
|
|
|
}); |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -1132,16 +1128,12 @@ var PDFViewerApplication = { |
|
|
|
|
|
|
|
|
|
|
|
printService.layout(); |
|
|
|
printService.layout(); |
|
|
|
|
|
|
|
|
|
|
|
//#if !PRODUCTION
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (true) { |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
|
|
|
|
this.externalServices.reportTelemetry({ |
|
|
|
this.externalServices.reportTelemetry({ |
|
|
|
type: 'print' |
|
|
|
type: 'print' |
|
|
|
}); |
|
|
|
}); |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// Whether all pages of the PDF have the same width and height.
|
|
|
|
// Whether all pages of the PDF have the same width and height.
|
|
|
@ -1272,16 +1264,17 @@ var PDFViewerApplication = { |
|
|
|
eventBus.on('documentproperties', webViewerDocumentProperties); |
|
|
|
eventBus.on('documentproperties', webViewerDocumentProperties); |
|
|
|
eventBus.on('find', webViewerFind); |
|
|
|
eventBus.on('find', webViewerFind); |
|
|
|
eventBus.on('findfromurlhash', webViewerFindFromUrlHash); |
|
|
|
eventBus.on('findfromurlhash', webViewerFindFromUrlHash); |
|
|
|
//#if GENERIC
|
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
eventBus.on('fileinputchange', webViewerFileInputChange); |
|
|
|
eventBus.on('fileinputchange', webViewerFileInputChange); |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
//#if GENERIC
|
|
|
|
var validateFileURL; |
|
|
|
var HOSTED_VIEWER_ORIGINS = ['null', |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
|
|
|
|
var HOSTED_VIEWER_ORIGINS = ['null', |
|
|
|
'http://mozilla.github.io', 'https://mozilla.github.io']; |
|
|
|
'http://mozilla.github.io', 'https://mozilla.github.io']; |
|
|
|
function validateFileURL(file) { |
|
|
|
validateFileURL = function validateFileURL(file) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
var viewerOrigin = new URL(window.location.href).origin || 'null'; |
|
|
|
var viewerOrigin = new URL(window.location.href).origin || 'null'; |
|
|
|
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) { |
|
|
|
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) { |
|
|
@ -1306,8 +1299,8 @@ function validateFileURL(file) { |
|
|
|
PDFViewerApplication.error(loadingErrorMessage, moreInfo); |
|
|
|
PDFViewerApplication.error(loadingErrorMessage, moreInfo); |
|
|
|
throw e; |
|
|
|
throw e; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadAndEnablePDFBug(enabledTabs) { |
|
|
|
function loadAndEnablePDFBug(enabledTabs) { |
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
return new Promise(function (resolve, reject) { |
|
|
@ -1328,22 +1321,21 @@ function loadAndEnablePDFBug(enabledTabs) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerInitialized() { |
|
|
|
function webViewerInitialized() { |
|
|
|
//#if GENERIC
|
|
|
|
var file; |
|
|
|
|
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
var queryString = document.location.search.substring(1); |
|
|
|
var queryString = document.location.search.substring(1); |
|
|
|
var params = parseQueryString(queryString); |
|
|
|
var params = parseQueryString(queryString); |
|
|
|
var file = 'file' in params ? params.file : DEFAULT_URL; |
|
|
|
file = 'file' in params ? params.file : DEFAULT_URL; |
|
|
|
validateFileURL(file); |
|
|
|
validateFileURL(file); |
|
|
|
//#endif
|
|
|
|
} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
file = window.location.href.split('#')[0]; |
|
|
|
//var file = window.location.href.split('#')[0];
|
|
|
|
} else if (PDFJSDev.test('CHROME')) { |
|
|
|
//#endif
|
|
|
|
file = DEFAULT_URL; |
|
|
|
//#if CHROME
|
|
|
|
} |
|
|
|
//var file = DEFAULT_URL;
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var waitForBeforeOpening = []; |
|
|
|
var waitForBeforeOpening = []; |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
//#if GENERIC
|
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
var fileInput = document.createElement('input'); |
|
|
|
var fileInput = document.createElement('input'); |
|
|
|
fileInput.id = appConfig.openFileInputName; |
|
|
|
fileInput.id = appConfig.openFileInputName; |
|
|
|
fileInput.className = 'fileInput'; |
|
|
|
fileInput.className = 'fileInput'; |
|
|
@ -1351,25 +1343,22 @@ function webViewerInitialized() { |
|
|
|
fileInput.oncontextmenu = noContextMenuHandler; |
|
|
|
fileInput.oncontextmenu = noContextMenuHandler; |
|
|
|
document.body.appendChild(fileInput); |
|
|
|
document.body.appendChild(fileInput); |
|
|
|
|
|
|
|
|
|
|
|
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) { |
|
|
|
if (!window.File || !window.FileReader || |
|
|
|
|
|
|
|
!window.FileList || !window.Blob) { |
|
|
|
appConfig.toolbar.openFile.setAttribute('hidden', 'true'); |
|
|
|
appConfig.toolbar.openFile.setAttribute('hidden', 'true'); |
|
|
|
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true'); |
|
|
|
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
fileInput.value = null; |
|
|
|
fileInput.value = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
//#else
|
|
|
|
appConfig.toolbar.openFile.setAttribute('hidden', 'true'); |
|
|
|
//appConfig.toolbar.openFile.setAttribute('hidden', 'true');
|
|
|
|
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true'); |
|
|
|
//appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
|
|
|
|
} |
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var PDFJS = pdfjsLib.PDFJS; |
|
|
|
var PDFJS = pdfjsLib.PDFJS; |
|
|
|
|
|
|
|
|
|
|
|
//#if !PRODUCTION
|
|
|
|
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) || |
|
|
|
if (true) { |
|
|
|
PDFViewerApplication.preferencePdfBugEnabled) { |
|
|
|
//#else
|
|
|
|
|
|
|
|
//if (PDFViewerApplication.preferencePdfBugEnabled) {
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
// Special debugging flags in the hash section of the URL.
|
|
|
|
// Special debugging flags in the hash section of the URL.
|
|
|
|
var hash = document.location.hash.substring(1); |
|
|
|
var hash = document.location.hash.substring(1); |
|
|
|
var hashParams = parseQueryString(hash); |
|
|
|
var hashParams = parseQueryString(hash); |
|
|
@ -1405,17 +1394,18 @@ function webViewerInitialized() { |
|
|
|
PDFJS.ignoreCurrentPositionOnZoom = |
|
|
|
PDFJS.ignoreCurrentPositionOnZoom = |
|
|
|
(hashParams['ignorecurrentpositiononzoom'] === 'true'); |
|
|
|
(hashParams['ignorecurrentpositiononzoom'] === 'true'); |
|
|
|
} |
|
|
|
} |
|
|
|
//#if !PRODUCTION
|
|
|
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) { |
|
|
|
if ('disablebcmaps' in hashParams && hashParams['disablebcmaps']) { |
|
|
|
if ('disablebcmaps' in hashParams && hashParams['disablebcmaps']) { |
|
|
|
PDFJS.cMapUrl = '../external/cmaps/'; |
|
|
|
PDFJS.cMapUrl = '../external/cmaps/'; |
|
|
|
PDFJS.cMapPacked = false; |
|
|
|
PDFJS.cMapPacked = false; |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
//#if !(FIREFOX || MOZCENTRAL)
|
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
|
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
if ('locale' in hashParams) { |
|
|
|
if ('locale' in hashParams) { |
|
|
|
PDFJS.locale = hashParams['locale']; |
|
|
|
PDFJS.locale = hashParams['locale']; |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
if ('textlayer' in hashParams) { |
|
|
|
if ('textlayer' in hashParams) { |
|
|
|
switch (hashParams['textlayer']) { |
|
|
|
switch (hashParams['textlayer']) { |
|
|
|
case 'off': |
|
|
|
case 'off': |
|
|
@ -1437,16 +1427,16 @@ function webViewerInitialized() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//#if !(FIREFOX || MOZCENTRAL)
|
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
|
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
mozL10n.setLanguage(PDFJS.locale); |
|
|
|
mozL10n.setLanguage(PDFJS.locale); |
|
|
|
//#endif
|
|
|
|
} else { |
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
|
|
|
|
if (!PDFViewerApplication.supportsDocumentFonts) { |
|
|
|
if (!PDFViewerApplication.supportsDocumentFonts) { |
|
|
|
PDFJS.disableFontFace = true; |
|
|
|
PDFJS.disableFontFace = true; |
|
|
|
console.warn(mozL10n.get('web_fonts_disabled', null, |
|
|
|
console.warn(mozL10n.get('web_fonts_disabled', null, |
|
|
|
'Web fonts are disabled: unable to use embedded PDF fonts.')); |
|
|
|
'Web fonts are disabled: unable to use embedded PDF fonts.')); |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!PDFViewerApplication.supportsPrinting) { |
|
|
|
if (!PDFViewerApplication.supportsPrinting) { |
|
|
|
appConfig.toolbar.print.classList.add('hidden'); |
|
|
|
appConfig.toolbar.print.classList.add('hidden'); |
|
|
@ -1539,8 +1529,9 @@ function webViewerInitialized() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//#if GENERIC
|
|
|
|
var webViewerOpenFileViaURL; |
|
|
|
function webViewerOpenFileViaURL(file) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
|
|
|
|
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { |
|
|
|
if (file && file.lastIndexOf('file:', 0) === 0) { |
|
|
|
if (file && file.lastIndexOf('file:', 0) === 0) { |
|
|
|
// file:-scheme. Load the contents in the main thread because QtWebKit
|
|
|
|
// file:-scheme. Load the contents in the main thread because QtWebKit
|
|
|
|
// cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
|
|
|
|
// cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
|
|
|
@ -1564,19 +1555,19 @@ function webViewerOpenFileViaURL(file) { |
|
|
|
if (file) { |
|
|
|
if (file) { |
|
|
|
PDFViewerApplication.open(file); |
|
|
|
PDFViewerApplication.open(file); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) { |
|
|
|
|
|
|
|
webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) { |
|
|
|
|
|
|
|
PDFViewerApplication.setTitleUsingUrl(file); |
|
|
|
|
|
|
|
PDFViewerApplication.initPassiveLoading(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
webViewerOpenFileViaURL = function webViewerOpenFileURL(file) { |
|
|
|
|
|
|
|
if (file) { |
|
|
|
|
|
|
|
throw new Error('Not implemented: webViewerOpenFileURL'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
//#elif (FIREFOX || MOZCENTRAL || CHROME)
|
|
|
|
|
|
|
|
//function webViewerOpenFileViaURL(file) {
|
|
|
|
|
|
|
|
// PDFViewerApplication.setTitleUsingUrl(file);
|
|
|
|
|
|
|
|
// PDFViewerApplication.initPassiveLoading();
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//#else
|
|
|
|
|
|
|
|
//function webViewerOpenFileURL(file) {
|
|
|
|
|
|
|
|
// if (file) {
|
|
|
|
|
|
|
|
// throw new Error('Not implemented: webViewerOpenFileURL');
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function webViewerPageRendered(e) { |
|
|
|
function webViewerPageRendered(e) { |
|
|
|
var pageNumber = e.pageNumber; |
|
|
|
var pageNumber = e.pageNumber; |
|
|
@ -1612,12 +1603,8 @@ function webViewerPageRendered(e) { |
|
|
|
'An error occurred while rendering the page.'), pageView.error); |
|
|
|
'An error occurred while rendering the page.'), pageView.error); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//#if !PRODUCTION
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (true) { |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
|
|
|
|
PDFViewerApplication.externalServices.reportTelemetry({ |
|
|
|
PDFViewerApplication.externalServices.reportTelemetry({ |
|
|
|
type: 'pageInfo' |
|
|
|
type: 'pageInfo' |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1628,24 +1615,19 @@ function webViewerPageRendered(e) { |
|
|
|
stats: stats |
|
|
|
stats: stats |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerTextLayerRendered(e) { |
|
|
|
function webViewerTextLayerRendered(e) { |
|
|
|
//#if !PRODUCTION
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (true) { |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL') && |
|
|
|
return; |
|
|
|
e.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) { |
|
|
|
} |
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
|
|
|
|
if (e.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) { |
|
|
|
|
|
|
|
console.error(mozL10n.get('document_colors_not_allowed', null, |
|
|
|
console.error(mozL10n.get('document_colors_not_allowed', null, |
|
|
|
'PDF documents are not allowed to use their own colors: ' + |
|
|
|
'PDF documents are not allowed to use their own colors: ' + |
|
|
|
'\'Allow pages to choose their own colors\' ' + |
|
|
|
'\'Allow pages to choose their own colors\' ' + |
|
|
|
'is deactivated in the browser.')); |
|
|
|
'is deactivated in the browser.')); |
|
|
|
PDFViewerApplication.fallback(); |
|
|
|
PDFViewerApplication.fallback(); |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function webViewerPageMode(e) { |
|
|
|
function webViewerPageMode(e) { |
|
|
@ -1803,17 +1785,18 @@ function webViewerHashchange(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//#if GENERIC
|
|
|
|
var webViewerFileInputChange; |
|
|
|
window.addEventListener('change', function webViewerChange(evt) { |
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
|
|
|
|
window.addEventListener('change', function webViewerChange(evt) { |
|
|
|
var files = evt.target.files; |
|
|
|
var files = evt.target.files; |
|
|
|
if (!files || files.length === 0) { |
|
|
|
if (!files || files.length === 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
PDFViewerApplication.eventBus.dispatch('fileinputchange', |
|
|
|
PDFViewerApplication.eventBus.dispatch('fileinputchange', |
|
|
|
{fileInput: evt.target}); |
|
|
|
{fileInput: evt.target}); |
|
|
|
}, true); |
|
|
|
}, true); |
|
|
|
|
|
|
|
|
|
|
|
function webViewerFileInputChange(e) { |
|
|
|
webViewerFileInputChange = function webViewerFileInputChange(e) { |
|
|
|
var file = e.fileInput.files[0]; |
|
|
|
var file = e.fileInput.files[0]; |
|
|
|
|
|
|
|
|
|
|
|
if (!pdfjsLib.PDFJS.disableCreateObjectURL && |
|
|
|
if (!pdfjsLib.PDFJS.disableCreateObjectURL && |
|
|
@ -1835,11 +1818,12 @@ function webViewerFileInputChange(e) { |
|
|
|
// URL does not reflect proper document location - hiding some icons.
|
|
|
|
// URL does not reflect proper document location - hiding some icons.
|
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
var appConfig = PDFViewerApplication.appConfig; |
|
|
|
appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true'); |
|
|
|
appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true'); |
|
|
|
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true'); |
|
|
|
appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', |
|
|
|
|
|
|
|
'true'); |
|
|
|
appConfig.toolbar.download.setAttribute('hidden', 'true'); |
|
|
|
appConfig.toolbar.download.setAttribute('hidden', 'true'); |
|
|
|
appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true'); |
|
|
|
appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true'); |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('localized', function localized(evt) { |
|
|
|
window.addEventListener('localized', function localized(evt) { |
|
|
|
PDFViewerApplication.eventBus.dispatch('localized'); |
|
|
|
PDFViewerApplication.eventBus.dispatch('localized'); |
|
|
@ -2091,7 +2075,8 @@ window.addEventListener('keydown', function keydown(evt) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//#if !(FIREFOX || MOZCENTRAL)
|
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
|
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
// CTRL or META without shift
|
|
|
|
// CTRL or META without shift
|
|
|
|
if (cmd === 1 || cmd === 8) { |
|
|
|
if (cmd === 1 || cmd === 8) { |
|
|
|
switch (evt.keyCode) { |
|
|
|
switch (evt.keyCode) { |
|
|
@ -2101,7 +2086,7 @@ window.addEventListener('keydown', function keydown(evt) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//#endif
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CTRL+ALT or Option+Command
|
|
|
|
// CTRL+ALT or Option+Command
|
|
|
|
if (cmd === 3 || cmd === 10) { |
|
|
|
if (cmd === 3 || cmd === 10) { |
|
|
|