Comments (17)
Were you able to solve this issue @AnnoyingTechnology ?
Hi, sadly no. I had to use a workaround without using an iframe.
The workaround being : using Google Street View static image API.
from dom-to-image-more.
@IDisposable Here is the fix
https://github.com/ransomsumit/dom-to-image/blob/master/src/dom-to-image.js
from dom-to-image-more.
Try to use toPng, I get a black picture too when I use toJpeg, but work well in toPng
from dom-to-image-more.
Thanks for the tip. But this had already been tried without success.
from dom-to-image-more.
Were you able to solve this issue @AnnoyingTechnology ?
from dom-to-image-more.
Does adding allow="accelerometer; magnetometer; gyroscope"
to the iframe work? That would allow the device sensors inside third-party domain loaded scripts.
from dom-to-image-more.
Hey Guys, i just found a big bug with the instanceof checks in the source code.
Trying instanceof with a dom element situated inside an iframe on window prototypes gives false on chrome but gives true on firefox.
Fixing this solved my issue with iframes.
from dom-to-image-more.
@ransomsumit Did you have a PR or a general fix or more details you would like to contribute?
from dom-to-image-more.
Thanks! I've generalized it a bit more to reach up into the contentWindow as needed. Can you confirm that the version in PR #80 works for you so I can make a general release?
from dom-to-image-more.
No it doesn't work properly. it's missing out on styles for several tags. @IDisposable
from dom-to-image-more.
Any suggestion as to what we're missing? I would love to roll out a fix.
from dom-to-image-more.
The one thing I noticed is that some tags For ex. < g > gives out false on instanceof check within the frame for some reason but gives true on root window. So the fail safe will be to check instanceof on root window and the frame window at the same time with proper condition. My fix is working fine with this.
Currently,
I am tackling some weird image event error with makeimage function, if you have any context please tell. @IDisposable
from dom-to-image-more.
I've pushed up some more extensive cleanup, mostly around the finding of the owner window object and also fixed a really silly issue with class name generation used when copying over any ::before
or ::after
attributes.
Please pull the branch again and see if I've got it working. If you can give me a repro that show the error, I can fix it faster (follow the pattern in the unit testes... an HTML, a CSS, (optionally) a control-image.
from dom-to-image-more.
Maybe it's because iframe has loading=lazy
attribute
from dom-to-image-more.
Parallel to the iframe
feature request:
getComputedStyle
recomputes layout. We want to target recomputes to the element's window, not `global || window`.
I believe the internal implementation in Blink:
- reaches up from
element.ownerDocument.defaultView
back toglobal || window
making this change a 5-10% slight slowdown - also that
window.getComputedStyle
triggers a layout recompute in iframes anyway
It just seems more robust to be using the window that's the immediate context of the element itself. We could do this in #108 or when we implement iframes.. if the latter, let's add it to this PR.
from dom-to-image-more.
For iframe cloning:
- We should first check if there is an srcdoc because that is usually inlined as a higher priority than the
<iframe>
src
. - Same origin =
iframe.contentDocument
is available: we can attempt a jump fromiframe
toiframe.contentDocument
when getting the children. Similar to #101. Otherwise there should be the option to fetch the HTML ofsrc
via XHR and inline it.
from dom-to-image-more.
Resources inside the cloned iframe document don't load after the XHR. So cross-origin support is a no-no.
I believe Google Street View is always a cross-origin embed/iframe so it's impossible to take a screenshot of without retooling some kind of advanced browser API and requiring user input after the toSvg
call.
from dom-to-image-more.
Related Issues (20)
- Can I use this library without npm or module? Just plain html HOT 2
- On firefox toPng returns empty image HOT 1
- make it posible to shift
- Icon to image display failed HOT 1
- TypeError: Cannot read properties of undefined (reading 'setProperty')
- Error using toPng with extra quote in HTML
- The internal picture is blank HOT 2
- border HOT 10
- Cannot convert webgl
- Need embed fonts to be optional
- Browser crashes when using toPng
- Image is cropped in Firefox HOT 3
- cssRules from google CSS breaking HOT 1
- TypeError:Failed to execute 'readAsDataURL' on 'FileReader' : parameter 1 is not of type 'Blob' HOT 7
- Bug: get wrong pic from image jsp
- domtoimage doesn't work on vector layer
- Exporting blank image when element's parent has visibility hidden
- Dom-to-image conversion results misaligned content in Image for CSS flex styles
- domtoImage converts only first child element when cloneNode(true) is used
- Unavaible to override existing CSS style within the adjustClone function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dom-to-image-more.