New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Element styling only for html2canvas? #701
Comments
You can modify the contents of the document (which is a clone of the original) that will get rendered with the
|
Thanks Nik! Greatly appreciate your work on this library. Is this in the documentation? |
No, unfortunately not. The documentation is greatly lacking in many respects at the moment... |
My downloaded image isn't getting the proper styling so I'm using computed-style-to-inline-style to render it properly by converting all the styling to inline css. But the issue with that is it's affecting the original dom. So I want to do it for the cloned element instead inside the onclone function but it's not working and the image isn't properly styled. Any idea why it's happening? |
I tried to do the same thing, here is how I implemented it and all my styles were properly downloaded:
|
another way, my solution: add to element for example : onclone: (document) => {
const els = document.querySelectorAll(
'[data-html2canvas-class]',
) as NodeListOf<HTMLElement>
els.forEach((el) => {
const payloadClasses = el.getAttribute('data-html2canvas-class')
if (payloadClasses) {
el.className = [el.className.trim(), payloadClasses.trim()].join(
' ',
)
}
})
}, |
I'm using the handy
data-html2canvas-ignore
tag on a few elements, but Firefox is giving me problems with elements with negative margins. I'd like to be able to add an html2canvas-only style tag for a particular element, such as:data-html2canvas-style="margin-left: 0"
.Has anyone else had any luck doing something like this?
The text was updated successfully, but these errors were encountered: