Resize the canvas with fabric js

fabricjs, html5-canvas, javascript

Solution

Previously answered here.

I'm not sure what you've been trying, but

var canvas = document.getElementsByTagName('canvas')[0];
canvas.width  = 800;
canvas.height = 600;

should work fine.

Problem

The application lets user save the designs and post it so other users can view it later. The original canvas saved with the proportions of width=700 and height=600. But when displaying the canvas, I want to resize the canvas to fit into dimensions of (350,300). half of the original. But if I directly apply those dimensions and load width setWidth() and setHeight() it loads with original proportions. All I want is to display the canvas with new dimensions.

Original source

Related problems