import aspose.pdf as pdf
# Load License
license = pdf.License()
license.set_license("Aspose.Total.lic")

# Instantiate a new PDF document
pdfDocument = pdf.Document()

# Add a page in the PDF
pdfPage = pdfDocument.pages.add()

# Set some sample text
fragment = pdf.text.TextFragment("hello world")

# Set text position on the page
fragment.position = pdf.text.Position(100, 600)

# Set rotation angle
fragment.text_state.rotation = 60

# Initialize TextBuilder object
textBuilder = pdf.text.TextBuilder(pdfPage)

# Append the fragment to the PDF page
textBuilder.append_text(fragment)
            
# Save the PDF on the disk
pdfDocument.save("RotatedTextPdfWithPython.pdf")

print("Text rotated successfully in PDF")