From ca1766728bb6175728a212f712557cd6cdea9635 Mon Sep 17 00:00:00 2001 From: Eunchong Yu Date: Tue, 15 Apr 2014 22:45:27 +0900 Subject: [PATCH] Correct the type of PDFDocumentProxy.numPages and .fingerprint The type of them is a property, not a function or a method. Reference: - API spec: https://github.com/mozilla/pdf.js/blob/305274cd45ed3b4931f983b31ebd4ffb999fb4c6/test/unit/api_spec.js#L45-L50 - Impl: https://github.com/mozilla/pdf.js/blob/816f2f7e1dc604d52bbde29eb9357360dbeddbbe/src/core/core.js#L476 and #L512 --- pdf/pdf-tests.ts | 20 ++++++++++++++++++-- pdf/pdf.d.ts | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pdf/pdf-tests.ts b/pdf/pdf-tests.ts index 90542b503..615730780 100644 --- a/pdf/pdf-tests.ts +++ b/pdf/pdf-tests.ts @@ -3,9 +3,18 @@ // // Fetch the PDF document from the URL using promises // +var pdfDoc: PDFDocumentProxy; +var pageNum: number; + PDFJS.getDocument('helloworld.pdf').then(function (pdf) { // Using promise to fetch the page - pdf.getPage(1).then(function (page) { + pdfDoc = pdf; + pageNum = 1; + renderPage(pageNum); +}); + +function renderPage(pageNum: number) { + pdfDoc.getPage(pageNum).then(function (page) { var scale = 1.5; var viewport = page.getViewport(scale); @@ -26,4 +35,11 @@ PDFJS.getDocument('helloworld.pdf').then(function (pdf) { }; page.render(renderContext); }); -}); +} + +function goNext() { + if (pdfDoc && pageNum < pdfDoc.numPages) { + ++pageNum; + renderPage(pageNum); + } +} diff --git a/pdf/pdf.d.ts b/pdf/pdf.d.ts index bd66604f4..94733c3e3 100644 --- a/pdf/pdf.d.ts +++ b/pdf/pdf.d.ts @@ -74,12 +74,12 @@ interface PDFDocumentProxy { /** * Total number of pages the PDF contains. **/ - numPages(): number; + numPages: number; /** * A unique ID to identify a PDF. Not guaranteed to be unique. [jbaldwin: haha what] **/ - fingerprint(): string; + fingerprint: string; /** * True if embedded document fonts are in use. Will be set during rendering of the pages.