|
|
@ -2097,6 +2097,8 @@ Object.defineProperty(exports, "__esModule", { |
|
|
|
}); |
|
|
|
}); |
|
|
|
exports.PDFFindController = exports.FindStates = undefined; |
|
|
|
exports.PDFFindController = exports.FindStates = undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _pdfjs = __w_pdfjs_require__(0); |
|
|
|
|
|
|
|
|
|
|
|
var _ui_utils = __w_pdfjs_require__(1); |
|
|
|
var _ui_utils = __w_pdfjs_require__(1); |
|
|
|
|
|
|
|
|
|
|
|
var FindStates = { |
|
|
|
var FindStates = { |
|
|
@ -2267,38 +2269,39 @@ var PDFFindController = function PDFFindControllerClosure() { |
|
|
|
this.updateUIResultsCount(); |
|
|
|
this.updateUIResultsCount(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
extractText: function PDFFindController_extractText() { |
|
|
|
extractText: function extractText() { |
|
|
|
|
|
|
|
var _this2 = this; |
|
|
|
|
|
|
|
|
|
|
|
if (this.startedTextExtraction) { |
|
|
|
if (this.startedTextExtraction) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.startedTextExtraction = true; |
|
|
|
this.startedTextExtraction = true; |
|
|
|
this.pageContents = []; |
|
|
|
this.pageContents.length = 0; |
|
|
|
var extractTextPromisesResolves = []; |
|
|
|
var promise = Promise.resolve(); |
|
|
|
var numPages = this.pdfViewer.pagesCount; |
|
|
|
|
|
|
|
for (var i = 0; i < numPages; i++) { |
|
|
|
var _loop = function _loop(i, ii) { |
|
|
|
this.extractTextPromises.push(new Promise(function (resolve) { |
|
|
|
var extractTextCapability = (0, _pdfjs.createPromiseCapability)(); |
|
|
|
extractTextPromisesResolves.push(resolve); |
|
|
|
_this2.extractTextPromises[i] = extractTextCapability.promise; |
|
|
|
})); |
|
|
|
promise = promise.then(function () { |
|
|
|
} |
|
|
|
return _this2.pdfViewer.getPageTextContent(i).then(function (textContent) { |
|
|
|
var self = this; |
|
|
|
var textItems = textContent.items; |
|
|
|
function extractPageText(pageIndex) { |
|
|
|
var strBuf = []; |
|
|
|
self.pdfViewer.getPageTextContent(pageIndex).then(function textContentResolved(textContent) { |
|
|
|
for (var j = 0, jj = textItems.length; j < jj; j++) { |
|
|
|
var textItems = textContent.items; |
|
|
|
strBuf.push(textItems[j].str); |
|
|
|
var str = []; |
|
|
|
} |
|
|
|
for (var i = 0, len = textItems.length; i < len; i++) { |
|
|
|
_this2.pageContents[i] = strBuf.join(''); |
|
|
|
str.push(textItems[i].str); |
|
|
|
extractTextCapability.resolve(i); |
|
|
|
} |
|
|
|
}); |
|
|
|
self.pageContents.push(str.join('')); |
|
|
|
|
|
|
|
extractTextPromisesResolves[pageIndex](pageIndex); |
|
|
|
|
|
|
|
if (pageIndex + 1 < self.pdfViewer.pagesCount) { |
|
|
|
|
|
|
|
extractPageText(pageIndex + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) { |
|
|
|
|
|
|
|
_loop(i, ii); |
|
|
|
} |
|
|
|
} |
|
|
|
extractPageText(0); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
executeCommand: function PDFFindController_executeCommand(cmd, state) { |
|
|
|
executeCommand: function PDFFindController_executeCommand(cmd, state) { |
|
|
|
var _this2 = this; |
|
|
|
var _this3 = this; |
|
|
|
|
|
|
|
|
|
|
|
if (this.state === null || cmd !== 'findagain') { |
|
|
|
if (this.state === null || cmd !== 'findagain') { |
|
|
|
this.dirtyMatch = true; |
|
|
|
this.dirtyMatch = true; |
|
|
@ -2306,12 +2309,12 @@ var PDFFindController = function PDFFindControllerClosure() { |
|
|
|
this.state = state; |
|
|
|
this.state = state; |
|
|
|
this.updateUIState(FindStates.FIND_PENDING); |
|
|
|
this.updateUIState(FindStates.FIND_PENDING); |
|
|
|
this._firstPagePromise.then(function () { |
|
|
|
this._firstPagePromise.then(function () { |
|
|
|
_this2.extractText(); |
|
|
|
_this3.extractText(); |
|
|
|
clearTimeout(_this2.findTimeout); |
|
|
|
clearTimeout(_this3.findTimeout); |
|
|
|
if (cmd === 'find') { |
|
|
|
if (cmd === 'find') { |
|
|
|
_this2.findTimeout = setTimeout(_this2.nextMatch.bind(_this2), 250); |
|
|
|
_this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), 250); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_this2.nextMatch(); |
|
|
|
_this3.nextMatch(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -2325,6 +2328,8 @@ var PDFFindController = function PDFFindControllerClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
nextMatch: function PDFFindController_nextMatch() { |
|
|
|
nextMatch: function PDFFindController_nextMatch() { |
|
|
|
|
|
|
|
var _this4 = this; |
|
|
|
|
|
|
|
|
|
|
|
var previous = this.state.findPrevious; |
|
|
|
var previous = this.state.findPrevious; |
|
|
|
var currentPageIndex = this.pdfViewer.currentPageNumber - 1; |
|
|
|
var currentPageIndex = this.pdfViewer.currentPageNumber - 1; |
|
|
|
var numPages = this.pdfViewer.pagesCount; |
|
|
|
var numPages = this.pdfViewer.pagesCount; |
|
|
@ -2339,14 +2344,13 @@ var PDFFindController = function PDFFindControllerClosure() { |
|
|
|
this.pageMatches = []; |
|
|
|
this.pageMatches = []; |
|
|
|
this.matchCount = 0; |
|
|
|
this.matchCount = 0; |
|
|
|
this.pageMatchesLength = null; |
|
|
|
this.pageMatchesLength = null; |
|
|
|
var self = this; |
|
|
|
|
|
|
|
for (var i = 0; i < numPages; i++) { |
|
|
|
for (var i = 0; i < numPages; i++) { |
|
|
|
this.updatePage(i); |
|
|
|
this.updatePage(i); |
|
|
|
if (!(i in this.pendingFindMatches)) { |
|
|
|
if (!(i in this.pendingFindMatches)) { |
|
|
|
this.pendingFindMatches[i] = true; |
|
|
|
this.pendingFindMatches[i] = true; |
|
|
|
this.extractTextPromises[i].then(function (pageIdx) { |
|
|
|
this.extractTextPromises[i].then(function (pageIdx) { |
|
|
|
delete self.pendingFindMatches[pageIdx]; |
|
|
|
delete _this4.pendingFindMatches[pageIdx]; |
|
|
|
self.calcFindMatch(pageIdx); |
|
|
|
_this4.calcFindMatch(pageIdx); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|