loadingTask.promise.then(function(doc) { const numPages = doc.numPages; console.log('# Document Loaded'); return doc.getPage(pageNum).then(function(page) { console.log('# Page ' + pageNum); let textContent; return page.getTextContent().then(function(content) { textContent = strings.join(''); console.log(textContent); }).then(function() { writeFile('file.txt', textContent); });
loadingTask.promise.then(function(doc) { const numPages = doc.numPages; lastPromise = doc.getMetadata().then(function (data) { return doc.getPage(pageNum).then(function (page) { return page.getTextContent({normalizeWhitespace:true}).then(function (content) { }).then(function () { lastPromise = lastPromise.then(loadPage.bind(null, i)); }).then(function () { console.log('# End of Document');