code: def _mudraw(buffer, fmt):
      
      with NamedTemporaryFile(suffix='.pdf') as tmp_in:
          tmp_in.write(buffer)
          tmp_in.seek(0)
          tmp_in.flush()
  
          proc = run(
              ['mudraw', '-F', fmt, '-o', '-', tmp_in.name], stdout=PIPE, stderr=PIPE
          )
          if proc.stderr:
              raise RuntimeError(proc.stderr.decode())
          return proc.stdout
docs: Use mupdf draw to rasterize the PDF in the memory buffer