title: CreatePdf with xhtml2pdf from template and upload to S3
body: <p>I tried to generate Pdf file from html using xhtml2pdf, after that I want to upload to S3. I had no idea how to do it, after trying a few ways but still stuck. Thank you so much for your help in advance.</p>
  <pre><code>def upload_pdf_S3(pdf):
      client = boto3.client(
          's3',
          aws_access_key_id,
          aws_secret_access_key
      )
      try:
          client.upload_fileobj(pdf, 'test', 'test111.pdf')
          return True
      except ClientError as e:
          print(e)
          return False
  
  def render_to_pdf(template_src, context_dict={}):
      template = get_template(template_src)
      html = template.render(context_dict)
      result = BytesIO()
      pdf = pisa.pisaDocument(BytesIO(html.encode(&quot;ISO-8859-1&quot;)), result)
      upload_pdf_S3(pdf)
      if not pdf.err:
          return HttpResponse(result.getvalue(), content_type='application/pdf')
      return None
  </code></pre>