A simple Grunt multitask that uses prince to convert HTML files to PDF.
Convertion to PDF takes care of @media print
CSS rules and preserves links to remote web pages.
Nearly everything is copied over from grunt-wkhtmltopdf.
Download and install prince from the project page.
Make sure prince
is accessible from your PATH
(Try prince
in your Terminal).
Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-prince
Then add this line to your project's grunt.js
gruntfile:
grunt.loadNpmTasks('grunt-prince');
Simply add task definition in your gruntfile. See the folllowing example:
//...
prince: {
dev: {
src: 'path/to/some/html/file/*.html',
dest: 'pdf/output/'
},
prod: {
src: 'path/to/some/html/file/*.html',
dest: 'pdf/output/'
}
},
//...
Run grunt prince
to execute all the targets or grunt prince:targetname
to execute a specific target. Every html
file defined by the src
parameter will be turned into a PDF and saved to dest
folder.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
- v0.0.1: First Release
Copyright (c) 2014 Paul Pflugradt Licensed under the MIT license.