Created
April 19, 2018 14:28
-
-
Save officer-rosmarino/657d9e471e0cf54ea583d419375c2d66 to your computer and use it in GitHub Desktop.
Generate a PDF using pdfmake on the server with Node.js (no browser)
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
'use script' | |
var pdfmake = require('pdfmake'); | |
var fs = require('fs'); | |
const doc = new pdfmake({ | |
Roboto: { normal: new Buffer(require('pdfmake/build/vfs_fonts.js').pdfMake.vfs['Roboto-Regular.ttf'], 'base64') } | |
}).createPdfKitDocument({ content: 'test' }) | |
doc.pipe(fs.createWriteStream('myFile.pdf')) | |
doc.end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately when I open the generated pdf on OSX using Adobe Acrobat I get an error.

When opening using PDF Preview of Chrome, no errors, but the doc is simply empty, as it is in Acrobat.