Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8489263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:46:52+00:00 2026-06-10T21:46:52+00:00

If I do the following from the same machine, I get a beautiful PDF

  • 0

If I do the following from the same machine, I get a beautiful PDF as expected:

$ wkhtmltopdf --title "Transaction 773 (printed version)" --margin-left 5 --margin-right 2 --encoding utf8 www.google.com - > salida.pdf

But if from a common python shell I do:

>>> import subprocess
>>> f = open("salida.pdf", "wb")
>>> f.write(subprocess.check_output(["wkhtmltopdf", '--title "Transaction 773 (printed version)"', "--margin-left 5", "--margin-right 2", "--encoding utf8", "www.google.com", "-"]))

Then all I get is the common error:

/usr/lib/python2.7/subprocess.pyc in check_output(*popenargs, **kwargs)
    542         if cmd is None:
    543             cmd = popenargs[0]
--> 544         raise CalledProcessError(retcode, cmd, output=output)
    545     return output
    546 

CalledProcessError: Command '['wkhtmltopdf', '--title "Transaction 773 (printed version)"', '--margin-left 5', '--margin-right 2', '--encoding utf8', 'www.google.com', '-']' returned non-zero exit status 1

Looking at the complete error message, it tells me:

Unknown long argument –title “Transaction 773 (printed version)”

Why is not accepting the arguments? It’s worth mentioning that if I remove all arguments and just leave the input file and the “-“, it works like charm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:46:54+00:00Added an answer on June 10, 2026 at 9:46 pm

    You need to specify each argument in a separate item, and long arguments are actually 2 values:

    f.write(subprocess.check_output([
        "wkhtmltopdf", 
        '--title', "Transaction 773 (printed version)",
        "--margin-left", "5",
        "--margin-right", "2",
        "--encoding", "utf8",
        "www.google.com", "-"]))
    

    Normally, the shell parses such a command line, splits it on whitespace (except where text has been enclosed in quotes), and passes that on to the new process as the argv value.

    Now, you are creating that argv list yourself, and you have to do the splitting yourself. Note that the --title argument thus no longer needs to have the shell-level quotes either.

    A short argument (-ml5 or similar) doesn’t have that whitespace, so you didn’t have a problem with those.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Step 1, I use the following command to get my local IE version from
I have three mysql table from same database Db1. Three tables have following columns.
Sometimes I get the following from SQL Server 2005 when executing a stored procedure:
Following from this: Every specific weekday, sql and php I got this: deals_bookings.everyWeekDay =
Following from my last question which @Jon Skeet gave me a lot of help
Following from these question Subset sum problem and Sum-subset with a fixed subset size
I have noted the following from a website: The JVM HotSpot memory is split
Is the following From header incorect? // To send HTML mail, the Content-type header
I'm getting the following from a third party library (one example): @%SystemRoot%\SomePath\SomeFile.Dll,-203 I know
I have a problem following from my previous problem . I also have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.