phantom-html-to-pdf
phantom-html-to-pdf copied to clipboard
Custom Headers is not working
Hi, I have tried the to push the customHeaders into global config or inside conversion option but still found that no custom headers received from server. My code is something like below:
var conversion = require("phantom-html-to-pdf")({
timeout: 120000,
waitForJS: true,
waitForJSVarName: "PHANTOM_HTML_TO_PDF_READY",
printDelay: 5000,
customHeaders: { //put here is not working
"Authorization": token[0]
}
});
conversion({
url: url,
footer: '<div style="font-family: \'Source Sans Pro\',sans-serif;text-align:center">Page {#pageNum} of {#numPages}</div>',
customHeaders: { //put here is also not working
"Authorization": token[0]
}
}, function (err, pdf) {
console.log("err => " + err);
console.log("pdf => " + pdf);
var output = fs.createWriteStream(path)
console.log(pdf.logs);
console.log(pdf.numberOfPages);
// since pdf.stream is a node.js stream you can use it
// to save the pdf to a file (like in this example) or to
// respond an http request.
pdf.stream.pipe(output);
callback(null, path);
});
How can i done this? thanks!