svg-sketch-pdf

1.0.28 • Public • Published

svg-sketch-pdf

pdf creation for svg-sketch

using the awesome pdfkit library

converts json from svg-sketch to pdf.

js-standard-style build status Greenkeeper badge

Try it out! view on requirebin

use with browserify

example

run in node or browser!

var fs = require('fs');
var pdf = require('./')({size: [595.28, 841.89], base64: typeof window !== 'undefined'});
var concat = require('concat-stream');
pdf.pipe(concat(write));
pdf.write([
  {
    type: 'header',
    layout: {
      type: 'landscape'
    }
  },
  {
    type: 'text',
    args: {
      value: 'I love svg',
      x: 100,
      y: 100
    }
  },
  {
    type: 'path',
    args: {
      d: 'M 100,114 L 200,114'
    }
  }
]);
 
pdf.end();
 
function write(data) {
  if ('undefined' === typeof window) {
    fs.writeFileSync('output.pdf', data, {encoding: 'base64'});
  } else {
    window.location.href = 'data:application/pdf;base64,' + data;
  }
}

opt.size is [width, height]

opt.document optional function document(pdfkitDoc) { }

opt.yoffset optional function yoffset(event) {}

opt.compress optional compress pdf (default false)

install

With npm do:

npm install svg-sketch-pdf

license

MIT

Package Sidebar

Install

npm i svg-sketch-pdf

Weekly Downloads

33

Version

1.0.28

License

MIT

Last publish

Collaborators

  • jameskyburz