Capture SVG and save it as a System.File

0
Hi – I am using an external routine to render and inject an SVG into my app’s UI. How would I approach capturing it and save it as a system.file object so I can work with it in my database? Thanks, Boris
asked
2 answers
1

Hi Boris,

You need to add the SVG into your project and then can use it where ever you want within the project locally. Please have a look into custom images in Mendix documentation for more details.

 

If you want to save an SVG into your database as an image then,

  1. Create an entity (e.g. SVG) and generalise it with System.Image entity (give appropriate entity access to SVG entity)
  2. Once you get the API response back then you can create a new object of SVG use ‘String To File’ java action from CommunityCommmons app store module
  3. Commit.
     

I tried this as an example using https://codepen.io/osublake/pen/OMRdKq and it works great, see screenshots below.

 

 

Hope this helps!

answered
1

Hi,

You can make a widget that should use html2canvas.js to capture an dom element (in your case the svg) and save it in Mendix as a file.

Have done such before, but I don't have an example right now.

answered