mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-06 16:20:26 +08:00
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
This commit is contained in:
+18
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user