mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Convert PDFDocumentLoadingTask
, in src/display/api.js
, to an ES6 class
Also deprecates the `then` method, in favour of the `promise` getter.
This commit is contained in:
parent
5f15dc2023
commit
ef8e5fd77c
14 changed files with 82 additions and 68 deletions
|
@ -28,11 +28,12 @@
|
|||
//
|
||||
// Asynchronous download PDF
|
||||
//
|
||||
pdfjsLib.getDocument(url).then(function getPdfHelloWorld(pdf) {
|
||||
var loadingTask = pdfjsLib.getDocument(url);
|
||||
loadingTask.promise.then(function(pdf) {
|
||||
//
|
||||
// Fetch the first page
|
||||
//
|
||||
pdf.getPage(1).then(function getPageHelloWorld(page) {
|
||||
pdf.getPage(1).then(function(page) {
|
||||
var scale = 1.5;
|
||||
var viewport = page.getViewport(scale);
|
||||
|
||||
|
|
|
@ -39,9 +39,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.
|
||||
pdfjsLib.getDocument({data: pdfData}).then(function getPdfHelloWorld(pdf) {
|
||||
var loadingTask = pdfjsLib.getDocument({data: pdfData});
|
||||
loadingTask.promise.then(function(pdf) {
|
||||
// Fetch the first page.
|
||||
pdf.getPage(1).then(function getPageHelloWorld(page) {
|
||||
pdf.getPage(1).then(function(page) {
|
||||
var scale = 1.5;
|
||||
var viewport = page.getViewport(scale);
|
||||
|
||||
|
|
|
@ -117,7 +117,8 @@
|
|||
/**
|
||||
* Asynchronously downloads PDF.
|
||||
*/
|
||||
pdfjsLib.getDocument(url).then(function (pdfDoc_) {
|
||||
var loadingTask = pdfjsLib.getDocument(url);
|
||||
loadingTask.promise.then(function(pdfDoc_) {
|
||||
pdfDoc = pdfDoc_;
|
||||
document.getElementById('page_count').textContent = pdfDoc.numPages;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue