How to Create PDF using Python
Contents
[
Hide
]
Aspose.PDF for Python via .NET is a PDF manipulation API that allows developers to create, load, modify, and convert PDF files directly from Python for .NET applications with just a few lines of code.
How to Create Simple PDF File
To create a PDF using Python via .NET with Aspose.PDF, you can follow these steps:
- Create an object of Document class
- Add a Page object to the pages collection of the Document object
- Add TextFragment to paragraphs collection of the page
- Save the resultant PDF document
import aspose.pdf as ap
# Initialize document object
document = ap.Document()
# Add page
page = document.pages.add()
# Add text to new page
page.paragraphs.add(ap.text.TextFragment("Hello World!"))
# Save updated PDF
document.save(output_pdf)