Workaround for <foreignObject> that is not supported in IE

tuchfeld
tuchfeld used Ask the Experts™
on
Hello,
Can you please direct me how to do so?
The folowing code works just fine in Chrome.
Thanks, Aryeh.
function html_to_img(html) {
  var data = '<svg xmlns="http://www.w3.org/2000/svg" width="' + 400 + '" height="' + 200 + '">' +
          '<foreignObject width="100%" height="100%">' +
          '<div xmlns="http://www.w3.org/1999/xhtml" style="font-size:18px; font-family: david; word-wrap: break-word;">' +
          html +
          '</div>' +
          '</foreignObject>' +
          '</svg>';

  var DOMURL = window.URL || window.webkitURL || window;
  var svg = new Blob([data], { type: 'image/svg+xml;charset=utf-8' });
  var url = DOMURL.createObjectURL(svg);
  img.src = url; // some Image Element.
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Manager / Solutions Architect
Commented:
I think this isn't possible.
Have you tried HTML2Canvas?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial