svg.js 524 B

12345678910111213141516171819
  1. var svgTagRenderer = require('./svg-tag')
  2. exports.render = svgTagRenderer.render
  3. exports.renderToFile = function renderToFile (path, qrData, options, cb) {
  4. if (typeof cb === 'undefined') {
  5. cb = options
  6. options = undefined
  7. }
  8. var fs = require('fs')
  9. var svgTag = exports.render(qrData, options)
  10. var xmlStr = '<?xml version="1.0" encoding="utf-8"?>' +
  11. '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' +
  12. svgTag
  13. fs.writeFile(path, xmlStr, cb)
  14. }