carbon icon indicating copy to clipboard operation
carbon copied to clipboard

Generated SVG is shown as a blank image when imported into Google Slides/Figma/Inkscape/GitHub

Open tracyhenry opened this issue 7 years ago • 17 comments
trafficstars

Generated svg will appear as a blank image when imported to google slides/drawings or lucidcharts. Actually, when it's imported into google drive, the preview is already a blank image.

Browser:
Code Snippet (If Applicable)

tracyhenry avatar Sep 04 '18 11:09 tracyhenry

@tracyhenry which browser were you using, and can you post a link or code snippet so we can recreate the bug?

mfix22 avatar Sep 04 '18 16:09 mfix22

I saw this issue arisen on both Chrome and Safari. The code snippet I was using is the following:

var teamLogoTransform = new Transform("teamlogoID",
    "select * from teams;",
    "nba",
    function (row){
        var id = parseInt(row[0]);
        var y = Math.floor(id / 6);
        var x = id - y * 6;
        var ret = [];
        ret.push(row[0]);
        ret.push((x * 2 + 1) * 80);
        ret.push((y * 2 + 1) * 80 + 100);
        ret.push(row[1]);
        ret.push(row[2]);
        ret.push(row[3]);
        ret.push(row[4]);

        return Java.to(ret ,"java.lang.String[]");
    },
    ["id", "x", "y", "team_id", "city", "name", "abbr"],
    true);

tracyhenry avatar Sep 06 '18 18:09 tracyhenry

I just tried this image, and the SVG is downloaded correctly. Whether or not you are able to import it into Google Slides it outside of the scope of Carbon.

I don't believe any SVGs are able to be imported into Google Slides, too 🙂

Closing.

mfix22 avatar Sep 08 '18 18:09 mfix22

First... it's possible to import svgs to google slides: https://www.sosnoob.com/how-to-import-svg-files-into-google-slides/

Second... the generated svg not only broke on google drive/slides, it also broke on lucidchart.com, which is a popular drawing website.

I know the generated svg displays correctly on browsers, but there must be some formatting issues that prevent it from displaying correctly on those platforms.

My use case is to paste some code snippet into academic papers (which will work best with svgs), which I think it's fairly important. Please consider reopening this issue. It's definitely within the scope of Carbon.

tracyhenry avatar Sep 09 '18 01:09 tracyhenry

Thanks for releasing Carbon. The generated SVG renders in Google Chrome 70, but is a blank white rectangle in Inkscape 0.92.3 or Emacs SVG mode with preview rendered by ImageMagick.

There is one warning reported by Inkscape which might point to the common source of the rendering error in the viewers reported in this issue:

$ inkscape ~/Downloads/carbon.svg 
WARNING: unknown type: svg:foreignObject

jfkw avatar Sep 12 '18 23:09 jfkw

Right 🙂 The library we use to convert DOM nodes to images uses <foreignObject> tags to embed HTML nodes into an SVG document. These tags are not allowed in a lot of image softwares, including InkScape (source).

I am assuming this is the same issue that others are seeing when converting SVGs for Google products.

Unfortunately, I am not aware of a way to do the HTML -> SVG embedding w/o foreignObject. I will leave this open in case anyone has another idea.

mfix22 avatar Sep 13 '18 16:09 mfix22

Duplicate of #353 Tracking in #358

mfix22 avatar Sep 30 '18 05:09 mfix22

Just hit this issue when trying to convert SVG into PDF using Inkscape to embed an image into a LaTeX paper (I guess @tracyhenry was also using it?).

It seems the generated SVG is somehow just a container for plain HTML. Maybe we would need to change the library code to generate "true" SVG. Have you ever considered using https://github.com/radkovo/WebVector (just found via a Google search)?

michelole avatar Nov 22 '18 11:11 michelole

The same thing happened here, I also want to convert saved SVG into PDF, then embed into a paper. Would love to see you guys fix this issue.

allenanswerzq avatar May 23 '19 13:05 allenanswerzq

Same here, getting a blank frame when i import this into Figma.

jerriclynsjohn avatar Feb 21 '20 09:02 jerriclynsjohn

Does anyone have any suggestions for fixing this? Are there any other good libraries that convert a DOM node to an SVG, without using foreignObject?

mfix22 avatar Feb 29 '20 02:02 mfix22

I'd love this as a feature. especially for post-processing in figma.

Luttik avatar Aug 10 '20 20:08 Luttik

same here :) Any news? Thanks

Does anyone have any suggestions for fixing this? Are there any other good libraries that convert a DOM node to an SVG, without using foreignObject?

@mfix22 It looks like this might be usable, dom-to-svg: https://www.npmjs.com/package/dom-to-svg.

thepeoplesbourgeois avatar Sep 12 '21 04:09 thepeoplesbourgeois

I am also having problems importing the SVG image in Inkscape, the canvas appears empty.

leiteg avatar May 18 '22 21:05 leiteg

Any update? I try to import the svg to Illustrator but report “Clipping will be lost on roundtrip to Tiny”

miku1958 avatar Feb 19 '23 04:02 miku1958

For anyone who want to insert the svg from carbon to draw.io, there's a workaround:

  • Do not directly copy and paste into your diagram.
  • First, drag your svg into a github comment window, it will be uploaded into github user assets folder, get the url (sth like https://gist.github.com/assets/40353317/)
  • Then click arrange->insert->image and use this url to import the svg file

Zhaoyilunnn avatar Jan 25 '24 08:01 Zhaoyilunnn