question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cant load app into browser

See original GitHub issue

I’m tried to solve the following problem using pdfkit (Flask). when I add wkhtmltopdf configuration to my app then my app can’t load into the browser even the index page cant load into the browser. but when I remove wkhtmltopdf configuration from my app then my all routes work fine only the HTML to pdf route gives me the following error.

OSError: No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

Configuration:

config = pdfkit.configuration(wkhtmltopdf='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe')
pdfkit.from_url('http://127.0.0.1:5000/leave_worker_pdf', 'output.pdf', configuration=config)

route.py code:

@app.route('/leave_worker_pdf', methods=['POST'])
def leave_worker_pdf():
    leave_worker = LeaveWorker.query.all()
    html = render_template("leave_worker_pdf.html", leave_worker=leave_worker)
    pdf = pdfkit.from_string(html, False)
    response = make_response(pdf)
    response.headers["Content-Type"] = "application/pdf"
    response.headers["Content-Disposition"] = "inline; filename=output.pdf"
    return response

HTML markup:

<!DOCTYPE html>
![Screenshot_51](https://user-images.githubusercontent.com/76259605/109492862-69ecf580-7aad-11eb-8371-17209911ae9f.png)
![Screenshot_51](https://user-images.githubusercontent.com/76259605/109492915-838e3d00-7aad-11eb-88e4-33c25cc2535c.png)


<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
</head>
<body>
  <div class="container">

  
    <h1 class="text-center mt-4">Leave Workers Details</h1>
  
    <table class="table mt-4">
        <thead class="table-dark">
          <tr>
            <th scope="col">Id</th>
            <th scope="col">Name</th>
            <th scope="col">Address</th>
            <th scope="col">Contact</th>
            <th scope="col">LeaveDate</th>
            <th scope="col">Admin</th>
          </tr>
        </thead>
        {% for worker in leave_worker %}
        <tbody>
          <tr>
            <td> {{ worker.id }}</td>
            <td> {{ worker.leave_worker_name }} </td>
            <td> {{ worker.leave_worker_address }} </td>
            <td> {{ worker.leave_worker_contact }} </td>
            <td> {{ worker.leave_date.strftime('%Y-%m-%d') }} </td>
            <td> {{ worker.admin.username }} </td>
          </tr>
        </tbody>
        {% endfor %}
    </table>
  
  </div>
</body>
</html>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JazzCorecommented, Mar 20, 2021

You should provide configuration arg for any API since its not stored anywhere.

Try changing to

def leave_worker_pdf():
    leave_worker = LeaveWorker.query.all()
    config = pdfkit.configuration(wkhtmltopdf='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe')
    html = render_template("leave_worker_pdf.html", leave_worker=leave_worker)
    pdf = pdfkit.from_string(html, False, configuration=config)
0reactions
ijazbachacommented, Mar 21, 2021

Thanks, Is working now @JazzCore

Read more comments on GitHub >

github_iconTop Results From Across the Web

9 Ways to Fix “No App Found to Open URL” in Android
9 Ways to Fix “No App Found to Open URL” in Android · 1. Force-Close Android Apps and Retry · 2. Reboot Your...
Read more >
Fix problems with apps, extensions, or themes - Chrome ...
If you're having problems with your apps, extensions, and themes, try these steps. If you can't install an app You can no longer...
Read more >
Fix Can't Download Via Browser App Error On Google Play ...
ViaBrowser # Can't # Download #Google #PlayStore #Can'tDownloadGooglePlayStore #PlaystoreDownloadpendingFix: Can't Download Via Browser App ...
Read more >
What to Do When a Website Won't Load | PCMag
To determine whether the problem lies with your browser or your PC as a whole, fire up an alternate browser and try to...
Read more >
browser works for internet, but apps wont
4. Open Edge or Chrome browser and try to open any web page and see if the error has been resolved. ... 3....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found