JazzCore / python-pdfkit

Wkhtmltopdf python wrapper to convert html to pdf
MIT License
1.99k stars 330 forks source link

Change output directory #114

Closed kevinyjiang closed 3 years ago

kevinyjiang commented 6 years ago

Hi all, is there any way to specify a specific directory to output the PDFs to? I supposed you could just move them afterwards but it would be nice to export them directly to another directory.

I tried pdfkit.from_string(output, "./pdfs/out.pdf", options=options) but get this error:

File "cpa-ui.py", line 100, in generate_docs
    self.modelToPDFConverter.createInvoice(model)
  File "/Users/kevinjiang/projects/cpa-automate/ModelToPDFConverter.py", line 42, in createInvoice
    pdfkit.from_string(output, filename, options=options, css=self.css)
  File "/usr/local/lib/python3.7/site-packages/pdfkit/api.py", line 72, in from_string
    return r.to_pdf(output_path)
  File "/usr/local/lib/python3.7/site-packages/pdfkit/pdfkit.py", line 156, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
Loading pages (1/6)
QPainter::begin(): Returned false============================] 100%
Error: Unable to write to destination                              
Exit with code 1, due to unknown error.

Thanks in advance!

AcckiyGerman commented 5 years ago

pdfkit.from_string("hello world", "PATH/TO/FOLDER/WHERE/YOU/CAN/WRITE/out.pdf", options=options) Are you really studying in the University of Columbia? If so, I won't recommend my kids to go there.

Please, close the Issue.

citrusvanilla commented 4 years ago

@AcckiyGerman It's "Columbia University" you dick.

citrusvanilla commented 4 years ago

the documentation should specify the "file" argument can be an absolute path.

AcckiyGerman commented 4 years ago

Oh, sorry @columbia, I actually wanted to insult the guy's "senior" ego, nothing more.

When such a "senior" comes to the interview and can't write FuzzBuzz, what do you do then? Stroke his head and give him a higher position?

AcckiyGerman commented 4 years ago

the documentation should specify the "file" argument can be an absolute path.

This is not a secret for anybody, who ever wrote open() in python.

JazzCore commented 3 years ago

I dont feel a need to specify that paths can be both relative or absolute, it's a default behavior in almost any library. If it was only relative OR absolute - sure, this needs to be specified in README, closing since the issue is answered.

Sorry that it took so long for me to get to it...