Are you calling it from JavaScript?
If not, then no.
-Boris
I have just embedded gecko in java application .From the
nsIDOMDocument I get nsIDOMHTMLCanvasElement's and the do a
drawWindow() and then use canvas toDataURL method.
nsIDOMDocument doc = win.getDocument();
nsIDOMNode iframe =
doc.getElementsByTagName("iframe").item(0);
nsIDOMNSHTMLFrameElement iframeelem =
(nsIDOMNSHTMLFrameElement)iframe.queryInterface(nsIDOMNSHTMLFrameElement.NS_IDOMNSHTMLFRA
MEELEMENT_IID);
nsIDOMWindow window=iframeelem.getContentWindow();
nsIDOMNode n =
doc.getDocumentElement().getElementsByTagName("canvas").item(0);
nsIDOMHTMLCanvasElement canElem =
(nsIDOMHTMLCanvasElement)
n.queryInterface(nsIDOMHTMLCanvasElement.NS_IDOMHTMLCANVASELEMENT_I
ID);
nsISupports support = canElem.getContext("2d");
nsIDOMCanvasRenderingContext2D context =
(nsIDOMCanvasRenderingContext2D)support.queryInterface(nsIDOMCanvasRenderingContext2D.
NS_IDOMCANVASRENDERINGCONTEXT2D_IID);
context.clearRect(0,0,600,800);
context.save();
context.scale(1,1);
context.drawWindow(window,0, 0, 600,500,"blue");
context.restore();
String url = context.getCanvas().toDataURL();
I could see the iframe window content getting drawn on the canvas.
Will this not work?.If yes why.
Thanks for your response.
regards,
Krithi
It will not. toDataURL only works when called from JavaScript.
-Boris