|
|
@ -15,8 +15,8 @@ |
|
|
|
/* globals PDFBug, Stats */ |
|
|
|
/* globals PDFBug, Stats */ |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, localized, |
|
|
|
animationStarted, DEFAULT_SCALE_VALUE, getPDFFileNameFromURL, MAX_SCALE, |
|
|
|
MAX_SCALE, MIN_SCALE, mozL10n, noContextMenuHandler, normalizeWheelEventDelta, |
|
|
|
MIN_SCALE, noContextMenuHandler, normalizeWheelEventDelta, |
|
|
|
parseQueryString, ProgressBar, RendererType, UNKNOWN_SCALE |
|
|
|
parseQueryString, ProgressBar, RendererType, UNKNOWN_SCALE |
|
|
|
} from './ui_utils'; |
|
|
|
} from './ui_utils'; |
|
|
|
import { |
|
|
|
import { |
|
|
@ -129,6 +129,8 @@ var PDFViewerApplication = { |
|
|
|
secondaryToolbar: null, |
|
|
|
secondaryToolbar: null, |
|
|
|
/** @type {EventBus} */ |
|
|
|
/** @type {EventBus} */ |
|
|
|
eventBus: null, |
|
|
|
eventBus: null, |
|
|
|
|
|
|
|
/** @type {IL10n} */ |
|
|
|
|
|
|
|
l10n: null, |
|
|
|
pageRotation: 0, |
|
|
|
pageRotation: 0, |
|
|
|
isInitialViewSet: false, |
|
|
|
isInitialViewSet: false, |
|
|
|
viewerPrefs: { |
|
|
|
viewerPrefs: { |
|
|
@ -155,6 +157,8 @@ var PDFViewerApplication = { |
|
|
|
this.appConfig = appConfig; |
|
|
|
this.appConfig = appConfig; |
|
|
|
|
|
|
|
|
|
|
|
return this._readPreferences().then(() => { |
|
|
|
return this._readPreferences().then(() => { |
|
|
|
|
|
|
|
return this._initializeL10n(); |
|
|
|
|
|
|
|
}).then(() => { |
|
|
|
return this._initializeViewerComponents(); |
|
|
|
return this._initializeViewerComponents(); |
|
|
|
}).then(() => { |
|
|
|
}).then(() => { |
|
|
|
// Bind the various event handlers *after* the viewer has been
|
|
|
|
// Bind the various event handlers *after* the viewer has been
|
|
|
@ -162,13 +166,13 @@ var PDFViewerApplication = { |
|
|
|
this.bindEvents(); |
|
|
|
this.bindEvents(); |
|
|
|
this.bindWindowEvents(); |
|
|
|
this.bindWindowEvents(); |
|
|
|
|
|
|
|
|
|
|
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
// We can start UI localization now.
|
|
|
|
// For backwards compatibility, we dispatch the 'localized' event on
|
|
|
|
var appContainer = appConfig.appContainer || document.documentElement; |
|
|
|
// the `eventBus` once the viewer has been initialized.
|
|
|
|
this.l10n.translate(appContainer).then(() => { |
|
|
|
localized.then(() => { |
|
|
|
// Dispatch the 'localized' event on the `eventBus` once the viewer
|
|
|
|
|
|
|
|
// has been fully initialized and translated.
|
|
|
|
this.eventBus.dispatch('localized'); |
|
|
|
this.eventBus.dispatch('localized'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.isViewerEmbedded && !PDFJS.isExternalLinkTargetSet()) { |
|
|
|
if (this.isViewerEmbedded && !PDFJS.isExternalLinkTargetSet()) { |
|
|
|
// Prevent external links from "replacing" the viewer,
|
|
|
|
// Prevent external links from "replacing" the viewer,
|
|
|
@ -256,6 +260,25 @@ var PDFViewerApplication = { |
|
|
|
]).catch(function (reason) { }); |
|
|
|
]).catch(function (reason) { }); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_initializeL10n() { |
|
|
|
|
|
|
|
// Locale can be changed only when special debugging flags is present in
|
|
|
|
|
|
|
|
// the hash section of the URL, or development version of viewer is used.
|
|
|
|
|
|
|
|
// It is not possible to change locale for Firefox extension builds.
|
|
|
|
|
|
|
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') || |
|
|
|
|
|
|
|
(!PDFJSDev.test('FIREFOX || MOZCENTRAL') && |
|
|
|
|
|
|
|
this.viewerPrefs['pdfBugEnabled'])) { |
|
|
|
|
|
|
|
let hash = document.location.hash.substring(1); |
|
|
|
|
|
|
|
let hashParams = parseQueryString(hash); |
|
|
|
|
|
|
|
if ('locale' in hashParams) { |
|
|
|
|
|
|
|
PDFJS.locale = hashParams['locale']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.l10n = this.externalServices.createL10n(); |
|
|
|
|
|
|
|
return this.l10n.getDirection().then((dir) => { |
|
|
|
|
|
|
|
document.getElementsByTagName('html')[0].dir = dir; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @private |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -290,6 +313,7 @@ var PDFViewerApplication = { |
|
|
|
linkService: pdfLinkService, |
|
|
|
linkService: pdfLinkService, |
|
|
|
downloadManager, |
|
|
|
downloadManager, |
|
|
|
renderer: this.viewerPrefs['renderer'], |
|
|
|
renderer: this.viewerPrefs['renderer'], |
|
|
|
|
|
|
|
l10n: this.l10n, |
|
|
|
enhanceTextSelection: this.viewerPrefs['enhanceTextSelection'], |
|
|
|
enhanceTextSelection: this.viewerPrefs['enhanceTextSelection'], |
|
|
|
renderInteractiveForms: this.viewerPrefs['renderInteractiveForms'], |
|
|
|
renderInteractiveForms: this.viewerPrefs['renderInteractiveForms'], |
|
|
|
enablePrintAutoRotate: this.viewerPrefs['enablePrintAutoRotate'], |
|
|
|
enablePrintAutoRotate: this.viewerPrefs['enablePrintAutoRotate'], |
|
|
@ -302,6 +326,7 @@ var PDFViewerApplication = { |
|
|
|
container: thumbnailContainer, |
|
|
|
container: thumbnailContainer, |
|
|
|
renderingQueue: pdfRenderingQueue, |
|
|
|
renderingQueue: pdfRenderingQueue, |
|
|
|
linkService: pdfLinkService, |
|
|
|
linkService: pdfLinkService, |
|
|
|
|
|
|
|
l10n: this.l10n |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); |
|
|
|
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); |
|
|
|
|
|
|
|
|
|
|
@ -337,11 +362,11 @@ var PDFViewerApplication = { |
|
|
|
let findBarConfig = Object.create(appConfig.findBar); |
|
|
|
let findBarConfig = Object.create(appConfig.findBar); |
|
|
|
findBarConfig.findController = this.findController; |
|
|
|
findBarConfig.findController = this.findController; |
|
|
|
findBarConfig.eventBus = eventBus; |
|
|
|
findBarConfig.eventBus = eventBus; |
|
|
|
this.findBar = new PDFFindBar(findBarConfig); |
|
|
|
this.findBar = new PDFFindBar(findBarConfig, this.l10n); |
|
|
|
|
|
|
|
|
|
|
|
this.pdfDocumentProperties = |
|
|
|
this.pdfDocumentProperties = |
|
|
|
new PDFDocumentProperties(appConfig.documentProperties, |
|
|
|
new PDFDocumentProperties(appConfig.documentProperties, |
|
|
|
this.overlayManager); |
|
|
|
this.overlayManager, this.l10n); |
|
|
|
|
|
|
|
|
|
|
|
this.pdfCursorTools = new PDFCursorTools({ |
|
|
|
this.pdfCursorTools = new PDFCursorTools({ |
|
|
|
container, |
|
|
|
container, |
|
|
@ -349,7 +374,8 @@ var PDFViewerApplication = { |
|
|
|
preferences: this.preferences, |
|
|
|
preferences: this.preferences, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.toolbar = new Toolbar(appConfig.toolbar, container, eventBus); |
|
|
|
this.toolbar = new Toolbar(appConfig.toolbar, container, eventBus, |
|
|
|
|
|
|
|
this.l10n); |
|
|
|
|
|
|
|
|
|
|
|
this.secondaryToolbar = |
|
|
|
this.secondaryToolbar = |
|
|
|
new SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); |
|
|
|
new SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); |
|
|
@ -365,7 +391,7 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay, |
|
|
|
this.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay, |
|
|
|
this.overlayManager); |
|
|
|
this.overlayManager, this.l10n); |
|
|
|
|
|
|
|
|
|
|
|
this.pdfOutlineViewer = new PDFOutlineViewer({ |
|
|
|
this.pdfOutlineViewer = new PDFOutlineViewer({ |
|
|
|
container: appConfig.sidebar.outlineView, |
|
|
|
container: appConfig.sidebar.outlineView, |
|
|
@ -385,7 +411,7 @@ var PDFViewerApplication = { |
|
|
|
sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer; |
|
|
|
sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer; |
|
|
|
sidebarConfig.pdfOutlineViewer = this.pdfOutlineViewer; |
|
|
|
sidebarConfig.pdfOutlineViewer = this.pdfOutlineViewer; |
|
|
|
sidebarConfig.eventBus = eventBus; |
|
|
|
sidebarConfig.eventBus = eventBus; |
|
|
|
this.pdfSidebar = new PDFSidebar(sidebarConfig); |
|
|
|
this.pdfSidebar = new PDFSidebar(sidebarConfig, this.l10n); |
|
|
|
this.pdfSidebar.onToggled = this.forceRendering.bind(this); |
|
|
|
this.pdfSidebar.onToggled = this.forceRendering.bind(this); |
|
|
|
|
|
|
|
|
|
|
|
resolve(undefined); |
|
|
|
resolve(undefined); |
|
|
@ -507,8 +533,10 @@ var PDFViewerApplication = { |
|
|
|
PDFViewerApplication.open(file, args); |
|
|
|
PDFViewerApplication.open(file, args); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onError(err) { |
|
|
|
onError(err) { |
|
|
|
PDFViewerApplication.error(mozL10n.get('loading_error', null, |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
'An error occurred while loading the PDF.'), err); |
|
|
|
'An error occurred while loading the PDF.').then((msg) => { |
|
|
|
|
|
|
|
PDFViewerApplication.error(msg, err); |
|
|
|
|
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onProgress(loaded, total) { |
|
|
|
onProgress(loaded, total) { |
|
|
|
PDFViewerApplication.progress(loaded / total); |
|
|
|
PDFViewerApplication.progress(loaded / total); |
|
|
@ -659,24 +687,27 @@ var PDFViewerApplication = { |
|
|
|
this.load(pdfDocument, scale); |
|
|
|
this.load(pdfDocument, scale); |
|
|
|
}, (exception) => { |
|
|
|
}, (exception) => { |
|
|
|
let message = exception && exception.message; |
|
|
|
let message = exception && exception.message; |
|
|
|
let loadingErrorMessage = mozL10n.get('loading_error', null, |
|
|
|
let loadingErrorMessage; |
|
|
|
'An error occurred while loading the PDF.'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (exception instanceof InvalidPDFException) { |
|
|
|
if (exception instanceof InvalidPDFException) { |
|
|
|
// change error message also for other builds
|
|
|
|
// change error message also for other builds
|
|
|
|
loadingErrorMessage = mozL10n.get('invalid_file_error', null, |
|
|
|
loadingErrorMessage = this.l10n.get('invalid_file_error', null, |
|
|
|
'Invalid or corrupted PDF file.'); |
|
|
|
'Invalid or corrupted PDF file.'); |
|
|
|
} else if (exception instanceof MissingPDFException) { |
|
|
|
} else if (exception instanceof MissingPDFException) { |
|
|
|
// special message for missing PDF's
|
|
|
|
// special message for missing PDF's
|
|
|
|
loadingErrorMessage = mozL10n.get('missing_file_error', null, |
|
|
|
loadingErrorMessage = this.l10n.get('missing_file_error', null, |
|
|
|
'Missing PDF file.'); |
|
|
|
'Missing PDF file.'); |
|
|
|
} else if (exception instanceof UnexpectedResponseException) { |
|
|
|
} else if (exception instanceof UnexpectedResponseException) { |
|
|
|
loadingErrorMessage = mozL10n.get('unexpected_response_error', null, |
|
|
|
loadingErrorMessage = this.l10n.get('unexpected_response_error', null, |
|
|
|
'Unexpected server response.'); |
|
|
|
'Unexpected server response.'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
loadingErrorMessage = this.l10n.get('loading_error', null, |
|
|
|
|
|
|
|
'An error occurred while loading the PDF.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.error(loadingErrorMessage, { message, }); |
|
|
|
return loadingErrorMessage.then((msg) => { |
|
|
|
throw new Error(loadingErrorMessage); |
|
|
|
this.error(msg, { message, }); |
|
|
|
|
|
|
|
throw new Error(msg); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -744,27 +775,27 @@ var PDFViewerApplication = { |
|
|
|
* and optionally a 'stack' property. |
|
|
|
* and optionally a 'stack' property. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
error: function pdfViewError(message, moreInfo) { |
|
|
|
error: function pdfViewError(message, moreInfo) { |
|
|
|
var moreInfoText = mozL10n.get('error_version_info', |
|
|
|
let moreInfoText = [this.l10n.get('error_version_info', |
|
|
|
{version: version || '?', build: build || '?'}, |
|
|
|
{version: version || '?', build: build || '?'}, |
|
|
|
'PDF.js v{{version}} (build: {{build}})') + '\n'; |
|
|
|
'PDF.js v{{version}} (build: {{build}})')]; |
|
|
|
if (moreInfo) { |
|
|
|
if (moreInfo) { |
|
|
|
moreInfoText += |
|
|
|
moreInfoText.push( |
|
|
|
mozL10n.get('error_message', {message: moreInfo.message}, |
|
|
|
this.l10n.get('error_message', {message: moreInfo.message}, |
|
|
|
'Message: {{message}}'); |
|
|
|
'Message: {{message}}')); |
|
|
|
if (moreInfo.stack) { |
|
|
|
if (moreInfo.stack) { |
|
|
|
moreInfoText += '\n' + |
|
|
|
moreInfoText.push( |
|
|
|
mozL10n.get('error_stack', {stack: moreInfo.stack}, |
|
|
|
this.l10n.get('error_stack', {stack: moreInfo.stack}, |
|
|
|
'Stack: {{stack}}'); |
|
|
|
'Stack: {{stack}}')); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (moreInfo.filename) { |
|
|
|
if (moreInfo.filename) { |
|
|
|
moreInfoText += '\n' + |
|
|
|
moreInfoText.push( |
|
|
|
mozL10n.get('error_file', {file: moreInfo.filename}, |
|
|
|
this.l10n.get('error_file', {file: moreInfo.filename}, |
|
|
|
'File: {{file}}'); |
|
|
|
'File: {{file}}')); |
|
|
|
} |
|
|
|
} |
|
|
|
if (moreInfo.lineNumber) { |
|
|
|
if (moreInfo.lineNumber) { |
|
|
|
moreInfoText += '\n' + |
|
|
|
moreInfoText.push( |
|
|
|
mozL10n.get('error_line', {line: moreInfo.lineNumber}, |
|
|
|
this.l10n.get('error_line', {line: moreInfo.lineNumber}, |
|
|
|
'Line: {{line}}'); |
|
|
|
'Line: {{line}}')); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -802,7 +833,9 @@ var PDFViewerApplication = { |
|
|
|
closeButton.oncontextmenu = noContextMenuHandler; |
|
|
|
closeButton.oncontextmenu = noContextMenuHandler; |
|
|
|
moreInfoButton.removeAttribute('hidden'); |
|
|
|
moreInfoButton.removeAttribute('hidden'); |
|
|
|
lessInfoButton.setAttribute('hidden', 'true'); |
|
|
|
lessInfoButton.setAttribute('hidden', 'true'); |
|
|
|
errorMoreInfo.value = moreInfoText; |
|
|
|
Promise.all(moreInfoText).then((parts) => { |
|
|
|
|
|
|
|
errorMoreInfo.value = parts.join('\n'); |
|
|
|
|
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
console.error(message + '\n' + moreInfoText); |
|
|
|
console.error(message + '\n' + moreInfoText); |
|
|
|
this.fallback(); |
|
|
|
this.fallback(); |
|
|
@ -1148,25 +1181,29 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!this.supportsPrinting) { |
|
|
|
if (!this.supportsPrinting) { |
|
|
|
var printMessage = mozL10n.get('printing_not_supported', null, |
|
|
|
this.l10n.get('printing_not_supported', null, |
|
|
|
'Warning: Printing is not fully supported by this browser.'); |
|
|
|
'Warning: Printing is not fully supported by ' + |
|
|
|
|
|
|
|
'this browser.').then((printMessage) => { |
|
|
|
this.error(printMessage); |
|
|
|
this.error(printMessage); |
|
|
|
|
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The beforePrint is a sync method and we need to know layout before
|
|
|
|
// The beforePrint is a sync method and we need to know layout before
|
|
|
|
// returning from this method. Ensure that we can get sizes of the pages.
|
|
|
|
// returning from this method. Ensure that we can get sizes of the pages.
|
|
|
|
if (!this.pdfViewer.pageViewsReady) { |
|
|
|
if (!this.pdfViewer.pageViewsReady) { |
|
|
|
var notReadyMessage = mozL10n.get('printing_not_ready', null, |
|
|
|
this.l10n.get('printing_not_ready', null, |
|
|
|
'Warning: The PDF is not fully loaded for printing.'); |
|
|
|
'Warning: The PDF is not fully loaded for printing.'). |
|
|
|
|
|
|
|
then((notReadyMessage) => { |
|
|
|
window.alert(notReadyMessage); |
|
|
|
window.alert(notReadyMessage); |
|
|
|
|
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var pagesOverview = this.pdfViewer.getPagesOverview(); |
|
|
|
var pagesOverview = this.pdfViewer.getPagesOverview(); |
|
|
|
var printContainer = this.appConfig.printContainer; |
|
|
|
var printContainer = this.appConfig.printContainer; |
|
|
|
var printService = PDFPrintServiceFactory.instance.createPrintService( |
|
|
|
var printService = PDFPrintServiceFactory.instance.createPrintService( |
|
|
|
this.pdfDocument, pagesOverview, printContainer); |
|
|
|
this.pdfDocument, pagesOverview, printContainer, this.l10n); |
|
|
|
this.printService = printService; |
|
|
|
this.printService = printService; |
|
|
|
this.forceRendering(); |
|
|
|
this.forceRendering(); |
|
|
|
|
|
|
|
|
|
|
@ -1312,13 +1349,11 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
var message = e && e.message; |
|
|
|
var message = e && e.message; |
|
|
|
var loadingErrorMessage = mozL10n.get('loading_error', null, |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
'An error occurred while loading the PDF.'); |
|
|
|
'An error occurred while loading the PDF.'). |
|
|
|
|
|
|
|
then((loadingErrorMessage) => { |
|
|
|
var moreInfo = { |
|
|
|
PDFViewerApplication.error(loadingErrorMessage, { message, }); |
|
|
|
message, |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
PDFViewerApplication.error(loadingErrorMessage, moreInfo); |
|
|
|
|
|
|
|
throw e; |
|
|
|
throw e; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -1423,12 +1458,6 @@ function webViewerInitialized() { |
|
|
|
PDFJS.cMapPacked = false; |
|
|
|
PDFJS.cMapPacked = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
|
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
|
|
|
|
if ('locale' in hashParams) { |
|
|
|
|
|
|
|
PDFJS.locale = hashParams['locale']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ('textlayer' in hashParams) { |
|
|
|
if ('textlayer' in hashParams) { |
|
|
|
switch (hashParams['textlayer']) { |
|
|
|
switch (hashParams['textlayer']) { |
|
|
|
case 'off': |
|
|
|
case 'off': |
|
|
@ -1450,15 +1479,15 @@ function webViewerInitialized() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (typeof PDFJSDev === 'undefined' || |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) { |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL') && |
|
|
|
mozL10n.setLanguage(PDFJS.locale); |
|
|
|
!PDFViewerApplication.supportsDocumentFonts) { |
|
|
|
} else { |
|
|
|
|
|
|
|
if (!PDFViewerApplication.supportsDocumentFonts) { |
|
|
|
|
|
|
|
PDFJS.disableFontFace = true; |
|
|
|
PDFJS.disableFontFace = true; |
|
|
|
console.warn(mozL10n.get('web_fonts_disabled', null, |
|
|
|
PDFViewerApplication.l10n.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.'). |
|
|
|
} |
|
|
|
then((msg) => { |
|
|
|
|
|
|
|
console.warn(msg); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!PDFViewerApplication.supportsPrinting) { |
|
|
|
if (!PDFViewerApplication.supportsPrinting) { |
|
|
@ -1489,8 +1518,10 @@ function webViewerInitialized() { |
|
|
|
Promise.all(waitForBeforeOpening).then(function () { |
|
|
|
Promise.all(waitForBeforeOpening).then(function () { |
|
|
|
webViewerOpenFileViaURL(file); |
|
|
|
webViewerOpenFileViaURL(file); |
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
PDFViewerApplication.error(mozL10n.get('loading_error', null, |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
'An error occurred while opening.'), reason); |
|
|
|
'An error occurred while opening.').then((msg) => { |
|
|
|
|
|
|
|
PDFViewerApplication.error(msg, reason); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1511,8 +1542,10 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) { |
|
|
|
xhr.responseType = 'arraybuffer'; |
|
|
|
xhr.responseType = 'arraybuffer'; |
|
|
|
xhr.send(); |
|
|
|
xhr.send(); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
PDFViewerApplication.error(mozL10n.get('loading_error', null, |
|
|
|
PDFViewerApplication.l10n.get('loading_error', null, |
|
|
|
'An error occurred while loading the PDF.'), e); |
|
|
|
'An error occurred while loading the PDF.').then((msg) => { |
|
|
|
|
|
|
|
PDFViewerApplication.error(msg, e); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1563,8 +1596,10 @@ function webViewerPageRendered(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (pageView.error) { |
|
|
|
if (pageView.error) { |
|
|
|
PDFViewerApplication.error(mozL10n.get('rendering_error', null, |
|
|
|
PDFViewerApplication.l10n.get('rendering_error', null, |
|
|
|
'An error occurred while rendering the page.'), pageView.error); |
|
|
|
'An error occurred while rendering the page.').then((msg) => { |
|
|
|
|
|
|
|
PDFViewerApplication.error(msg, pageView.error); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
@ -1586,10 +1621,13 @@ function webViewerTextLayerRendered(e) { |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
if (typeof PDFJSDev !== 'undefined' && |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL') && |
|
|
|
PDFJSDev.test('FIREFOX || MOZCENTRAL') && |
|
|
|
e.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) { |
|
|
|
e.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) { |
|
|
|
console.error(mozL10n.get('document_colors_not_allowed', null, |
|
|
|
PDFViewerApplication.l10n.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.'). |
|
|
|
|
|
|
|
then((msg) => { |
|
|
|
|
|
|
|
console.error(msg); |
|
|
|
|
|
|
|
}); |
|
|
|
PDFViewerApplication.fallback(); |
|
|
|
PDFViewerApplication.fallback(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2194,10 +2232,6 @@ function webViewerKeyDown(evt) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
localized.then(function webViewerLocalized() { |
|
|
|
|
|
|
|
document.getElementsByTagName('html')[0].dir = mozL10n.getDirection(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Abstract factory for the print service. */ |
|
|
|
/* Abstract factory for the print service. */ |
|
|
|
var PDFPrintServiceFactory = { |
|
|
|
var PDFPrintServiceFactory = { |
|
|
|
instance: { |
|
|
|
instance: { |
|
|
|