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

Can't use all command arguments via the API #17

Open
damienalexandre opened this issue May 7, 2020 · 1 comment
Open

Can't use all command arguments via the API #17

damienalexandre opened this issue May 7, 2020 · 1 comment

Comments

@damienalexandre
Copy link
Contributor

We have the ability to set whtmltopdf options via HTTP Header,
but that only works for argument with a value I'm afraid.

HTTP headers are read here:

for k, v in request.headers.items():
if k.startswith('Pdf-') or k.startswith('Pdf_'):
config[k[4:].lower()] = v.lower()

Then in:

pydf/pydf/wkhtmltopdf.py

Lines 33 to 42 in 8f9ce76

def _convert_args(**py_args):
cmd_args = []
for name, value in py_args.items():
if value in {None, False}:
continue
arg_name = '--' + name.replace('_', '-')
if value is True:
cmd_args.append(arg_name)
else:
cmd_args.extend([arg_name, str(value)])

The only way to get the argument on the command line is to have a real True.

So via the API we can't get options like --disable-javascript or even --lowquality.

@samuelcolvin
Copy link
Member

sorry not to reply earlier. I'd be happy to accept a PR to treat a special value like 'TRUE' or '<set-option> as the same as True and just add the option with no argument.

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

2 participants