Skip to content

Commit d020202

Browse files
committed
Add options documentation
1 parent d829f73 commit d020202

1 file changed

Lines changed: 39 additions & 7 deletions

File tree

README.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,44 @@ pdf.create(htmlString, options, callback)
2626
```
2727

2828
## Options
29-
`script`: Absolute path to a custom phantomjs script, use the file in lib/scripts as example
30-
`timeout`: Timeout that will cancel phantomjs, milliseconds as Integer, default: 10000
31-
`filename`: The file path of the file that will be written. If you want to save the file permanently, you have to pass this option.
32-
`directory`: The directory path of the file that will be written. default: '/tmp'
29+
```javascript
30+
config = {
31+
// Script options
32+
script: '/url' // Absolute path to a custom phantomjs script, use the file in lib/scripts as example
33+
timeout: 10000 // Timeout that will cancel phantomjs, in milliseconds
3334

34-
The full options object gets converted to JSON and will get passed to the phantomjs script as third argument.
35-
There are more options concerning the paperSize, header & footer options inside the phantomjs script.
35+
// Papersize Options: http://phantomjs.org/api/webpage/property/paper-size.html
36+
"height": "", // allowed units: mm, cm, in, px
37+
"width": "", // allowed units: mm, cm, in, px
38+
- or -
39+
"format": "A4", // allowed units: A3, A4, A5, Legal, Letter, Tabloid
40+
"orientation": "portrait", // portrait or landscape
41+
42+
43+
// Page options
44+
"border": "0" // default is 0, units: mm, cm, in, px
45+
"header": {
46+
"height": "45mm",
47+
"contents": "<div style="text-align: center;">© Marc Bachmann</div>"
48+
},
49+
"footer": {
50+
"height": "28mm",
51+
"contents": "<span style="color: #444;">{{page}}</span>/<span>{{pages}}</span>"
52+
},
53+
54+
55+
// File options
56+
"type": "pdf", // allowed file types: png, jpeg, pdf
57+
"quality": "75", // only used for types png & jpeg
3658

37-
## documentations for more available options will follow soon :)
59+
60+
// Export options
61+
"buffer": true, // only supported on certain systems
62+
- or -
63+
"filename": "/tmp/html-pdf-123-123.pdf" // The file path of the file that will be written. If you want to save the file permanently, you have to pass this option.
64+
"directory": "/tmp" // The directory the file gets written into if no filename is defined. default: '/tmp'
65+
}
66+
```
67+
68+
The full options object gets converted to JSON and will get passed to the phantomjs script as third argument.
69+
There are more options concerning the paperSize, header & footer options inside the phantomjs script.

0 commit comments

Comments
 (0)