Skip to content
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

html2canvas not work when the html contains a canvas element #1311

Closed
mengwuhen opened this issue Dec 13, 2017 · 35 comments
Closed

html2canvas not work when the html contains a canvas element #1311

mengwuhen opened this issue Dec 13, 2017 · 35 comments
Labels

Comments

@mengwuhen
Copy link

mengwuhen commented Dec 13, 2017

Bug reports:

I am using html2canvas in a react Project. I found that html2canvas not work when the html contains a canvas element. The canvas area will show empty.

Specifications:

this is the html picture
image

this is the convert to canvas picture

image

in the canvas area , I use 'echarts-for-react' to draw a Radar map。But when I clcik Generate pictures Button , the dowload picture is not complete

  • html2canvas version tested with: 1.0.0-alpha.4
  • Browser & version: Chrome 60.0.3112.7
  • Operating system: windows
@bigfacewo
Copy link

I have the same problem.

@niklasvh
Copy link
Owner

Could you share an example on jsfiddle?

@outerbound
Copy link

same problem. i have chartjs graphs on page, they are no longer rendering. used to render in previous version

@outerbound
Copy link

outerbound commented Dec 14, 2017

I have created a fiddle to show the problem
https://jsfiddle.net/outerbound/v7p71wzr/

This is not working on chrome :( , I can confirm on safari it working :)

@ZeroGravity100500
Copy link

problem is in removing container form DOM before rendering

@JasonDung
Copy link

I have the same problem. marker...

@bigfacewo
Copy link

Maybe html2canvas can not work with gridstack.js

@NanChen6
Copy link

Had the same problem with using chart.js with vue(vue-chart.js) and it only happens in Chrome

@wangyunzhu
Copy link

I have the same problem, html2canvas can not work with gridstack.js, when i use html2canvans with gridstack, all elements get stacked at the top.
image

@bigfacewo
Copy link

bigfacewo commented Dec 19, 2017

@Nemo0915 I build a jsfiddle with gridstack.js, but it's work fine.So maybe that is not gridstack.js's problem,but i am not very sure.

@ArrayZheng
Copy link

same problem,Firefox is ok but Chorme can not work

@wangyunzhu
Copy link

@bigfacewo thanks for your reply,it's the screenshot of your jsfiddle, the button has been stacked to the top too, and the result is same whether in FF or Chrome.
image

@bigfacewo
Copy link

bigfacewo commented Dec 20, 2017

@Nemo0915 I found the 0.5.0-beta4 version work normal,jsfiddle. the screenshot is:
qq 20171220150328
The 1.0.0-alpha4 version,jsfiddle,it's can not work on chrome, But i didn't find the problem that the elements were stacked on the top. this is the screenshot on Firefox:
qq 20171220150946

Chrome version:63.0.3239.108
Firefox version:57.0.2

@IxAres
Copy link

IxAres commented Dec 20, 2017

you can add option: removeContainer: false to fixed this problem temporarily....

@NanChen6
Copy link

Thanks @IxAres, it solves my problem.

@niklasvh
Copy link
Owner

Fixed in 38749bc

@omeriko
Copy link

omeriko commented Oct 6, 2019

i've tried adding removeContainer: false, but the problem still exists on mobile Chrome

@nehachaudhary
Copy link

@niklasvh it doesn't work at all. I am using version 1.0.0-rc.5 of this application.
Screenshot 2020-02-17 at 10 54 42 AM

@steele-cjf
Copy link

hey,what solution?

@MrG2333
Copy link

MrG2333 commented Apr 14, 2020

2020 the problem is still here.

@VaguelyOnline
Copy link

+1 I'm also seeing this behaviour.

@IAmRC1
Copy link

IAmRC1 commented May 12, 2020

Problem still exists

@g0d0
Copy link

g0d0 commented May 12, 2020

Problem still exists with Chart.js and Firefox 76.0 (64-bit) browser

@Rajeshgtstpl
Copy link

Rajeshgtstpl commented Jul 10, 2020

Hey there I am getting the same issue with Mapbox inside the element can you please help here.
I have also tried removeContainer: false but it didn't work for me.

@AchoArnold
Copy link

@Rajeshgtstpl I had a similar issue with mapbox. I solved it by setting preserveDrawingBuffer: true in the mapbox options.

@andreassoegaard
Copy link

andreassoegaard commented Aug 7, 2020

I'm not using Chart.js, but had the same problem with canvases where i used drawImage. Solved the issue by putting image.crossOrigin = 'anonymous' on the image element before passing it to drawImage, like this:

image.crossOrigin = 'anonymous'

Hope it can help someone :)

@tejasdotchavan
Copy link

tejasdotchavan commented Aug 25, 2020

Hi guys, I am having similar canvas export issue but with a threejs scene, any recommendations? I have tried with the v1.0.0-rc.7 but it exports everything but the threejs canvas.

EDIT: I tried to add in the threejs canvas like this:

image

But got this error:

image

@jimmyangel
Copy link

@AchoArnold preserveDrawingBuffer: true worked for me for Mapbox, thanks.

Question: have you noticed a performance impact?

@Nurbek0525
Copy link

I'm not using Chart.js, but had the same problem with canvases where i used drawImage. Solved the issue by putting image.crossOrigin = 'anonymous' on the image element before passing it to drawImage, like this:

image.crossOrigin = 'anonymous'

Hope it can help someone :)

it saved my life thanks

@SalahAdDin
Copy link

I'm not using Chart.js, but had the same problem with canvases where i used drawImage. Solved the issue by putting image.crossOrigin = 'anonymous' on the image element before passing it to drawImage, like this:
image.crossOrigin = 'anonymous'
Hope it can help someone :)

it saved my life thanks

It does not work.

@sachin-sprinkle
Copy link

Is there any fix for this?? Still facing this issue.

@SalahAdDin
Copy link

Is there any fix for this?? Still facing this issue.

We had to use a proxy server to avoid this problem.

@rishhavv
Copy link

Found any fix?

@arvind-kumar-esri
Copy link

preserveDrawingBuffer: true

Where we add this into code

@linilini
Copy link

于38749bc修复

The statistical chart is good in Chrome, but there is a problem with Safari and the statistical chart is not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests