0.4.5 • Published 10 years ago

pdf-builder v0.4.5

Weekly downloads
18
License
MIT
Repository
github
Last release
10 years ago

node-pdf-builder

Requires wkhtmltopdf.

Installation

npm install pdf-builder

Example

var PDF = require('pdf-builder')

new PDF()
	.setGlobalOptions({
		headerFontSize:  18,
		headerSpacing:   10,
		marginTop:       30,
		debugJavascript: true
	})
	.addPath('http://google.com', {
		headerCenter: 'Google',
		runScript: function() {
			console.log('Google input being processed...')
		}
	})
	.addPath('http://wkhtmltopdf.com/', {
		headerCenter: 'wkhtmltopdf',
		fnInput: 'wkhtmltopdf input being processed...',
		runScript: function(foo) {
			console.log(foo) // wkhtmltopdf input being processed...
		}
	})
	.setCustomCommand(function() {
		// Inject custom logic into command construction
		return this.getCommand().replace(/wkhtmltopdf.com/g, 'wkhtmltopdf.org')
	})
	.writeFile('output.pdf', function(err, result) {
		// result contains any warnings / console output from input execution
		console.log(result)
		console.log('Done!')

		/*
			Output:

			:1 Google input being processed...
			:1 wkhtmltopdf input being processed...
			Done!
		*/
	})

Features

  • Supports multiple pages
  • Supports global and page-level wkhtmltopdf options
  • Supports custom commands - use the helper functions as much or as little as you want
  • Suppresses wkhtmltopdf progress messages and only returns actual page outputs and errors
  • Supports passing actual functions as runScript values, with fnInput as its input
  • Supports streaming

TODO

  • .addTableOfContents()

Acknowledgments

0.4.5

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago