Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Doesn't seem to work with foreignObjects #70

Closed
jrgleason opened this issue Jan 28, 2016 · 13 comments
Closed

Doesn't seem to work with foreignObjects #70

jrgleason opened this issue Jan 28, 2016 · 13 comments

Comments

@jrgleason
Copy link

I tried it on an SVG I generated with D3. All the primitives shapes seemed to come out ok but the foreign objects do not show up. Is there something I can do about this?

@exupero
Copy link
Owner

exupero commented Jan 28, 2016

I haven't seen this problem before and a quick experiment doesn't reproduce it. Can you give an example of your SVG?

@jrgleason
Copy link
Author

I am seeing a couple other issues too it might be a red herring I will open up issues on the other 2 side effects first then close this one if those fix it.

@jrgleason
Copy link
Author

Here is a plunker that demos it.

The UI sucks click on the top button then on the printer if you miss the printer it is hard to tell. But if you hit it you should download the image minus the foreign objects.

@exupero
Copy link
Owner

exupero commented Jan 29, 2016

That doesn't seem to be the right link.

@jrgleason
Copy link
Author

WTH ok enough crazy markdown tricks then here it is in PT https://plnkr.co/edit/mCPepG4UzPJbO0ghADsr?p=info

@jrgleason
Copy link
Author

Weird I went to edit it and the address looks correct but you are right that hyperlink is taking you the wrong spot. Make sure to copy paste the text.

@exupero
Copy link
Owner

exupero commented Jan 29, 2016

Try adding xmlns="http://www.w3.org/1999/xhtml" to the HTML elements within the foreignObject.

@jrgleason
Copy link
Author

Like every element or just the first on in the FO?

@jrgleason
Copy link
Author

Looks like that works thanks now on to another issue :-)

@usmaanalii
Copy link

screen shot 2018-01-29 at 09 15 51

I'm trying to include a div with text, utilising foreign objects, but they don't show in the resulting image, should this be working?

Using Chrome 63 by the way.

@exupero
Copy link
Owner

exupero commented Jan 29, 2018

There are a couple examples of foreignObject working on the test page, and they do seem to be working in Chrome 63. One omits the xmlns attribute, and the tests it as xml:xmlns. It's possible that contenteditable breaks rendering of the object to an image, in which case, I'll happily take a pull request that removes that attribute from the cloned SVG tree before exporting it as a PNG.

@usmaanalii
Copy link

usmaanalii commented Jan 29, 2018

I've tested this in browser (by manually removing contenteditable), and it's still missing the foreign object, any other ideas?

@usmaanalii
Copy link

usmaanalii commented Jan 29, 2018

No worries, found the fix. When you add a foreignObject, it must have a height attribute, might be worth adding to your documentation, thanks for your help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants