Mix page orientations

Each page in a pyFPDF document can have its own orientation. The trick lies in adding the parameter `orientation` when using the `add_page` method.

# Import FPDF class
from fpdf import FPDF

# Create instance of FPDF class
# You can set the orientation here also. 'P'ortait by default.

# Now we add a page. Since no orientation has been set, it is 'P'ortrait
# by default

# Remember to put at least one of this font declarations when you are going
# to render text.  Not needed if not drawing text.

# Text height
th = pdf.font_size

loremipsum = """Lorem ipsum dolor sit amet, vel ne quando dissentias. Ne his oporteat expetendis. Ei tantas explicari quo, sea vidit minimum menandri ea. His case errem dicam ex, mel eruditi tibique delicatissimi ut. At mea wisi dolorum contentiones, in malis vitae viderer mel.

Vis at dolores ocurreret splendide. Noster dolorum repudiare vis ei, te augue summo vis. An vim quas torquatos, electram posidonium eam ea, eros blandit ea vel. Reque summo assueverit an sit. Sed nibh conceptam cu, pro in graeci ancillae constituto, eam eu oratio soleat instructior. No deleniti quaerendum vim, assum saepe munere ea vis, te tale tempor sit. An sed debet ocurreret adversarium, ne enim docendi mandamus sea.
# Since w=0 it will go all the way to the right margin.
pdf.multi_cell(0,th, loremipsum)

# Next page will be landscape.


# Same text as before.
# Since w=0 it will go all the way to the right margin.
pdf.multi_cell(0,th, loremipsum)


page orientation pyfpdf


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s