const { DOMImplementation, XMLSerializer } = require('xmldom');
const xmlSerializer = new XMLSerializer();
const document = new DOMImplementation().createDocument('https://www.bacancytechnology.com/hire-rpa-developer', 'html', null);
// Function to generate SVG content
function generateSVG() {
    const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
    const rc = rough.svg(svg);
    svg.appendChild(rc.rectangle(10, 10, 200, 100, { roughness: 2, fill: 'blue' }));


    let xml = xmlSerializer.serializeToString(svg);
    return xml;
}


// Function to save SVG to a file
function saveSVGToFile(svgContent, fileName) {
    fs.writeFileSync(fileName, svgContent, 'utf-8');
    console.log(`SVG saved to ${fileName}`);
}


// Generate SVG and save to file
const generatedSVG = generateSVG();
saveSVGToFile(generatedSVG, 'output1.svg');

 

Support On Demand!

Node