title: Converting html to pdf using Python Flask
body: <p>Here is my code in myclass.py</p>
  
  <pre><code>class Pdf():
  
      def render_pdf(self,name,html):
  
  
          from xhtml2pdf import pisa
          from StringIO import StringIO
  
          pdf = StringIO()
  
          pisa.CreatePDF(StringIO(html), pdf)
  
          return pdf
  </code></pre>
  
  <p>And I am calling it in api.py like this</p>
  
  <pre><code>@app.route('/invoice/&lt;business_name&gt;/&lt;tin&gt;', methods=['GET'])
  def view_invoice(business_name,tin):
  
     #pdf = StringIO()
    html = render_template('certificate.html', business_name=business_name,tin=tin)
  file_class = Pdf()
  pdf = file_class.render_pdf(business_name,html)
  return pdf
  </code></pre>
  
  <p>But it throws this error </p>
  
  <pre><code>AttributeError: StringIO instance has no __call__ method
  </code></pre>