Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 578
user1187968 Avatar asked Dec 15 '22 07:12

user1187968


1 Answers

Use the following CSS:

@page {
    size: letter landscape;
    margin: 2cm;
}
like image 122
user1187968 Avatar answered Dec 16 '22 21:12

user1187968