1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-22 19:51:29 +00:00

setup test file with phantomjs, no luck though

This commit is contained in:
Scott
2016-01-12 12:50:34 -08:00
committed by Scott Tolksdorf
parent db5d12992a
commit a193bccc86
10 changed files with 415 additions and 3 deletions

26
server/pdfConvert.js Normal file
View File

@@ -0,0 +1,26 @@
var pdf = require('html-pdf');
var Markdown = require('marked');
var style = require('fs').readFileSync('../build/phbPage/bundle.css', 'utf8');
style = "<style>html, body {margin: 0;padding: 0;-webkit-print-color-adjust: exact;box-sizing: border-box;}\n"+
style + "</style>";
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
style = replaceAll(style, '/assets/homebrew/assets/', 'http://www.naturalcrit.com/assets/homebrew/assets/');
var content = Markdown('# oh hey \n welcome! ##### test');
var html = "<html><head>" + style + "</head><body><div class='phb'>"+ content +"</div></body></html>"
console.log(html);
pdf.create(html).toFile('./pdfs/businesscard.pdf', function(err, res){
console.log(err);
console.log(res.filename);
});