Created
October 27, 2018 14:48
-
-
Save amundo/655f0be4e8abe5c5bd67d9f6dd86ea49 to your computer and use it in GitHub Desktop.
loading a pdf and rendering a page with pdf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pdfjsLib.getDocument('helloworld.pdf') | |
.then(pdf => pdf.getPage(1) | |
.then(page => { | |
var scale = 1.5 | |
var viewport = page.getViewport(scale) | |
var canvas = document.createElement('canvas') | |
var context = canvas.getContext('2d') | |
canvas.height = viewport.height | |
canvas.width = viewport.width | |
var renderContext = { | |
canvasContext: context, | |
viewport: page.getViewport(scale) | |
} | |
page.render(renderContext) | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment