Skip to content

SVG in img tag not rendering correctly in Firefox #1897

Open
@jonmarkhall

Description

@jonmarkhall

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 trying to use html2canvas to generate an image from a page that contains an SVG in the form of a base-64 encoded data URI in an <img> tag. This has been working fine in Chrome but not in Firefox. I think this may be because Firefox is returning 0 for both img.naturalWidth and img.naturalHeight which as used as the intrinsicWidth and intrinsicHeight values in the ImageElementContainer class. The SVG has width and height attributes set. Could the intrinsicWidth and intrinsicHeight values be derived from the <svg>'s width and height instead of the <img>'s naturalWidth and naturalHeight?

I don't have an example I can easily provide but I can create a jsfiddle if needed.

Specifications:

  • html2canvas version tested with: 1.0.0-rc.3
  • Browser & version: Firefox 67.0.2
  • Operating system: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions