I'm using maker.js from microsoft to create svgs and maker.js also allow to export the models to dxf string. I'm able to get dxf string from it. I want to make dxf file from dxf string and save in user desired location or default download location.
Question
How do I create a file and write in it using a string and save it with extension .dxf using javascript.
Generally a user has to initiate a download, easiest way I'm aware of is a href to a data url. In React you can render that link as:
Where
dxfString
is a the value returned by makerjs.Demo of this code in production
HTML only version in jsfiddle
Depending on your framework you'll need a different syntax for changing
href
of a link.btoa
is a standard function in all modern browsers.