AdamH
AdamH

Reputation: 141

Capture screenshot of iframe - html2canvas not working

I have the following iframe:

<iframe name="content" src="" style="position: absolute; left: 0px; top: 28px;" allowtransparency="true" border="0" scrolling="yes" width="100%" frameborder="0" height="90%" id="MyFrame"></iframe>

I simply want to capture a screenshot of the iframe contents as they stand, I've tried html2canvas but it doesn't seem to work. I've tried placing the iframe inside a div but no joy.

I've seen various methods of achieving this using php, but nothing that seems clear. Can anyone shed any light?

Upvotes: 2

Views: 10142

Answers (1)

M. Page
M. Page

Reputation: 2814

It's written in the limitations section of the doc: http://html2canvas.hertzen.com/documentation.html#limitations.

The script doesn't render plugin content such as Flash or Java applets. It doesn't render iframe content either.

Screen capture using JS raises security problems.

Recently I've been trying carota (https://github.com/danielearwicker/carota) with some success to render HTML text on a canvas. However, it only handles a small subset of HTML.

There is also the SVG foreignobjectapproach which makes it possible to render DOM objects in a canvas: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas

Unfortunately, it is not implemented in IE, including IE 11.

Upvotes: 6

Related Questions