title: Why I have to convert bytes from BytesIO then convert back to BytesIO so it can be read as PDF file response?
body: <p>I use <code>PyPDF4</code> to merge pdf files, then I use the merged pdf as a <code>HttpResponse</code>.
  I use <code>BytesIO</code> to get the result from <code>PdfFileMerger</code>. </p>
  
  <p>I got it working using this code </p>
  
  <pre><code>def mergePDF(listOfPDFFile):
      merger = PdfFileMerger()
      for file in listOfPDFFile:
          merger.append(PdfFileReader(file))
      _byteIo = BytesIO()
      merger.write(_byteIo)
      return _byteIo.getvalue()
  </code></pre>
  
  <p>Then when I use the method in <code>APIView</code> to return the merged pdf as a <code>HttpResponse</code></p>
  
  <pre><code>class DocumentBundlePDFView(APIView):
      def get(self, request, format=None):
          '''
           here goes a process to assign list of document to documentList
          '''
          pdfBytes = mergePDF(documentList)
          pdfFile = io.BytesIO(pdfBytes)
          response = HttpResponse(FileWrapper(pdfFile), content_type='application/pdf')
          return response
  </code></pre>
  
  <p>But, why I have to create <code>BytesIO</code> object twice to get it working?
  Initially I return the <code>_byteIO</code> instance then directly pass the instance to <code>FileWrapper</code> but it output 0Kb file.</p>
  
  <p>So I convert the <code>_byteIO</code> instance to <code>bytes</code> then create another <code>BytesIO</code> instance in APIView to get it working.</p>
  
  <p>How can I simplify the code? </p>