Skip to content

Instantly share code, notes, and snippets.

@cadecairos
Created November 27, 2012 21:50
Show Gist options
  • Save cadecairos/4157343 to your computer and use it in GitHub Desktop.
Save cadecairos/4157343 to your computer and use it in GitHub Desktop.
function renderPage( options, page ) {
var canvas = options.__canvas,
ctx = canvas.getContext( "2d" ),
viewport = page.getViewport( 1, 0 ),
wActual = options.__wrapperDiv.clientWidth,
hActual = options.__wrapperDiv.clientHeight,
wRatio,
hRatio,
ratio;
renderComplete = false;
canvas.height = hActual;
canvas.width = wActual;
hRatio = canvas.height / viewport.height;
wRatio = canvas.width / viewport.width;
ratio = Math.min( hRatio, wRatio );
canvas.height = viewport.height;
canvas.width = viewport.width;
page.render({
canvasContext: ctx,
viewport: viewport
});
options.__rendered = true;
ctx.scale( wRatio, hRatio );
canvas.height = hActual;
canvas.width = wActual;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment