html2canvas icon indicating copy to clipboard operation
html2canvas copied to clipboard

ERROR Error: Uncaught (in promise): Unable to find element in cloned iframe

Open EnochGao opened this issue 2 years ago • 16 comments

Bug reports:

I found a problem when using Angular. Does the transformed element have to be visible? image

an example on stackblitz.

Specifications:

  • html2canvas version tested with: v1.4.1
  • Browser & version: Chrome v103.0.5060.134
  • Operating system: windows 11

EnochGao avatar Aug 01 '22 07:08 EnochGao

+1

qertis avatar Aug 17 '22 19:08 qertis

Also having this issue with generated svg components in react

kenjicncr avatar Sep 20 '22 00:09 kenjicncr

How to solve this problem?

Fairytale-peng avatar Sep 23 '22 07:09 Fairytale-peng

I had the same issue, not using angular.

In my case the problem was that for some reason, html2canvas didn't like when you do appendChild to body element, but it worked when you prepend rendered element to body. For some reason place of rendered element matters somehow, so if anyone looking for a solution - just try to prepend / append rendered element to a different place.

In case with react / angular / vue it means that you should get rendered element from component, copy it and appened it somewhere else. Hope it helps.

jes490 avatar Nov 15 '22 03:11 jes490

I've reproduced the issue in react with svg build with visx: https://codesandbox.io/s/visx-html2canvas-issue-l7ox9x?file=/src/App.js

Does anyone have an idea, how to fix it?

sebkasanzew avatar Dec 26 '22 20:12 sebkasanzew

I've reproduced the issue in react with svg build with visx: https://codesandbox.io/s/visx-html2canvas-issue-l7ox9x?file=/src/App.js

Does anyone have an idea, how to fix it?

+1

JoeWrights avatar Apr 21 '23 08:04 JoeWrights

Has resolved; Error reason: the issue of DOM rendering timing, the DOM actually fetched by the first parameter of HTML2canvas is the Canvas cache; Solution: A variable is named on the outermost part of the component, and the DOM is reassigned each time inside the component, preventing the cache from being obtained

linpeng118 avatar Jun 17 '23 03:06 linpeng118

Has resolved; Error reason: the issue of DOM rendering timing, the DOM actually fetched by the first parameter of HTML2canvas is the Canvas cache; Solution: A variable is named on the outermost part of the component, and the DOM is reassigned each time inside the component, preventing the cache from being obtained

can you share your implementation

MahendraChandwani avatar Aug 07 '23 09:08 MahendraChandwani

+1

baokuanze avatar Aug 11 '23 07:08 baokuanze

image I found the problem. html2canvas traverses document nodes, but the element nodes projected in angular are not in document

EnochGao avatar Aug 14 '23 01:08 EnochGao

Not only Angular, but many other non-HTML tags report the same error

------------------ 原始邮件 ------------------ 发件人: "niklasvh/html2canvas" @.>; 发送时间: 2023年8月14日(星期一) 上午9:24 @.>; @.@.>; 主题: Re: [niklasvh/html2canvas] ERROR Error: Uncaught (in promise): Unable to find element in cloned iframe (Issue #2929)

I found the problem. html2canvas traverses document nodes, but the element nodes projected in angular are not in document

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

linpeng118 avatar Aug 14 '23 01:08 linpeng118

Also having this issue with generated svg components in react

Same. Issue with generated svgs.

@kenjicncr or anyone, how did you resolve this issue ?

karanshah229 avatar Jan 04 '24 06:01 karanshah229

I get the same issue here , in case the element is in ShadowDOM

vctqs1 avatar Jan 17 '24 11:01 vctqs1

how to solve it

Hao1617 avatar Apr 23 '24 06:04 Hao1617

在反应中生成的 svg 组件也有这个问题

相同的。生成的 svgs 存在问题。

@kenjicncr或者任何人,你是如何解决这个问题的?

how to fix it?

Hao1617 avatar Apr 23 '24 06:04 Hao1617