mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Convert examples/components/pageviewer.js to await/async (issue 14127)
This commit is contained in:
parent
70fc30d97c
commit
711fbe1376
1 changed files with 23 additions and 23 deletions
|
@ -47,9 +47,10 @@ const loadingTask = pdfjsLib.getDocument({
|
|||
cMapPacked: CMAP_PACKED,
|
||||
enableXfa: ENABLE_XFA,
|
||||
});
|
||||
loadingTask.promise.then(function (pdfDocument) {
|
||||
(async function () {
|
||||
const pdfDocument = await loadingTask.promise;
|
||||
// Document loaded, retrieving the page.
|
||||
return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) {
|
||||
const pdfPage = await pdfDocument.getPage(PAGE_TO_VIEW);
|
||||
// Creating the page view with default parameters.
|
||||
const pdfPageView = new pdfjsViewer.PDFPageView({
|
||||
container,
|
||||
|
@ -70,5 +71,4 @@ loadingTask.promise.then(function (pdfDocument) {
|
|||
// Associate the actual page with the view, and draw it.
|
||||
pdfPageView.setPdfPage(pdfPage);
|
||||
return pdfPageView.draw();
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue