Change paper format to Letter and units to inches

# Import FPDF class
from fpdf import FPDF

# Create instance of FPDF class
# Letter size paper, use inches as unit of measure
pdf=FPDF(format='letter', unit='in')
# Add new page. Without this you cannot create the document.
pdf.add_page()
# Loop through some font sizes
for fs in range(8, 37):
    # Regular font, notice the empty string ''
    pdf.set_font('Arial','',fs)

    # Create a cell 1.0 inches wide, automatic height
    # and write some text
    pdf.cell(1.0,0.0,'Hello World!')
    
    # Insert break 0.15 inches in height
    # Just like a carriage return
    pdf.ln(0.15)

# output content into a file ('F') named 'hello2.pdf'
pdf.output('hello2.pdf','F')
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s