-3

Is there any way I could turn HTML into an image?

Let's say I made a barcode with HTML and CSS, is there a way I could save it as an image using JavaScript?

For example: Save anything inside #saveImage as an image.

<div id="saveImage">Save this text as an image</div>
unbindall
  • 514
  • 1
  • 13
  • 29
  • 1
    Good thing you searched, http://stackoverflow.com/questions/4912092/using-html5-canvas-javascript-to-take-screenshots/6678156#6678156 – Waxi Feb 03 '15 at 21:41

1 Answers1

1

You can render that HTML onto a <canvas> and then use canvas.toDataURL to get an image. See: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas

Daniel Weiner
  • 1,874
  • 12
  • 19