Skip to content

Instantly share code, notes, and snippets.

Created December 5, 2015 02:46
Show Gist options
  • Save anonymous/4a1cf3312a8f09e8afda to your computer and use it in GitHub Desktop.
Save anonymous/4a1cf3312a8f09e8afda to your computer and use it in GitHub Desktop.
var PDFDocument = require('pdfkit');
var fs=require('fs');
const getStdin = require('get-stdin');
doc = new PDFDocument({compress:false, sizes:[526,525],autoFirstPage:false});
doc.pipe(fs.createWriteStream('out.pdf'));
// add the image and TOGO order text
doc.addPage({margin:0});
doc.image('logo3.png');
doc.moveDown();
doc.text("TOGO ORDER", {
paragraphGap: 0,
indent: 0,
align: 'center',
columns: 1,
width: 135
});
doc.moveDown();
// loop through file and add text
getStdin().then(str => {
doc.text(str, {
paragraphGap: 0,
indent: 0,
align: 'center',
columns: 1,
width: 135
});
doc.moveDown();
console.log(str);
});
doc.text("DONE", {
paragraphGap: 0,
indent: 0,
align: 'center',
columns: 1,
width: 135
});
doc.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment