title: Convert html table into pdf using flask
body: <p>I'm tried to solve the following problem using pdfkit.</p>
  <p>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.</p>
  <pre><code>OSError: No wkhtmltopdf executable found: &quot;b''&quot;
  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
  </code></pre>
  <p><strong>Configuration:</strong></p>
  <pre><code>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)
  </code></pre>
  <p><strong>route.py code:</strong></p>
  <pre><code>@app.route('/leave_worker_pdf', methods=['POST'])
  def leave_worker_pdf():
      leave_worker = LeaveWorker.query.all()
      html = render_template(&quot;leave_worker_pdf.html&quot;, leave_worker=leave_worker)
      pdf = pdfkit.from_string(html, False)
      response = make_response(pdf)
      response.headers[&quot;Content-Type&quot;] = &quot;application/pdf&quot;
      response.headers[&quot;Content-Disposition&quot;] = &quot;inline; filename=output.pdf&quot;
      return response
  </code></pre>
  <p><strong>HTML markup:</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div class=&quot;container&quot;&gt;
  
    
      &lt;h1 class=&quot;text-center mt-4&quot;&gt;Leave Workers Details&lt;/h1&gt;
    
      &lt;table class=&quot;table mt-4&quot;&gt;
          &lt;thead class=&quot;table-dark&quot;&gt;
            &lt;tr&gt;
              &lt;th scope=&quot;col&quot;&gt;Id&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;Name&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;Address&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;Contact&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;LeaveDate&lt;/th&gt;
              &lt;th scope=&quot;col&quot;&gt;Admin&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          {% for worker in leave_worker %}
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;td&gt; {{ worker.id }}&lt;/td&gt;
              &lt;td&gt; {{ worker.leave_worker_name }} &lt;/td&gt;
              &lt;td&gt; {{ worker.leave_worker_address }} &lt;/td&gt;
              &lt;td&gt; {{ worker.leave_worker_contact }} &lt;/td&gt;
              &lt;td&gt; {{ worker.leave_date.strftime('%Y-%m-%d') }} &lt;/td&gt;
              &lt;td&gt; {{ worker.admin.username }} &lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
          {% endfor %}
      &lt;/table&gt;
    
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong>When I add wkhtmltopdf configuration the page can't load into the browser.</strong></p>
  <p><a href="https://i.stack.imgur.com/2OGJb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2OGJb.png" alt="When I add wkhtmltopdf configuration the page can't load into the browser" /></a></p>
  <p><strong>Even the homepage cant load into the browser.</strong></p>
  <p><a href="https://i.stack.imgur.com/iB3Bt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iB3Bt.png" alt="index page" /></a></p>
  <p><strong>when I remove wkhtmltopdf configuration from my app then my all routes work fine only when i click on the pdf then its give in error.</strong></p>
  <p><a href="https://i.stack.imgur.com/E0Rhg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E0Rhg.png" alt="enter image description here" /></a></p>
  <p><strong>Error:</strong></p>
  <p><a href="https://i.stack.imgur.com/Qbcmx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qbcmx.png" alt="enter image description here" /></a></p>