modelmat / sphinxcontrib-drawio

Sphinx extension for including draw.io files.
MIT License
39 stars 17 forks source link

Embed text when exporting in svg file format #100

Open JWA74 opened 2 weeks ago

JWA74 commented 2 weeks ago

sphinxcontrib-drawio is an excellent tool, extremely handy when creating images etcetera for documentation. We use Sphinx since it allows us to create documents in different formats using the same source code (*.rst files).

Discovered a minor issue, when exporting images in svg format they look fine in documents exported as HTML whereas the very same images in documents exported as PDF will have a small text stating “Text is not SVG – cannot display”. When exporting images manually from draw.io in svg format and then using those when creating the PDF works fine.

We use simplepdf to create PDF files from .rst source files.

It is not clear to me what settings are used in sphinxcontrib-drawio when exporting in svg format but the only thing I can think of that might cause this is that images and text are not embedded when exporting? Would it be possible to add such a feature?

image

How it looks in the PDF file when using sphinxcontrib-drawio.

image

How it looks like in the PDF file when exporting images manually in draw.io and then include those images in the rst files.

image

jdillard commented 2 weeks ago

Thanks for the detailed description! It might help to add an example .drawio file so that someone can use that to troubleshoot.

ItayZiv commented 2 weeks ago

Generally the SVGs exported by draw.io are meant for web embedding, there are some workaround that can be done. But it has been a while since I touched this project so I need to take some time to remember how it works.

https://www.drawio.com/doc/faq/svg-export-text-problems Explains the problem and how to workaround it (for now you can try the 2nd option to disable formatted text and word wrap)

JWA74 commented 2 weeks ago

Generally the SVGs exported by draw.io are meant for web embedding, there are some workaround that can be done. But it has been a while since I touched this project so I need to take some time to remember how it works.

https://www.drawio.com/doc/faq/svg-export-text-problems Explains the problem and how to workaround it (for now you can try the 2nd option to disable formatted text and word wrap)

I will give it a try and keep update you all, thanks!

JWA74 commented 2 weeks ago

Works fine, I also added some if-builder statements that allows me to generate svg files for HTML documentation and png files for PDF documents from the same source.