Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Headers is not working #98

Open
chinkan opened this issue Jun 25, 2018 · 0 comments
Open

Custom Headers is not working #98

chinkan opened this issue Jun 25, 2018 · 0 comments

Comments

@chinkan
Copy link

chinkan commented Jun 25, 2018

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&nbsp{#pageNum}&nbspof&nbsp{#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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant