Just place the canvas inside the wrapper <div>and set its visualized size relative to the wrapper. You can then set the logical size of the canvas to the size of the viewport to achieve high dots per inch without changing its actual size on the screen. For example,
var scale = 5;
var viewport = page.getViewport(scale);
canvas.width = viewport.width;
canvas.height = viewport.height;
canvas.style.width = "100%";
canvas.style.height = "100%";
wrapper.style.width = Math.floor(viewport.width/scale) + 'pt';
wrapper.style.height = Math.floor(viewport.height/scale) + 'pt';
source
share