mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Add page size to the document properties dialog
This commit is contained in:
parent
5f98f9b8f1
commit
8558c5b1d9
5 changed files with 69 additions and 2 deletions
|
@ -626,6 +626,23 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|||
getMetadata: function PDFDocumentProxy_getMetadata() {
|
||||
return this.transport.getMetadata();
|
||||
},
|
||||
/**
|
||||
* @param {number} pageNumber The page number to get the page size from.
|
||||
* The first page is 1, which is also the default page used.
|
||||
* @return {Promise} A promise that is resolved with an dict containing the
|
||||
* width and height in inches.
|
||||
*/
|
||||
getPageSizeInches(pageNumber) {
|
||||
pageNumber = pageNumber || 1;
|
||||
return this.getPage(pageNumber).then((page) => {
|
||||
const [x1, y1, x2, y2] = page.view;
|
||||
// convert values from user units to inches
|
||||
return {
|
||||
width: (x2 - x1) / 72 * page.userUnit,
|
||||
height: (y2 - y1) / 72 * page.userUnit,
|
||||
};
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @return {Promise} A promise that is resolved with a TypedArray that has
|
||||
* the raw data from the PDF.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue