xxxxxxxxxx
#Import the class FPDF from module fpdf.
#Add a page.
#Set the font.
#Insert a cell and provide the text.
#Save the pdf with “. pdf” extencsion.
xxxxxxxxxx
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
def create_pdf(file_name):
c = canvas.Canvas(file_name, pagesize=letter)
# Draw text on the PDF
c.drawString(100, 750, "Hello, This is a PDF created with Python!")
# Draw a line
c.line(100, 730, 500, 730)
# Save the PDF
c.save()
if __name__ == "__main__":
create_pdf("example.pdf")
xxxxxxxxxx
# If you're trying to convert a python notebook (.ipynb) to PDF:
# Try Vertopal.com ==> .ipynb to PDF