Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Take screenshot of a page containing an iframe

We have a nodeJS/angular 4 website which is displaying an iframe from a third party (powerBI Emebdded). We are trying to get develop a feature allowing the end user to take a screenshot of the page including the content of the iframe.

We tried the iframe2image library: https://github.com/twolfson/iframe2image

But we are facing the issue of the same origin policy:

ERROR DOMException: Blocked a frame with origin http://localhost:4200
from accessing a cross-origin frame

As we have no access to the iframe (it's a third party content generated by PowerBI iframe with a dedicated library). We can not bypass the policy by setting the window.document.domain in the iframe to the same domain.

Do you have a solution to suggest us?

like image 284
romain-nio Avatar asked Oct 18 '18 08:10

romain-nio


People also ask

How do I get an iframe from HTML?

contentWindow. document. body. innerHTML: It returns the HTML content of iframe body.


1 Answers

I think this is absolutely not possible, because there is no way to access the elements of the iframe's document. But access to this elements is necessary because all libraries which are rendering html to any form of image need to resolve the Elements inside the document to get the visuals out of it.

like image 163
Sandro Schaurer Avatar answered Oct 02 '22 19:10

Sandro Schaurer