Convert document to PDF selecting page range and optional rotation. Output bytes object.

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

        return _fitz.Document_convertToPDF(self, from_page, to_page, rotate)