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

Pass options object to internal spawn invocation #100

Merged
merged 3 commits into from
Feb 27, 2021

Conversation

icompuiz
Copy link

I had an issue similar to #9 in my windows environment.

Basically my implementation passes a cookie argument which has three parts according to the wkhtmltopdf documentation.

So

    wkhtmltopdf("http://source", { output: "C:\dest.pdf", cookie: "<name> <value>" })

is ultimately executed on Windows as

     wkhtmltopdf <other arguments> --cookie "<name> <value>" http://source C:\dest.pdf

with quotes. Instead of

     wkhtmltopdf <other arguments> --cookie <name> <value> http://source C:\dest.pdf

without quotes.

The resolution for this case, as also noted in #9, is to pass the windowsVerbatimArguments option to spawn.

Instead of hard coding it into the library. I figured it would be more flexible to leave it up to the implementation to pass the argument. So

    wkhtmltopdf("http://source", { output: "C:\dest.pdf", cookie: "<name> <value>" })

becomes

        wkhtmltopdf("http://source", {
            output: "C:\dest.pdf", 
            cookie: "<name> <value>", 
            spawnOptions: { 
                windowsVerbatimArguments: true 
            }
        })

It is also unfortunate that this option is not documented though it's been implemented since 2011. (nodejs/node-v0.x-archive#4259)

Isioma Nnodum and others added 3 commits June 28, 2017 13:50
Immediately removed from options so they are not passed to wkhtmltopdf.
Passed as is as the options parameter to spawn invokation
@zxlin zxlin merged commit 68dcdbb into devongovett:master Feb 27, 2021
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

Successfully merging this pull request may close these issues.

2 participants