UNPKG

html-to-image

Version:

Generates an image from a DOM node using HTML5 canvas and SVG.

21 lines 962 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSvgDataURL = void 0; var util_1 = require("./util"); function createSvgDataURL(clonedNode, width, height) { var xmlns = 'http://www.w3.org/2000/svg'; var svg = document.createElementNS(xmlns, 'svg'); var 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 util_1.svgToDataURL(svg); } exports.createSvgDataURL = createSvgDataURL; //# sourceMappingURL=createSvgDataURL.js.map