print out a pdf, from Bonsai, that has a referenced SVG with a <foreignObject> in it?

Does anyone know how to print out a pdf, from Bonsai, that has a referenced SVG with a <foreignObject> in it?

Using the attached file, if the SVG to PDF Command is empty, it prints out the following as a svg...

But if you do something like
SVG to PDF Command = [["inkscape.exe", "svg", "-o", "pdf", "--export-dpi=300"]]
... it doesn't show the referenced svg

From what I can understand Inkscape does not render <foreignObject>.
I tried to headlessly use Firefox and Chrome to do this, but it doesn't seem to work.

Comments

  • What are you creating the reference in? I assume that the reference itself cannot be opened in Inkscape? Might be easier to change the initial creation of the reference to not use foreignObject, as from a brief search it reads like foreignObject is one of those things that sounded good at the time, but was never fully implemented, and is now just a pain point.

  • edited October 2025

    Basically trying to find a workflow pipeline to print out a styled .markdown text to a printed PDF from Bonsai. A pdf, where the resultant text is searchable and selectable.
    I vibe coded this bat script that converts a .md to an svg. The only way, i could find to make the resultant text searchable/selectable, in the resultant svg, is to put it in a <foreignobject>.

    Currently, if you open the sheet svg in chrome, for example, and print to a pdf, the svg shows up, but when i try to do it headless via Bonsai, it doesn't work... probably missing something obvious.

  • How does this work in the existing functionality to include spreadsheet tables in drawings? Is this text not selectable/searchable?

  • edited October 2025

    Yeah, not 100% sure. In bonsai, there is a obviously a code base that translates a .ODS/.XLS to a SVG, and uses <text> tags. I think, however, if you'd want to convert an .md file, that has a lot of varied CSS styling, these individual <text> tags would not be enough to style it. Could be wrong.

  • It looks like it wouldn't be toooo difficult to create a markdown to SVG generator, the pillow module can read font metrics for inserting line breaks (CSS formatting beyond font selection would be a problem). Then you can have markdown files with titles, lists etc.. that get included in your drawings.

    Roel
Sign In or Register to comment.