Html2canvas: Fonts are not loaded when using html2canvas within an iframe

Created on 13 Mar 2019  ·  3Comments  ·  Source: niklasvh/html2canvas

Hi all, I'm having a similar issue to this one: https://github.com/niklasvh/html2canvas/issues/328.
I created a widget that uses html2canvas to take a screenshot. The problem is that the widget must be inserted in a site inside an iframe, the capture works but the fonts don't load. Here is a simple example of what happens: test-case-iframe

Specifications:

  • html2canvas version tested with: v1.0.0-alpha.12
  • Browser & version: Google Chrome Version 72.0.3626.121 (Official Build) (64-bit)
  • Operating system: Mac OS 10.13.6

Most helpful comment

@diego-rey I found that if your child frame is on the same domain as the parent, you can append a canvas element to the body of the child frame. Then pass that element to html2canvas using the canvas option. It'll pick up the font definitions inside the child frame.

All 3 comments

@diego-rey I found that if your child frame is on the same domain as the parent, you can append a canvas element to the body of the child frame. Then pass that element to html2canvas using the canvas option. It'll pick up the font definitions inside the child frame.

Oh the solution was simple. Thanks for the help @jasonbarry ! Doing this I was able to make it work.

@diego-rey can you provide example for your resolve?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dking3876 picture dking3876  ·  4Comments

kunal886496 picture kunal886496  ·  3Comments

AviYafe picture AviYafe  ·  5Comments

tjchambers32 picture tjchambers32  ·  3Comments

Loki180 picture Loki180  ·  4Comments