{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/pdf.js/issues/7120","repository_url":"https://api.github.com/repos/mozilla/pdf.js","labels_url":"https://api.github.com/repos/mozilla/pdf.js/issues/7120/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/pdf.js/issues/7120/comments","events_url":"https://api.github.com/repos/mozilla/pdf.js/issues/7120/events","html_url":"https://github.com/mozilla/pdf.js/issues/7120","id":143773325,"number":7120,"title":"Function to get PDF file details","user":{"login":"JohnEwen","id":18095148,"avatar_url":"https://avatars.githubusercontent.com/u/18095148?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnEwen","html_url":"https://github.com/JohnEwen","followers_url":"https://api.github.com/users/JohnEwen/followers","following_url":"https://api.github.com/users/JohnEwen/following{/other_user}","gists_url":"https://api.github.com/users/JohnEwen/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnEwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnEwen/subscriptions","organizations_url":"https://api.github.com/users/JohnEwen/orgs","repos_url":"https://api.github.com/users/JohnEwen/repos","events_url":"https://api.github.com/users/JohnEwen/events{/privacy}","received_events_url":"https://api.github.com/users/JohnEwen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-27T03:49:16Z","updated_at":"2016-03-27T09:15:31Z","closed_at":"2016-03-27T09:15:31Z","body":"I would like a simple function that can extract the number of pages, width and height of a PDF document using pdf.js but avoiding the use of promises.\r\n\r\nThe following works:\r\n\r\n\tPDFJS.getDocument(PDFDoc).then(function(pdf){\r\n\t\tpdf.getPage(1).then(function(page) {\r\n\t\t\tvar v=page.getViewport(1);\r\n\t\t\tPAGES=pdf.numPages;\r\n\t\t\tWIDTH=v.width;\r\n\t\t\tHEIGHT=v.height;\r\n\t\t});\r\n\t});\r\n\r\nbut I would like the values to be immediately available without having to bury all the rest of my code in a function called after HEIGHT has been calculated.\r\n"},"comment":{"url":"https://api.github.com/repos/mozilla/pdf.js/issues/comments/202022843","html_url":"https://github.com/mozilla/pdf.js/issues/7120#issuecomment-202022843","issue_url":"https://api.github.com/repos/mozilla/pdf.js/issues/7120","id":202022843,"user":{"login":"Snuffleupagus","id":2692120,"avatar_url":"https://avatars.githubusercontent.com/u/2692120?v=3","gravatar_id":"","url":"https://api.github.com/users/Snuffleupagus","html_url":"https://github.com/Snuffleupagus","followers_url":"https://api.github.com/users/Snuffleupagus/followers","following_url":"https://api.github.com/users/Snuffleupagus/following{/other_user}","gists_url":"https://api.github.com/users/Snuffleupagus/gists{/gist_id}","starred_url":"https://api.github.com/users/Snuffleupagus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Snuffleupagus/subscriptions","organizations_url":"https://api.github.com/users/Snuffleupagus/orgs","repos_url":"https://api.github.com/users/Snuffleupagus/repos","events_url":"https://api.github.com/users/Snuffleupagus/events{/privacy}","received_events_url":"https://api.github.com/users/Snuffleupagus/received_events","type":"User","site_admin":false},"created_at":"2016-03-27T09:15:31Z","updated_at":"2016-03-27T09:15:31Z","body":"The PDF.js API is written in order to allow ranged/chunked loading of PDF files, which is necessary to be able start rendering without having to wait for the entire PDF file to be downloaded first.\r\nIn order to achieve that, all of the API methods must be *asynchronous*, which is why Promises are used heavily in PDF.js.\r\nIt's neither possible, nor wanted, to convert parts of the API to be synchronous. Also, if anything the API/Core parts of PDF.js have only been getting more asynchronous over time.\r\n\r\nClosing as answered, and out of scope for the library."}}