Skip to content

Commit e40e4f5

Browse files
committed
Add http header support, fixes #69
1 parent 9d4b5ed commit e40e4f5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ config = {
9797
"phantomPath": "./node_modules/phantomjs/bin/phantomjs", // PhantomJS binary which should get downloaded automatically
9898
"phantomArgs": [], // array of strings used as phantomjs args e.g. ["--ignore-ssl-errors=yes"]
9999
"script": '/url', // Absolute path to a custom phantomjs script, use the file in lib/scripts as example
100-
"timeout": 30000 // Timeout that will cancel phantomjs, in milliseconds
100+
"timeout": 30000, // Timeout that will cancel phantomjs, in milliseconds
101+
102+
// HTTP Headers that are used for requests
103+
"httpHeaders": {
104+
// e.g.
105+
"Authorization": "Bearer ACEFAD8C-4B4D-4042-AB30-6C735F5BAC8B"
106+
}
101107

102108
}
103109
```

lib/scripts/pdf_a4_portrait.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/scripts/pdf_a4_portrait.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ exit('Did not receive any html') if !json.html?.trim()
2828

2929
options = json.options
3030
page = webpage.create()
31+
32+
if options.httpHeaders
33+
page.customHeaders = options.httpHeaders
34+
3135
page.content = json.html
3236
page.viewportSize = vp if vp = options.viewportSize
3337
totalPages = 0

0 commit comments

Comments
 (0)