Skip to content

Instantly share code, notes, and snippets.

@danawoodman
Created April 10, 2015 19:41
Show Gist options
  • Save danawoodman/ae72b838b7aa56869082 to your computer and use it in GitHub Desktop.
Save danawoodman/ae72b838b7aa56869082 to your computer and use it in GitHub Desktop.
Example of using pdfkit in Node.js
var fs = require('fs');
var PDFDocument = require('pdfkit');
var pdf = new PDFDocument({
size: 'LEGAL', // See other page sizes here: https://github.com/devongovett/pdfkit/blob/d95b826475dd325fb29ef007a9c1bf7a527e9808/lib/page.coffee#L69
info: {
Title: 'Tile of File Here',
Author: 'Some Author',
}
});
// Write stuff into PDF
pdf.text('Hello World');
// Stream contents to a file
pdf.pipe(
fs.createWriteStream('./path/to/file.pdf')
)
.on('finish', function () {
console.log('PDF closed');
});
// Close PDF and write file.
pdf.end();
@bartvandoormaal
Copy link

The issue of the permissions not working is because the ownerPassword property is missing. I needs to be set for the permissions to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment