title: Is it possible to generate PDF with StreamingHttpResponse as it's possible to do so with CSV for large dataset?
body: <p>I have a large dataset that I have to generate CSV and PDF for. With CSV, I use this guide: <a href="https://docs.djangoproject.com/en/3.1/howto/outputting-csv/" rel="noreferrer">https://docs.djangoproject.com/en/3.1/howto/outputting-csv/</a></p>
  <pre><code>import csv
  
  from django.http import StreamingHttpResponse
  
  class Echo:
      &quot;&quot;&quot;An object that implements just the write method of the file-like
      interface.
      &quot;&quot;&quot;
      def write(self, value):
          &quot;&quot;&quot;Write the value by returning it, instead of storing in a buffer.&quot;&quot;&quot;
          return value
  
  def some_streaming_csv_view(request):
      &quot;&quot;&quot;A view that streams a large CSV file.&quot;&quot;&quot;
      # Generate a sequence of rows. The range is based on the maximum number of
      # rows that can be handled by a single sheet in most spreadsheet
      # applications.
      rows = ([&quot;Row {}&quot;.format(idx), str(idx)] for idx in range(65536))
      pseudo_buffer = Echo()
      writer = csv.writer(pseudo_buffer)
      response = StreamingHttpResponse((writer.writerow(row) for row in rows),
                                       content_type=&quot;text/csv&quot;)
      response['Content-Disposition'] = 'attachment; filename=&quot;somefilename.csv&quot;'
      return response
  </code></pre>
  <p>It works great. However, I can't find anything that can be done for PDF. Can it? I use <code>render_to_pdf</code> as well as I use a template for PDF.</p>