html2canvas icon indicating copy to clipboard operation
html2canvas copied to clipboard

Images are not properly generated on v1.4.0

Open Ayush-gupta-josh opened this issue 4 years ago • 14 comments

Please make sure you are testing with the latest release of html2canvas. Old versions are not supported and issues reported for them will be closed.

Please follow the general troubleshooting steps first:

  • [x] You are using the latest version
  • [x] You are testing using the non-minified version of html2canvas and checked any potential issues reported in the console

Bug reports:

I am facing an with 1.4.0 version. Canvas is not properly generated on on this. when 1 am using vesion 1.3.3 my feature works fine but after we switch to v1.4.0 its is not generating complete canvas with proper height canvas. Canvas height always remain 1px

Images on v1.4.0 Movements_Barchart_view (27) pdf Image on v1.3.3 Movements_Barchart_view (31) pdf

Specifications:

  • html2canvas version tested with:
  • Browser & version:
  • Operating system:

Ayush-gupta-josh avatar Jan 06 '22 11:01 Ayush-gupta-josh

uninstall grammarly chrome extension, then all will be normal again

K0wd avatar Jan 10 '22 01:01 K0wd

卸载语法Chrome扩展,然后一切都会再次正常

How to uninstall grammarly chrome extension?

jacky-yanglei avatar Jan 11 '22 10:01 jacky-yanglei

uninstall grammarly chrome extension, then all will be normal again

How to uninstall grammarly chrome extension? @K0wd

jacky-yanglei avatar Jan 11 '22 10:01 jacky-yanglei

uninstall grammarly chrome extension, then all will be normal again

How to uninstall grammarly chrome extension? @K0wd

https://www.youtube.com/watch?v=j1yfnO9Eomc @jacky-yanglei

K0wd avatar Jan 11 '22 10:01 K0wd

I don't install grammarly chrome extension, I still have the same problem. @K0wd

jacky-yanglei avatar Jan 12 '22 02:01 jacky-yanglei

remark

wang1006tao avatar Jan 24 '22 09:01 wang1006tao

uninstall grammarly chrome extension, then all will be normal again

Just spent several hours trying to figure out why it would render properly on load but not on function call. Figured I'd try this on a whim, worked like a charm. Seems really bizarre, but I guess grammarly was somehow conflicting with this?

Xenotater avatar Feb 02 '22 02:02 Xenotater

I don't install grammarly chrome extension, I still have the same problem.

Try uninstalling other extensions, or try in incognito. @jacky-yanglei

moshefortgang avatar Feb 09 '22 10:02 moshefortgang

uninstall grammarly chrome extension, then all will be normal again

same here! thanks 👍🏽

filoscoder avatar Feb 17 '22 09:02 filoscoder

There seems to be an issue with Grammarly and the Shadow DOM, so in order to workaround it, you need to skip the elements which are not properly created:

function fnIgnoreElements(el: any) {
  return typeof el.shadowRoot === "object" && el.shadowRoot !== null
}

const canvas = await html2canvas(input, {
	ignoreElements: fnIgnoreElements,
})

ospfranco avatar Feb 17 '22 13:02 ospfranco

I have also encountered this issue with grammarly and html2canvas 1.4.1

prij avatar Feb 22 '22 06:02 prij

I confirm that @ospfranco solution fixed the problem with the Grammarly Chrome Extension. Thanks!

Grammarly Chrome Extension - 14.1050.0 html2canvas - 1.4.1

antoniotorres avatar Feb 22 '22 17:02 antoniotorres

@antoniotorres I encountered it only recently (yesterday) on 1.4.1, but I don’t know which version of the Grammarly was causing issue.

Issue: Chrome profile with Grammarly installed was not saving and generating base64 encoding for images using html2canvas correctly. Worked ok after Grammarly was uninstalled.

I reverted back to html2canvas 1.3.4 which works ok. I will try again with 1.4.1.

prij avatar Feb 22 '22 19:02 prij

There seems to be an issue with Grammarly and the Shadow DOM, so in order to workaround it, you need to skip the elements which are not properly created:

function fnIgnoreElements(el: any) {
  return typeof el.shadowRoot === "object" && el.shadowRoot !== null
}

const canvas = await html2canvas(input, {
	ignoreElements: fnIgnoreElements,
})

I confirm that too

I will add:

if you are using jspdf and .html() method, make sure to pass the ignoreElements() as follow

doc.html(pdf_el, {
	callback: function (doc) {
		// Save the PDF
		doc.save('search_result.pdf');
	},
	// ...
	html2canvas: { // <<<<<<------- html2canvas options
		ignoreElements(el) {
			return typeof el.shadowRoot === 'object' && el.shadowRoot !== null;
		},
	},
});

MohamedLamineAllal avatar Sep 24 '24 13:09 MohamedLamineAllal