html-to-image
Version:
Generates an image from a DOM node using HTML5 canvas and SVG.
17 lines • 818 B
JavaScript
import { svgToDataURL } from './util';
export function createSvgDataURL(clonedNode, width, height) {
const xmlns = 'http://www.w3.org/2000/svg';
const svg = document.createElementNS(xmlns, 'svg');
const foreignObject = document.createElementNS(xmlns, 'foreignObject');
svg.setAttributeNS('', 'width', `${width}`);
svg.setAttributeNS('', 'height', `${height}`);
foreignObject.setAttributeNS('', 'width', '100%');
foreignObject.setAttributeNS('', 'height', '100%');
foreignObject.setAttributeNS('', 'x', '0');
foreignObject.setAttributeNS('', 'y', '0');
foreignObject.setAttributeNS('', 'externalResourcesRequired', 'true');
svg.appendChild(foreignObject);
foreignObject.appendChild(clonedNode);
return svgToDataURL(svg);
}
//# sourceMappingURL=createSvgDataURL.js.map