|
|
@ -2348,6 +2348,7 @@ var PDFPageView = (function PDFPageViewClosure() { |
|
|
|
this.textLayerFactory = textLayerFactory; |
|
|
|
this.textLayerFactory = textLayerFactory; |
|
|
|
this.annotationLayerFactory = annotationLayerFactory; |
|
|
|
this.annotationLayerFactory = annotationLayerFactory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.renderTask = null; |
|
|
|
this.renderingState = RenderingStates.INITIAL; |
|
|
|
this.renderingState = RenderingStates.INITIAL; |
|
|
|
this.resume = null; |
|
|
|
this.resume = null; |
|
|
|
|
|
|
|
|
|
|
@ -2391,11 +2392,7 @@ var PDFPageView = (function PDFPageViewClosure() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
reset: function PDFPageView_reset(keepZoomLayer, keepAnnotations) { |
|
|
|
reset: function PDFPageView_reset(keepZoomLayer, keepAnnotations) { |
|
|
|
if (this.renderTask) { |
|
|
|
this.cancelRendering(); |
|
|
|
this.renderTask.cancel(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.resume = null; |
|
|
|
|
|
|
|
this.renderingState = RenderingStates.INITIAL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var div = this.div; |
|
|
|
var div = this.div; |
|
|
|
div.style.width = Math.floor(this.viewport.width) + 'px'; |
|
|
|
div.style.width = Math.floor(this.viewport.width) + 'px'; |
|
|
@ -2481,6 +2478,20 @@ var PDFPageView = (function PDFPageViewClosure() { |
|
|
|
this.reset(/* keepZoomLayer = */ true, /* keepAnnotations = */ true); |
|
|
|
this.reset(/* keepZoomLayer = */ true, /* keepAnnotations = */ true); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cancelRendering: function PDFPageView_cancelRendering() { |
|
|
|
|
|
|
|
if (this.renderTask) { |
|
|
|
|
|
|
|
this.renderTask.cancel(); |
|
|
|
|
|
|
|
this.renderTask = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.renderingState = RenderingStates.INITIAL; |
|
|
|
|
|
|
|
this.resume = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.textLayer) { |
|
|
|
|
|
|
|
this.textLayer.cancel(); |
|
|
|
|
|
|
|
this.textLayer = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Called when moved in the parent's container. |
|
|
|
* Called when moved in the parent's container. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -2576,6 +2587,7 @@ var PDFPageView = (function PDFPageViewClosure() { |
|
|
|
draw: function PDFPageView_draw() { |
|
|
|
draw: function PDFPageView_draw() { |
|
|
|
if (this.renderingState !== RenderingStates.INITIAL) { |
|
|
|
if (this.renderingState !== RenderingStates.INITIAL) { |
|
|
|
console.error('Must be in new state before drawing'); |
|
|
|
console.error('Must be in new state before drawing'); |
|
|
|
|
|
|
|
this.reset(); // Ensure that we reset all state to prevent issues.
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.renderingState = RenderingStates.RUNNING; |
|
|
|
this.renderingState = RenderingStates.RUNNING; |
|
|
@ -2834,8 +2846,8 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { |
|
|
|
function TextLayerBuilder(options) { |
|
|
|
function TextLayerBuilder(options) { |
|
|
|
this.textLayerDiv = options.textLayerDiv; |
|
|
|
this.textLayerDiv = options.textLayerDiv; |
|
|
|
this.eventBus = options.eventBus || domEvents.getGlobalEventBus(); |
|
|
|
this.eventBus = options.eventBus || domEvents.getGlobalEventBus(); |
|
|
|
|
|
|
|
this.textContent = null; |
|
|
|
this.renderingDone = false; |
|
|
|
this.renderingDone = false; |
|
|
|
this.divContentDone = false; |
|
|
|
|
|
|
|
this.pageIdx = options.pageIndex; |
|
|
|
this.pageIdx = options.pageIndex; |
|
|
|
this.pageNumber = this.pageIdx + 1; |
|
|
|
this.pageNumber = this.pageIdx + 1; |
|
|
|
this.matches = []; |
|
|
|
this.matches = []; |
|
|
@ -2848,6 +2860,9 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TextLayerBuilder.prototype = { |
|
|
|
TextLayerBuilder.prototype = { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
_finishRendering: function TextLayerBuilder_finishRendering() { |
|
|
|
_finishRendering: function TextLayerBuilder_finishRendering() { |
|
|
|
this.renderingDone = true; |
|
|
|
this.renderingDone = true; |
|
|
|
|
|
|
|
|
|
|
@ -2859,7 +2874,8 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { |
|
|
|
|
|
|
|
|
|
|
|
this.eventBus.dispatch('textlayerrendered', { |
|
|
|
this.eventBus.dispatch('textlayerrendered', { |
|
|
|
source: this, |
|
|
|
source: this, |
|
|
|
pageNumber: this.pageNumber |
|
|
|
pageNumber: this.pageNumber, |
|
|
|
|
|
|
|
numTextDivs: this.textDivs.length, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
@ -2869,14 +2885,10 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { |
|
|
|
* for specified amount of ms. |
|
|
|
* for specified amount of ms. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
render: function TextLayerBuilder_render(timeout) { |
|
|
|
render: function TextLayerBuilder_render(timeout) { |
|
|
|
if (!this.divContentDone || this.renderingDone) { |
|
|
|
if (!this.textContent || this.renderingDone) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.cancel(); |
|
|
|
if (this.textLayerRenderTask) { |
|
|
|
|
|
|
|
this.textLayerRenderTask.cancel(); |
|
|
|
|
|
|
|
this.textLayerRenderTask = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.textDivs = []; |
|
|
|
this.textDivs = []; |
|
|
|
var textLayerFrag = document.createDocumentFragment(); |
|
|
|
var textLayerFrag = document.createDocumentFragment(); |
|
|
@ -2893,17 +2905,23 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { |
|
|
|
this._finishRendering(); |
|
|
|
this._finishRendering(); |
|
|
|
this.updateMatches(); |
|
|
|
this.updateMatches(); |
|
|
|
}.bind(this), function (reason) { |
|
|
|
}.bind(this), function (reason) { |
|
|
|
// canceled or failed to render text layer -- skipping errors
|
|
|
|
// cancelled or failed to render text layer -- skipping errors
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setTextContent: function TextLayerBuilder_setTextContent(textContent) { |
|
|
|
/** |
|
|
|
|
|
|
|
* Cancels rendering of the text layer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
cancel: function TextLayerBuilder_cancel() { |
|
|
|
if (this.textLayerRenderTask) { |
|
|
|
if (this.textLayerRenderTask) { |
|
|
|
this.textLayerRenderTask.cancel(); |
|
|
|
this.textLayerRenderTask.cancel(); |
|
|
|
this.textLayerRenderTask = null; |
|
|
|
this.textLayerRenderTask = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTextContent: function TextLayerBuilder_setTextContent(textContent) { |
|
|
|
|
|
|
|
this.cancel(); |
|
|
|
this.textContent = textContent; |
|
|
|
this.textContent = textContent; |
|
|
|
this.divContentDone = true; |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
convertMatches: function TextLayerBuilder_convertMatches(matches, |
|
|
|
convertMatches: function TextLayerBuilder_convertMatches(matches, |
|
|
@ -3106,6 +3124,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { |
|
|
|
var div = this.textLayerDiv; |
|
|
|
var div = this.textLayerDiv; |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
var expandDivsTimer = null; |
|
|
|
var expandDivsTimer = null; |
|
|
|
|
|
|
|
|
|
|
|
div.addEventListener('mousedown', function (e) { |
|
|
|
div.addEventListener('mousedown', function (e) { |
|
|
|
if (self.enhanceTextSelection && self.textLayerRenderTask) { |
|
|
|
if (self.enhanceTextSelection && self.textLayerRenderTask) { |
|
|
|
self.textLayerRenderTask.expandTextDivs(true); |
|
|
|
self.textLayerRenderTask.expandTextDivs(true); |
|
|
@ -3133,10 +3152,13 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
end.classList.add('active'); |
|
|
|
end.classList.add('active'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
div.addEventListener('mouseup', function (e) { |
|
|
|
div.addEventListener('mouseup', function (e) { |
|
|
|
if (self.enhanceTextSelection && self.textLayerRenderTask) { |
|
|
|
if (self.enhanceTextSelection && self.textLayerRenderTask) { |
|
|
|
expandDivsTimer = setTimeout(function() { |
|
|
|
expandDivsTimer = setTimeout(function() { |
|
|
|
|
|
|
|
if (self.textLayerRenderTask) { |
|
|
|
self.textLayerRenderTask.expandTextDivs(false); |
|
|
|
self.textLayerRenderTask.expandTextDivs(false); |
|
|
|
|
|
|
|
} |
|
|
|
expandDivsTimer = null; |
|
|
|
expandDivsTimer = null; |
|
|
|
}, EXPAND_DIVS_TIMEOUT); |
|
|
|
}, EXPAND_DIVS_TIMEOUT); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -3579,6 +3601,7 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
setDocument: function (pdfDocument) { |
|
|
|
setDocument: function (pdfDocument) { |
|
|
|
if (this.pdfDocument) { |
|
|
|
if (this.pdfDocument) { |
|
|
|
|
|
|
|
this._cancelRendering(); |
|
|
|
this._resetView(); |
|
|
|
this._resetView(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3704,10 +3727,8 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
this._pagesRequests = []; |
|
|
|
this._pagesRequests = []; |
|
|
|
this._pageViewsReady = false; |
|
|
|
this._pageViewsReady = false; |
|
|
|
|
|
|
|
|
|
|
|
var container = this.viewer; |
|
|
|
// Remove the pages from the DOM.
|
|
|
|
while (container.hasChildNodes()) { |
|
|
|
this.viewer.textContent = ''; |
|
|
|
container.removeChild(container.lastChild); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_scrollUpdate: function PDFViewer_scrollUpdate() { |
|
|
|
_scrollUpdate: function PDFViewer_scrollUpdate() { |
|
|
@ -4080,6 +4101,17 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_cancelRendering: function PDFViewer_cancelRendering() { |
|
|
|
|
|
|
|
for (var i = 0, ii = this._pages.length; i < ii; i++) { |
|
|
|
|
|
|
|
if (this._pages[i]) { |
|
|
|
|
|
|
|
this._pages[i].cancelRendering(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param {PDFPageView} pageView |
|
|
|
* @param {PDFPageView} pageView |
|
|
|
* @returns {PDFPage} |
|
|
|
* @returns {PDFPage} |
|
|
|