@@ -23,13 +23,23 @@ pdf.create(html, options).toFile(function(err, res) {
2323## API
2424
2525``` js
26- pdf .create (html [, options]).toFile ([filepath, ]callback)
27- pdf .create (html [, options]).toBuffer (callback)
28- pdf .create (html [, options]).toStream (callback)
26+ var pdf = require (' html-pdf' );
27+ pdf .create (html).toFile ([filepath, ]function (err , res ){
28+ console .log (res .filename );
29+ });
2930
30- // for backwards compatibility
31- pdf .create (html [, options], callback)
31+ pdf .create (html).toStream (function (err , stream ){
32+ steam .pipe (fs .createWriteStream (' ./foo.pdf' ));
33+ });
34+
35+ pdf .create (html).toBuffer (function (err , buffer ){
36+ console .log (' This is a buffer:' , Buffer .isBuffer (buffer));
37+ });
3238
39+
40+ // for backwards compatibility
41+ // alias to pdf.create(html[, options]).toBuffer(callback)
42+ pdf .create (html [, options], function (err , buffer ){});
3343```
3444
3545
@@ -38,7 +48,7 @@ pdf.create(html [, options], callback)
3848config = {
3949
4050 // Export options
41- " directory" : " /tmp" // The directory the file gets written into if not using .toFile(filename, callback). default: '/tmp'
51+ " directory" : " /tmp" , // The directory the file gets written into if not using .toFile(filename, callback). default: '/tmp'
4252
4353 // Papersize Options: http://phantomjs.org/api/webpage/property/paper-size.html
4454 " height" : " 10.5in" , // allowed units: mm, cm, in, px
@@ -48,7 +58,15 @@ config = {
4858 " orientation" : " portrait" , // portrait or landscape
4959
5060 // Page options
51- " border" : " 0" // default is 0, units: mm, cm, in, px
61+ " border" : " 0" , // default is 0, units: mm, cm, in, px
62+ - or -
63+ " border" : {
64+ " top" : " 2in" , // default is 0, units: mm, cm, in, px
65+ " right" : " 1in" ,
66+ " bottom" : " 2in" ,
67+ " left" : " 1.5in"
68+ },
69+
5270 " header" : {
5371 " height" : " 45mm" ,
5472 " contents" : ' <div style="text-align: center;">Author: Marc Bachmann</div>'
0 commit comments