Last active
August 29, 2015 14:19
-
-
Save gr2m/0754a2133472d2ba27ca 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
var fs = require('fs') | |
var PDF = require('dream-pdf') | |
var tableData = require('./table.json') | |
PDF.plugin(require('dream-pdf-text')) | |
PDF.plugin(require('dream-pdf-image')) | |
PDF.plugin(require('dream-pdf-table')) | |
pdf = new PDF({ | |
size: [210, 297] | |
}) | |
pdf.text.loadFont('MyFunkyFont', fs.readFileSync('./path/to/funky.ttf')) | |
pdf.text.add("Hello, World", { | |
at: [20, 40], | |
size: 18 | |
}) | |
pdf.image.add(fs.readFileSync('./path/to/image.png'), { | |
at: [140, 40], | |
size: [60, 40] | |
}) | |
pdf.table.add(tableData, { | |
at: [20, 120] | |
}) | |
var data = pdf.toBlob() | |
// do what ever I want, like write to file, download, etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment