homam / heroku-html-to-pdf

Conver html to pdf service in Heroku

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Heroku config:

heroku config:set BUILDPACK_URL=https://github.com/krry/heroku-buildpack-nodejs-gulp-bower 
heroku config:set NPM_CONFIG_PRODUCTION=false

Usage:

curl "$url" -F html=@hello.html > hello.pdf

Node:

const config = {
  url: url,
  encoding: null, //IMPORTANT! This produces a binary body response instead of text
  formData: {
    html: {
      value:  new Buffer(content),
      options: {
        filename: 'hello.html',
        contentType: 'text/html'
      }
    }
  }
};

request.post(config, function(err, response, body) {
  fs.writeFile('test.pdf', body, "binary", function(writeErr) {
    console.log('Saved!');
  });
});

About

Conver html to pdf service in Heroku


Languages

Language:JavaScript 100.0%