Skip to content

Instantly share code, notes, and snippets.

@MadLittleMods
Created August 25, 2017 02:36
Show Gist options
  • Save MadLittleMods/510340ebffdbd514528bf429ff7726ae to your computer and use it in GitHub Desktop.
Save MadLittleMods/510340ebffdbd514528bf429ff7726ae to your computer and use it in GitHub Desktop.
const fs = require('fs');
const PDFDocument = require('pdfkit');
// Create a document
const doc = new PDFDocument({
margin: 0,
size: [612, 1595]
});
// Pipe its output somewhere, like to a file or HTTP response
// See below for browser usage
doc.pipe(fs.createWriteStream('output.pdf'));
doc.image('page1.png', {
width: 612
});
doc.addPage({
margin: 0,
size: [612, 1570]
})
doc.image('page2.png', {
width: 612
});
// Finalize PDF file
doc.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment