Created
August 25, 2017 02:36
-
-
Save MadLittleMods/510340ebffdbd514528bf429ff7726ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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