1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-13 20:15:56 +00:00
Files
homebrewery/server/pdfConvert.js
Scott Tolksdorf 13f68c872e Added pdf endpoint
2016-01-13 16:03:57 -05:00

31 lines
670 B
JavaScript

var pdf = require('html-pdf');
var Markdown = require('marked');
var PHBStyle = '<style>' + require('fs').readFileSync('../phb.standalone.css', 'utf8') + '</style>'
var content = Markdown('# oh hey \n welcome! isnt this neat \n \\page ##### test');
var html = "<html><head>" + PHBStyle + "</head><body><div class='phb'>"+ content +"</div></body></html>"
//var h = 279.4 - 20*2.8;
var h = 279.4 - 56;
//var w = 215.9 - 56*1.7
var w = 215.9 - 43;
var config = {
"height": (279.4 - 56) + "mm",
"width": (215.9 - 43) + "mm",
"border": "0",
}
pdf.create(html, config).toFile('./temp.pdf', function(err, res){
console.log(err);
console.log(res.filename);
});