Python xhtml2pdf to generate PDF in landscape mode
Asked Answered
E

1

5

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)
Elenore answered 28/3, 2016 at 20:39 Comment(0)
E
16

Use the following CSS:

@page {
    size: letter landscape;
    margin: 2cm;
}
Elenore answered 28/3, 2016 at 20:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.