1

I'm trying to use a canvas element, but the height can't exceed 16384 pixels. If i try with 16385 pixels, I get a IndexSizeError in IE11. This works fine in Chrome. The canvas is used in a PDF generation, and I don't really have time to move the generation to the server.

I've googled a bit, and it seems like the size might be different based on platform and browser.

Is it the browsers assigned memory and memory settings that decide this?

EDIT: I found some information here:

Note  The maximum size of the rendered area on a canvas is from 0,0 to 8192 
x 8192 pixels, regardless of the size of the canvas. For example, a canvas     
is created with a width and height of 8292 pixels. A rectangular fill is 
then applied as "ctx.fillRect (0,0, canvas.width, canvas.height)".Only the 
area within the coordinates (0, 0, 8192, 8192) can be rendered, leaving a 
100 pixel border on the right and bottom of the canvas.

Seem like I can have twice the size. Maybe this is just for IE9.

ptf
  • 3,210
  • 8
  • 34
  • 67

2 Answers2

1

The maximum area, width, and height of an HTML canvas element is dependent on the browser, operating system, and hardware available. Unfortunately, browsers do not provide a way to determine what their limitations are, nor do they provide any kind of feedback after an unusable canvas has been created.

It is possible to detect the canvas limitations of browser, but unfortunately not using native APIs. See my answer in the Maximum size of a <canvas> element thread for details.

John Hildenbiddle
  • 3,115
  • 2
  • 19
  • 14
0

The Canvas Specification states "the element can be sized arbitrarily by a style sheet", so based on this and the information you shared from the link, IE must likely be implementing their own maximum size. This seems useful, but does not provide any sources to back up the numbers shown (the favourite answer).

jburtondev
  • 2,827
  • 1
  • 14
  • 20
  • I'm guessing the sizes have been adjusted since I have no problems with a height of `20184` in Chrome. The size in IE11 might have been increased at some point as well. Thanks! – ptf Sep 04 '17 at 14:41
  • I see, no problem! – jburtondev Sep 04 '17 at 14:53