|
|
@ -209,104 +209,103 @@ var PDFViewerApplication = { |
|
|
|
_initializeViewerComponents: function _initializeViewerComponents() { |
|
|
|
_initializeViewerComponents: function _initializeViewerComponents() { |
|
|
|
var _this2 = this; |
|
|
|
var _this2 = this; |
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
var appConfig = this.appConfig; |
|
|
|
var appConfig = this.appConfig; |
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
return new Promise(function (resolve, reject) { |
|
|
|
var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(); |
|
|
|
var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(); |
|
|
|
_this2.eventBus = eventBus; |
|
|
|
_this2.eventBus = eventBus; |
|
|
|
var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); |
|
|
|
var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); |
|
|
|
pdfRenderingQueue.onIdle = self.cleanup.bind(self); |
|
|
|
pdfRenderingQueue.onIdle = _this2.cleanup.bind(_this2); |
|
|
|
self.pdfRenderingQueue = pdfRenderingQueue; |
|
|
|
_this2.pdfRenderingQueue = pdfRenderingQueue; |
|
|
|
var pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus }); |
|
|
|
var pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus }); |
|
|
|
self.pdfLinkService = pdfLinkService; |
|
|
|
_this2.pdfLinkService = pdfLinkService; |
|
|
|
var downloadManager = self.externalServices.createDownloadManager(); |
|
|
|
var downloadManager = _this2.externalServices.createDownloadManager(); |
|
|
|
self.downloadManager = downloadManager; |
|
|
|
_this2.downloadManager = downloadManager; |
|
|
|
var container = appConfig.mainContainer; |
|
|
|
var container = appConfig.mainContainer; |
|
|
|
var viewer = appConfig.viewerContainer; |
|
|
|
var viewer = appConfig.viewerContainer; |
|
|
|
self.pdfViewer = new _pdf_viewer.PDFViewer({ |
|
|
|
_this2.pdfViewer = new _pdf_viewer.PDFViewer({ |
|
|
|
container: container, |
|
|
|
container: container, |
|
|
|
viewer: viewer, |
|
|
|
viewer: viewer, |
|
|
|
eventBus: eventBus, |
|
|
|
eventBus: eventBus, |
|
|
|
renderingQueue: pdfRenderingQueue, |
|
|
|
renderingQueue: pdfRenderingQueue, |
|
|
|
linkService: pdfLinkService, |
|
|
|
linkService: pdfLinkService, |
|
|
|
downloadManager: downloadManager, |
|
|
|
downloadManager: downloadManager, |
|
|
|
renderer: self.viewerPrefs['renderer'], |
|
|
|
renderer: _this2.viewerPrefs['renderer'], |
|
|
|
enhanceTextSelection: self.viewerPrefs['enhanceTextSelection'], |
|
|
|
enhanceTextSelection: _this2.viewerPrefs['enhanceTextSelection'], |
|
|
|
renderInteractiveForms: self.viewerPrefs['renderInteractiveForms'], |
|
|
|
renderInteractiveForms: _this2.viewerPrefs['renderInteractiveForms'], |
|
|
|
enablePrintAutoRotate: self.viewerPrefs['enablePrintAutoRotate'] |
|
|
|
enablePrintAutoRotate: _this2.viewerPrefs['enablePrintAutoRotate'] |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfRenderingQueue.setViewer(self.pdfViewer); |
|
|
|
pdfRenderingQueue.setViewer(_this2.pdfViewer); |
|
|
|
pdfLinkService.setViewer(self.pdfViewer); |
|
|
|
pdfLinkService.setViewer(_this2.pdfViewer); |
|
|
|
var thumbnailContainer = appConfig.sidebar.thumbnailView; |
|
|
|
var thumbnailContainer = appConfig.sidebar.thumbnailView; |
|
|
|
self.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ |
|
|
|
_this2.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ |
|
|
|
container: thumbnailContainer, |
|
|
|
container: thumbnailContainer, |
|
|
|
renderingQueue: pdfRenderingQueue, |
|
|
|
renderingQueue: pdfRenderingQueue, |
|
|
|
linkService: pdfLinkService |
|
|
|
linkService: pdfLinkService |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfRenderingQueue.setThumbnailViewer(self.pdfThumbnailViewer); |
|
|
|
pdfRenderingQueue.setThumbnailViewer(_this2.pdfThumbnailViewer); |
|
|
|
self.pdfHistory = new _pdf_history.PDFHistory({ |
|
|
|
_this2.pdfHistory = new _pdf_history.PDFHistory({ |
|
|
|
linkService: pdfLinkService, |
|
|
|
linkService: pdfLinkService, |
|
|
|
eventBus: eventBus |
|
|
|
eventBus: eventBus |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfLinkService.setHistory(self.pdfHistory); |
|
|
|
pdfLinkService.setHistory(_this2.pdfHistory); |
|
|
|
self.findController = new _pdf_find_controller.PDFFindController({ pdfViewer: self.pdfViewer }); |
|
|
|
_this2.findController = new _pdf_find_controller.PDFFindController({ pdfViewer: _this2.pdfViewer }); |
|
|
|
self.findController.onUpdateResultsCount = function (matchCount) { |
|
|
|
_this2.findController.onUpdateResultsCount = function (matchCount) { |
|
|
|
if (self.supportsIntegratedFind) { |
|
|
|
if (_this2.supportsIntegratedFind) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
self.findBar.updateResultsCount(matchCount); |
|
|
|
_this2.findBar.updateResultsCount(matchCount); |
|
|
|
}; |
|
|
|
}; |
|
|
|
self.findController.onUpdateState = function (state, previous, matchCount) { |
|
|
|
_this2.findController.onUpdateState = function (state, previous, matchCount) { |
|
|
|
if (self.supportsIntegratedFind) { |
|
|
|
if (_this2.supportsIntegratedFind) { |
|
|
|
self.externalServices.updateFindControlState({ |
|
|
|
_this2.externalServices.updateFindControlState({ |
|
|
|
result: state, |
|
|
|
result: state, |
|
|
|
findPrevious: previous |
|
|
|
findPrevious: previous |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
self.findBar.updateUIState(state, previous, matchCount); |
|
|
|
_this2.findBar.updateUIState(state, previous, matchCount); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
self.pdfViewer.setFindController(self.findController); |
|
|
|
_this2.pdfViewer.setFindController(_this2.findController); |
|
|
|
var findBarConfig = Object.create(appConfig.findBar); |
|
|
|
var findBarConfig = Object.create(appConfig.findBar); |
|
|
|
findBarConfig.findController = self.findController; |
|
|
|
findBarConfig.findController = _this2.findController; |
|
|
|
findBarConfig.eventBus = eventBus; |
|
|
|
findBarConfig.eventBus = eventBus; |
|
|
|
self.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig); |
|
|
|
_this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig); |
|
|
|
self.overlayManager = _overlay_manager.OverlayManager; |
|
|
|
_this2.overlayManager = _overlay_manager.OverlayManager; |
|
|
|
self.handTool = new _hand_tool.HandTool({ |
|
|
|
_this2.handTool = new _hand_tool.HandTool({ |
|
|
|
container: container, |
|
|
|
container: container, |
|
|
|
eventBus: eventBus, |
|
|
|
eventBus: eventBus, |
|
|
|
preferences: _this2.preferences |
|
|
|
preferences: _this2.preferences |
|
|
|
}); |
|
|
|
}); |
|
|
|
self.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties); |
|
|
|
_this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties); |
|
|
|
self.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus); |
|
|
|
_this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus); |
|
|
|
self.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); |
|
|
|
_this2.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); |
|
|
|
if (self.supportsFullscreen) { |
|
|
|
if (_this2.supportsFullscreen) { |
|
|
|
self.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ |
|
|
|
_this2.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ |
|
|
|
container: container, |
|
|
|
container: container, |
|
|
|
viewer: viewer, |
|
|
|
viewer: viewer, |
|
|
|
pdfViewer: self.pdfViewer, |
|
|
|
pdfViewer: _this2.pdfViewer, |
|
|
|
eventBus: eventBus, |
|
|
|
eventBus: eventBus, |
|
|
|
contextMenuItems: appConfig.fullscreen |
|
|
|
contextMenuItems: appConfig.fullscreen |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
self.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay); |
|
|
|
_this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay); |
|
|
|
self.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ |
|
|
|
_this2.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ |
|
|
|
container: appConfig.sidebar.outlineView, |
|
|
|
container: appConfig.sidebar.outlineView, |
|
|
|
eventBus: eventBus, |
|
|
|
eventBus: eventBus, |
|
|
|
linkService: pdfLinkService |
|
|
|
linkService: pdfLinkService |
|
|
|
}); |
|
|
|
}); |
|
|
|
self.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ |
|
|
|
_this2.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ |
|
|
|
container: appConfig.sidebar.attachmentsView, |
|
|
|
container: appConfig.sidebar.attachmentsView, |
|
|
|
eventBus: eventBus, |
|
|
|
eventBus: eventBus, |
|
|
|
downloadManager: downloadManager |
|
|
|
downloadManager: downloadManager |
|
|
|
}); |
|
|
|
}); |
|
|
|
var sidebarConfig = Object.create(appConfig.sidebar); |
|
|
|
var sidebarConfig = Object.create(appConfig.sidebar); |
|
|
|
sidebarConfig.pdfViewer = self.pdfViewer; |
|
|
|
sidebarConfig.pdfViewer = _this2.pdfViewer; |
|
|
|
sidebarConfig.pdfThumbnailViewer = self.pdfThumbnailViewer; |
|
|
|
sidebarConfig.pdfThumbnailViewer = _this2.pdfThumbnailViewer; |
|
|
|
sidebarConfig.pdfOutlineViewer = self.pdfOutlineViewer; |
|
|
|
sidebarConfig.pdfOutlineViewer = _this2.pdfOutlineViewer; |
|
|
|
sidebarConfig.eventBus = eventBus; |
|
|
|
sidebarConfig.eventBus = eventBus; |
|
|
|
self.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig); |
|
|
|
_this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig); |
|
|
|
self.pdfSidebar.onToggled = self.forceRendering.bind(self); |
|
|
|
_this2.pdfSidebar.onToggled = _this2.forceRendering.bind(_this2); |
|
|
|
resolve(undefined); |
|
|
|
resolve(undefined); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -426,7 +425,7 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
return promise; |
|
|
|
return promise; |
|
|
|
}, |
|
|
|
}, |
|
|
|
open: function pdfViewOpen(file, args) { |
|
|
|
open: function open(file, args) { |
|
|
|
var _this3 = this; |
|
|
|
var _this3 = this; |
|
|
|
|
|
|
|
|
|
|
|
if (arguments.length > 2 || typeof args === 'number') { |
|
|
|
if (arguments.length > 2 || typeof args === 'number') { |
|
|
@ -439,7 +438,7 @@ var PDFViewerApplication = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
var parameters = Object.create(null), |
|
|
|
var parameters = Object.create(null), |
|
|
|
scale; |
|
|
|
scale = void 0; |
|
|
|
if (typeof file === 'string') { |
|
|
|
if (typeof file === 'string') { |
|
|
|
this.setTitleUsingUrl(file); |
|
|
|
this.setTitleUsingUrl(file); |
|
|
|
parameters.url = file; |
|
|
|
parameters.url = file; |
|
|
@ -460,21 +459,23 @@ var PDFViewerApplication = { |
|
|
|
this.pdfDocumentProperties.setFileSize(args.length); |
|
|
|
this.pdfDocumentProperties.setFileSize(args.length); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
var self = this; |
|
|
|
this.downloadComplete = false; |
|
|
|
self.downloadComplete = false; |
|
|
|
|
|
|
|
var loadingTask = (0, _pdfjs.getDocument)(parameters); |
|
|
|
var loadingTask = (0, _pdfjs.getDocument)(parameters); |
|
|
|
this.pdfLoadingTask = loadingTask; |
|
|
|
this.pdfLoadingTask = loadingTask; |
|
|
|
loadingTask.onPassword = function passwordNeeded(updateCallback, reason) { |
|
|
|
loadingTask.onPassword = function (updateCallback, reason) { |
|
|
|
self.passwordPrompt.setUpdateCallback(updateCallback, reason); |
|
|
|
_this3.passwordPrompt.setUpdateCallback(updateCallback, reason); |
|
|
|
self.passwordPrompt.open(); |
|
|
|
_this3.passwordPrompt.open(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
loadingTask.onProgress = function getDocumentProgress(progressData) { |
|
|
|
loadingTask.onProgress = function (_ref) { |
|
|
|
self.progress(progressData.loaded / progressData.total); |
|
|
|
var loaded = _ref.loaded, |
|
|
|
|
|
|
|
total = _ref.total; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_this3.progress(loaded / total); |
|
|
|
}; |
|
|
|
}; |
|
|
|
loadingTask.onUnsupportedFeature = this.fallback.bind(this); |
|
|
|
loadingTask.onUnsupportedFeature = this.fallback.bind(this); |
|
|
|
return loadingTask.promise.then(function getDocumentCallback(pdfDocument) { |
|
|
|
return loadingTask.promise.then(function (pdfDocument) { |
|
|
|
self.load(pdfDocument, scale); |
|
|
|
_this3.load(pdfDocument, scale); |
|
|
|
}, function getDocumentError(exception) { |
|
|
|
}, function (exception) { |
|
|
|
var message = exception && exception.message; |
|
|
|
var message = exception && exception.message; |
|
|
|
var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'); |
|
|
|
var loadingErrorMessage = _ui_utils.mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'); |
|
|
|
if (exception instanceof _pdfjs.InvalidPDFException) { |
|
|
|
if (exception instanceof _pdfjs.InvalidPDFException) { |
|
|
@ -484,11 +485,11 @@ var PDFViewerApplication = { |
|
|
|
} else if (exception instanceof _pdfjs.UnexpectedResponseException) { |
|
|
|
} else if (exception instanceof _pdfjs.UnexpectedResponseException) { |
|
|
|
loadingErrorMessage = _ui_utils.mozL10n.get('unexpected_response_error', null, 'Unexpected server response.'); |
|
|
|
loadingErrorMessage = _ui_utils.mozL10n.get('unexpected_response_error', null, 'Unexpected server response.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var moreInfo = { message: message }; |
|
|
|
_this3.error(loadingErrorMessage, { message: message }); |
|
|
|
self.error(loadingErrorMessage, moreInfo); |
|
|
|
|
|
|
|
throw new Error(loadingErrorMessage); |
|
|
|
throw new Error(loadingErrorMessage); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
download: function pdfViewDownload() { |
|
|
|
download: function pdfViewDownload() { |
|
|
|
function downloadByUrl() { |
|
|
|
function downloadByUrl() { |
|
|
|
downloadManager.downloadUrl(url, filename); |
|
|
|
downloadManager.downloadUrl(url, filename); |
|
|
@ -580,21 +581,23 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
load: function pdfViewLoad(pdfDocument, scale) { |
|
|
|
load: function load(pdfDocument, scale) { |
|
|
|
var _this5 = this; |
|
|
|
var _this5 = this; |
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
scale = scale || _ui_utils.UNKNOWN_SCALE; |
|
|
|
scale = scale || _ui_utils.UNKNOWN_SCALE; |
|
|
|
this.pdfDocument = pdfDocument; |
|
|
|
this.pdfDocument = pdfDocument; |
|
|
|
var downloadedPromise = pdfDocument.getDownloadInfo().then(function () { |
|
|
|
pdfDocument.getDownloadInfo().then(function () { |
|
|
|
self.downloadComplete = true; |
|
|
|
_this5.downloadComplete = true; |
|
|
|
self.loadingBar.hide(); |
|
|
|
_this5.loadingBar.hide(); |
|
|
|
|
|
|
|
firstPagePromise.then(function () { |
|
|
|
|
|
|
|
_this5.eventBus.dispatch('documentload', { source: _this5 }); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.toolbar.setPagesCount(pdfDocument.numPages, false); |
|
|
|
this.toolbar.setPagesCount(pdfDocument.numPages, false); |
|
|
|
this.secondaryToolbar.setPagesCount(pdfDocument.numPages); |
|
|
|
this.secondaryToolbar.setPagesCount(pdfDocument.numPages); |
|
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint; |
|
|
|
var id = this.documentFingerprint = pdfDocument.fingerprint; |
|
|
|
var store = this.store = new _view_history.ViewHistory(id); |
|
|
|
var store = this.store = new _view_history.ViewHistory(id); |
|
|
|
var baseDocumentUrl; |
|
|
|
var baseDocumentUrl = void 0; |
|
|
|
baseDocumentUrl = null; |
|
|
|
baseDocumentUrl = null; |
|
|
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl); |
|
|
|
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl); |
|
|
|
this.pdfDocumentProperties.setDocument(pdfDocument, this.url); |
|
|
|
this.pdfDocumentProperties.setDocument(pdfDocument, this.url); |
|
|
@ -608,19 +611,16 @@ var PDFViewerApplication = { |
|
|
|
var pdfThumbnailViewer = this.pdfThumbnailViewer; |
|
|
|
var pdfThumbnailViewer = this.pdfThumbnailViewer; |
|
|
|
pdfThumbnailViewer.setDocument(pdfDocument); |
|
|
|
pdfThumbnailViewer.setDocument(pdfDocument); |
|
|
|
firstPagePromise.then(function (pdfPage) { |
|
|
|
firstPagePromise.then(function (pdfPage) { |
|
|
|
downloadedPromise.then(function () { |
|
|
|
_this5.loadingBar.setWidth(_this5.appConfig.viewerContainer); |
|
|
|
self.eventBus.dispatch('documentload', { source: self }); |
|
|
|
if (!_pdfjs.PDFJS.disableHistory && !_this5.isViewerEmbedded) { |
|
|
|
}); |
|
|
|
if (!_this5.viewerPrefs['showPreviousViewOnLoad']) { |
|
|
|
self.loadingBar.setWidth(self.appConfig.viewerContainer); |
|
|
|
_this5.pdfHistory.clearHistoryState(); |
|
|
|
if (!_pdfjs.PDFJS.disableHistory && !self.isViewerEmbedded) { |
|
|
|
|
|
|
|
if (!self.viewerPrefs['showPreviousViewOnLoad']) { |
|
|
|
|
|
|
|
self.pdfHistory.clearHistoryState(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
self.pdfHistory.initialize(self.documentFingerprint); |
|
|
|
_this5.pdfHistory.initialize(_this5.documentFingerprint); |
|
|
|
if (self.pdfHistory.initialDestination) { |
|
|
|
if (_this5.pdfHistory.initialDestination) { |
|
|
|
self.initialDestination = self.pdfHistory.initialDestination; |
|
|
|
_this5.initialDestination = _this5.pdfHistory.initialDestination; |
|
|
|
} else if (self.pdfHistory.initialBookmark) { |
|
|
|
} else if (_this5.pdfHistory.initialBookmark) { |
|
|
|
self.initialBookmark = self.pdfHistory.initialBookmark; |
|
|
|
_this5.initialBookmark = _this5.pdfHistory.initialBookmark; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
var initialParams = { |
|
|
|
var initialParams = { |
|
|
@ -677,12 +677,12 @@ var PDFViewerApplication = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfDocument.getPageLabels().then(function (labels) { |
|
|
|
pdfDocument.getPageLabels().then(function (labels) { |
|
|
|
if (!labels || self.viewerPrefs['disablePageLabels']) { |
|
|
|
if (!labels || _this5.viewerPrefs['disablePageLabels']) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var i = 0, |
|
|
|
var i = 0, |
|
|
|
numLabels = labels.length; |
|
|
|
numLabels = labels.length; |
|
|
|
if (numLabels !== self.pagesCount) { |
|
|
|
if (numLabels !== _this5.pagesCount) { |
|
|
|
console.error('The number of Page Labels does not match ' + 'the number of pages in the document.'); |
|
|
|
console.error('The number of Page Labels does not match ' + 'the number of pages in the document.'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -694,44 +694,46 @@ var PDFViewerApplication = { |
|
|
|
} |
|
|
|
} |
|
|
|
pdfViewer.setPageLabels(labels); |
|
|
|
pdfViewer.setPageLabels(labels); |
|
|
|
pdfThumbnailViewer.setPageLabels(labels); |
|
|
|
pdfThumbnailViewer.setPageLabels(labels); |
|
|
|
self.toolbar.setPagesCount(pdfDocument.numPages, true); |
|
|
|
_this5.toolbar.setPagesCount(pdfDocument.numPages, true); |
|
|
|
self.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
|
|
|
_this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pagesPromise.then(function () { |
|
|
|
pagesPromise.then(function () { |
|
|
|
if (self.supportsPrinting) { |
|
|
|
if (!_this5.supportsPrinting) { |
|
|
|
pdfDocument.getJavaScript().then(function (javaScript) { |
|
|
|
return; |
|
|
|
if (javaScript.length) { |
|
|
|
|
|
|
|
console.warn('Warning: JavaScript is not supported'); |
|
|
|
|
|
|
|
self.fallback(_pdfjs.UNSUPPORTED_FEATURES.javaScript); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var regex = /\bprint\s*\(/; |
|
|
|
|
|
|
|
for (var i = 0, ii = javaScript.length; i < ii; i++) { |
|
|
|
|
|
|
|
var js = javaScript[i]; |
|
|
|
|
|
|
|
if (js && regex.test(js)) { |
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
|
|
window.print(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
pdfDocument.getJavaScript().then(function (javaScript) { |
|
|
|
|
|
|
|
if (javaScript.length) { |
|
|
|
|
|
|
|
console.warn('Warning: JavaScript is not supported'); |
|
|
|
|
|
|
|
_this5.fallback(_pdfjs.UNSUPPORTED_FEATURES.javaScript); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var regex = /\bprint\s*\(/; |
|
|
|
|
|
|
|
for (var i = 0, ii = javaScript.length; i < ii; i++) { |
|
|
|
|
|
|
|
var js = javaScript[i]; |
|
|
|
|
|
|
|
if (js && regex.test(js)) { |
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
|
|
window.print(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () { |
|
|
|
Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () { |
|
|
|
pdfDocument.getOutline().then(function (outline) { |
|
|
|
pdfDocument.getOutline().then(function (outline) { |
|
|
|
self.pdfOutlineViewer.render({ outline: outline }); |
|
|
|
_this5.pdfOutlineViewer.render({ outline: outline }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfDocument.getAttachments().then(function (attachments) { |
|
|
|
pdfDocument.getAttachments().then(function (attachments) { |
|
|
|
self.pdfAttachmentViewer.render({ attachments: attachments }); |
|
|
|
_this5.pdfAttachmentViewer.render({ attachments: attachments }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pdfDocument.getMetadata().then(function (data) { |
|
|
|
pdfDocument.getMetadata().then(function (_ref2) { |
|
|
|
var info = data.info, |
|
|
|
var info = _ref2.info, |
|
|
|
metadata = data.metadata; |
|
|
|
metadata = _ref2.metadata; |
|
|
|
self.documentInfo = info; |
|
|
|
|
|
|
|
self.metadata = metadata; |
|
|
|
_this5.documentInfo = info; |
|
|
|
|
|
|
|
_this5.metadata = metadata; |
|
|
|
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjs.version || '-') + (!_pdfjs.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); |
|
|
|
console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjs.version || '-') + (!_pdfjs.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); |
|
|
|
var pdfTitle; |
|
|
|
var pdfTitle = void 0; |
|
|
|
if (metadata && metadata.has('dc:title')) { |
|
|
|
if (metadata && metadata.has('dc:title')) { |
|
|
|
var title = metadata.get('dc:title'); |
|
|
|
var title = metadata.get('dc:title'); |
|
|
|
if (title !== 'Untitled') { |
|
|
|
if (title !== 'Untitled') { |
|
|
@ -742,11 +744,11 @@ var PDFViewerApplication = { |
|
|
|
pdfTitle = info['Title']; |
|
|
|
pdfTitle = info['Title']; |
|
|
|
} |
|
|
|
} |
|
|
|
if (pdfTitle) { |
|
|
|
if (pdfTitle) { |
|
|
|
self.setTitle(pdfTitle + ' - ' + document.title); |
|
|
|
_this5.setTitle(pdfTitle + ' - ' + document.title); |
|
|
|
} |
|
|
|
} |
|
|
|
if (info.IsAcroFormPresent) { |
|
|
|
if (info.IsAcroFormPresent) { |
|
|
|
console.warn('Warning: AcroForm/XFA is not supported'); |
|
|
|
console.warn('Warning: AcroForm/XFA is not supported'); |
|
|
|
self.fallback(_pdfjs.UNSUPPORTED_FEATURES.forms); |
|
|
|
_this5.fallback(_pdfjs.UNSUPPORTED_FEATURES.forms); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|