Html2Canvas foreignObjectRendering only render viewpoint

一笑奈何 提交于 2019-12-23 18:36:35

问题


I'm currently having issues while rendering complex DIV element into CANVAS element using Html2Canvas package. The problem is the DIV I want to write to the CANVAS, has

overflow: auto 

So the DIV is bigger than the screen ratio. and to add gasoline to the fire, all described above is in the Angular 5 component, what means the CSS isn't available while I'm accessing to ElementRef.nativeElement.innerHTML.

Encapsulation.None didn't work for me here either.

HTML to canvas settings:

  async: true,
  logging: false,
  backgroundColor: null,
  allowTaint: true,
  foreignObjectRendering: true,
  removeContainer: true

result:

make attention to the black space around the image, is the screen ratio, but it couldn't be rendered.

While I'm setting:

foreignObjectRendering: false

I'm getting very satisfying quality and the dimensions I want. but the diagrams look like this:

Thanks in advance! this is very important to me. And I guarantee that if I will resolve this, I'll create a very useful NPM package to export elements as PDF file at Angular 2+

Also attaching Html2Canvas documentation for your convenient: http://html2canvas.hertzen.com/configuration/

来源:https://stackoverflow.com/questions/53563864/html2canvas-foreignobjectrendering-only-render-viewpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!