title: Using ReportLab inside Flask server crashes
body: <p>I have a Flask app that does the following:
  (<a href="https://github.com/sebastian-meckovski/web-invoicer/blob/main/app.py" rel="nofollow noreferrer">here's the source code</a>)</p>
  <ul>
  <li>takes input from the user</li>
  <li>creates variables based on user input</li>
  <li>passes variables to the <code>exportPDF()</code> function</li>
  <li>The <code>exportPDF()</code> function enerates a PDF file based on user input</li>
  <li>Redirects user to download URL so the user receives that PDF file in the browser</li>
  </ul>
  <p>It already works but only once. If I want to reuse the page it crashes. Here's the error:</p>
  <pre><code>[2021-03-05 15:21:53,306] ERROR in app: Exception on / [POST]
  Traceback (most recent call last):
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\flask\app.py&quot;, line 2447, in wsgi_app
  response = self.full_dispatch_request()
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\flask\app.py&quot;, line 1952, in 
  full_dispatch_request
  rv = self.handle_user_exception(e)
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\flask\app.py&quot;, line 1821, in 
  handle_user_exception
  reraise(exc_type, exc_value, tb)
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\flask\_compat.py&quot;, line 39, in 
  reraise
  raise value
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\flask\app.py&quot;, line 1950, in 
  full_dispatch_request
  rv = self.dispatch_request()
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\flask\app.py&quot;, line 1936, in 
  dispatch_request
  return self.view_functions[rule.endpoint](**req.view_args)
  File &quot;C:\Users\sebas\Desktop\web-invoicer\app.py&quot;, line 49, in home
  export_PDF(sample_list, full_name=full_name, adress_line=adress_line)
  File &quot;C:\Users\sebas\Desktop\web-invoicer\invoicingCopy2.py&quot;, line 141, in export_PDF
  document.save()
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\reportlab\pdfgen\canvas.py&quot;, line 
  1277, in save
  self._doc.SaveToFile(self._filename, self)
  File &quot;c:\users\sebas\desktop\web-invoicer\venv\lib\site-packages\reportlab\pdfbase\pdfdoc.py&quot;, line 
  207, in SaveToFile
  raise RuntimeError(&quot;class %s instances can only be saved once&quot; % self.__class__.__name__)
  RuntimeError: class PDFDocument instances can only be saved once
  </code></pre>
  <p>I'm running out of ideas about what could be the issue. Ple</p>