Initialize the textLayerFactory once in BaseViewer.setDocument, rather than repeating it for every page

For reasons that I don't even pretend to understand, the `textLayerFactory` property is determined for *every single* page in the PDF document.
Given that the `TextLayerMode` should be consistent for *all* pages in a document, we obviously could/should define `textLayerFactory` just once instead.
This commit is contained in:
Jonas Jenwald 2020-03-07 22:24:27 +01:00
parent 1fac29d184
commit 3eb4c1940d

View File

@ -453,11 +453,10 @@ class BaseViewer {
const scale = this.currentScale;
const viewport = firstPdfPage.getViewport({ scale: scale * CSS_UNITS });
const textLayerFactory =
this.textLayerMode !== TextLayerMode.DISABLE ? this : null;
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
let textLayerFactory = null;
if (this.textLayerMode !== TextLayerMode.DISABLE) {
textLayerFactory = this;
}
const pageView = new PDFPageView({
container: this._setDocumentViewerElement,
eventBus: this.eventBus,