user1187968
user1187968

Reputation: 7986

Python xhtml2pdf to generate PDF in landscape mode

I am using the python xhtml2pdf module and the pisa class to create a PDF. Now the PDF is in vertical A4 format, how do I change it to have the PDF to landscape layout?

import xhtml2pdf.pisa as pisa
result = StringIO()
pdf = pisa.CreatePDF(
        StringIO("This is my PDF"),
        result)

Upvotes: 5

Views: 5270

Answers (1)

user1187968
user1187968

Reputation: 7986

Use the following CSS:

@page {
    size: letter landscape;
    margin: 2cm;
}

Upvotes: 16

Related Questions