{"action":"closed","issue":{"url":"https://api.github.com/repos/mozilla/pdf.js/issues/9973","repository_url":"https://api.github.com/repos/mozilla/pdf.js","labels_url":"https://api.github.com/repos/mozilla/pdf.js/issues/9973/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/pdf.js/issues/9973/comments","events_url":"https://api.github.com/repos/mozilla/pdf.js/issues/9973/events","html_url":"https://github.com/mozilla/pdf.js/issues/9973","id":349161213,"node_id":"MDU6SXNzdWUzNDkxNjEyMTM=","number":9973,"title":"Render pdf to fixed size?","user":{"login":"Glinkis","id":8037927,"node_id":"MDQ6VXNlcjgwMzc5Mjc=","avatar_url":"https://avatars2.githubusercontent.com/u/8037927?v=4","gravatar_id":"","url":"https://api.github.com/users/Glinkis","html_url":"https://github.com/Glinkis","followers_url":"https://api.github.com/users/Glinkis/followers","following_url":"https://api.github.com/users/Glinkis/following{/other_user}","gists_url":"https://api.github.com/users/Glinkis/gists{/gist_id}","starred_url":"https://api.github.com/users/Glinkis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Glinkis/subscriptions","organizations_url":"https://api.github.com/users/Glinkis/orgs","repos_url":"https://api.github.com/users/Glinkis/repos","events_url":"https://api.github.com/users/Glinkis/events{/privacy}","received_events_url":"https://api.github.com/users/Glinkis/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-09T14:47:40Z","updated_at":"2018-08-09T20:27:23Z","closed_at":"2018-08-09T20:27:23Z","author_association":"NONE","body":"I'm currently writing an [Electron app](https://github.com/Glinkis/reverse-image-finder), which needs to get the `rgba` pixel data from PDF files.\r\nNow the below code I have is working fine, but I was wondering if it's possible to render the pdf to a specific size?\r\n\r\nThis would probably(?) make processing large PDF files faster, as I only need `64x64`worth of pixel data.\r\n\r\n```js\r\nconst create2dContext = (width, height) => {\r\n  const canvas = document.createElement(\"canvas\");\r\n  canvas.width = width;\r\n  canvas.height = height;\r\n  return canvas.getContext(\"2d\");\r\n};\r\n\r\nconst decodePdf = async (imagePath) => {\r\n  const pdf = await PDFJS.getDocument(imagePath);\r\n  const page = await pdf.getPage(1);\r\n\r\n  const viewport = page.getViewport(1);\r\n  const { width, height } = viewport;\r\n\r\n  const canvasContext = create2dContext(width, height);\r\n  await page.render({ canvasContext, viewport });\r\n\r\n  return canvasContext.getImageData(0, 0, width, height);\r\n};\r\n```"}}
{"actor":{"display_login":"timvandermeij"}}