code: def pdf_from_writer(writer: Union[PdfFileWriter, PdfFileMerger]) -> bytes:
      
      memfile = io.BytesIO()
      writer.write(memfile)
      memfile.seek(0)
      return memfile.read()
docs: Extracts a PDF (as binary data) from a PyPDF2 writer or merger object.