Convert examples/learning/helloworld64.html to await/async

This commit is contained in:
michael-ikwuegbu 2021-10-15 17:38:10 +01:00
parent 6863f36880
commit ec5e7445f6

View File

@ -40,9 +40,10 @@
// Opening PDF by passing its binary data as a string. It is still preferable
// to use Uint8Array, but string or array-like structure will work too.
var loadingTask = pdfjsLib.getDocument({ data: pdfData, });
loadingTask.promise.then(function(pdf) {
(async function() {
var pdf = await loadingTask.promise;
// Fetch the first page.
pdf.getPage(1).then(function(page) {
var page = await pdf.getPage(1);
var scale = 1.5;
var viewport = page.getViewport({ scale: scale, });
// Support HiDPI-screens.
@ -64,12 +65,11 @@
// Render PDF page into canvas context.
var renderContext = {
canvasContext: context,
transform: transform,
viewport: viewport,
transform,
viewport,
};
page.render(renderContext);
});
});
})();
</script>
<hr>