question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

foreignObject and xhtml

See original GitHub issue

Hi there, nice-looking project! I’m new to SVG. I’ve been investigating this approach of rendering HTML inside an SVG element, using:

<foreignObject>
  <div xmlns="http://www.w3.org/1999/xhtml">
  </div>
</foreignObject>

From what I can tell, you don’t support <foreignObject>, is that right? It seems like it would be impossible to support. In any case, it might be worth adding to your “Unsupported” list on the readme!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
idrisadetunmbicommented, Nov 26, 2019

update for anyone finding this: I’ve managed to change the foreignObject elements into text elements using JavaScript so the labels are displaying properly now

Hi @rebeccaswebsite, please what approach did you take in solving this?

0reactions
alafrcommented, Oct 30, 2019

Hi, i don’t know any solution other than converting them to images with canvas (as said above it could be done with a callback function called when a foreignObject is detected). If the foreignObjects are very simple and have always the same syntax it might be possible to use a ‘replace’ with some regex to convert them before using svg-to-pdfkit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

<foreignObject> - SVG: Scalable Vector Graphics | MDN
The <foreignObject> SVG element includes elements from a different XML namespace. In the context of a browser, it is most likely (X)HTML.
Read more >
css - inline svg - how to apply browser default styles to xhtml in ...
i have an inline svg with foreignObject elements which contain xhtml fragments. however, the xhtml content is improperly styled due to ...
Read more >
Embedded Content — SVG 2
The 'foreignObject' element allows for inclusion of elements in a non-SVG namespace which is rendered within a region of the SVG graphic using ......
Read more >
foreignObject | Elements | SVG - osbo.com
The foreignObject SVG element specifies inclusion of elements in a non-SVG namespace which is rendered within a region of the SVG graphic using...
Read more >
<foreignObject> - SVG: Scalable Vector Graphics
The <foreignObject> SVG element includes elements from a different XML namespace ... In the context of SVG embedded in an HTML document, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found