Skip to content

Commit fe94e72

Browse files
committed
Update README
1 parent a94ebd5 commit fe94e72

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

Changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
console.log(res.filename);
1010
});
1111

12-
pdf.create(html).toStream(filepath, function(err, stream){
12+
pdf.create(html).toStream(function(err, stream){
1313
steam.pipe(fs.createWriteStream('./foo.pdf'));
1414
});
1515

16-
pdf.create(html).toBuffer(filepath, function(err, buffer){
16+
pdf.create(html).toBuffer(function(err, buffer){
1717
console.log('This is a buffer:', Buffer.isBuffer(buffer));
1818
});
1919
```

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
3848
config = {
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

Comments
 (0)