code: def convertToPDF(self, from_page=0, to_page=-1, rotate=0):
          
          if self.isClosed or self.isEncrypted:
              raise ValueError("operation illegal for closed / encrypted doc")
  
          return _fitz.Document_convertToPDF(self, from_page, to_page, rotate)
docs: Convert document to PDF selecting page range and optional rotation. Output bytes object.