![]() |
Using Reportlab to create a landscape pdf - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Using Reportlab to create a landscape pdf (/thread-28868.html) |
Using Reportlab to create a landscape pdf - SmukasPlays - Aug-07-2020 I'm trying to create a pdf in landscape format, but I couldn't do it with some of things that I found on the internet. I don't know if they're not useful nowadays or I'm doing wrong. from reportlab.lib.pagesizes import landscape,A4 from reportlab.pdfgen import canvas pdf = canvas.Canvas("Training.pdf") canvas.Canvas.setPageSize(pdf, (landscape(A4))) pdf.drawString(10,800, 'Hello') pdf.save()I also tried to use "pagesize" or "size" and to use other formats. from reportlab.lib.pagesizes import landscape,A4 from reportlab.pdfgen import canvas pdf = canvas.Canvas("Training.pdf") canvas.Canvas.setPageSize(pdf, pagesize=(landscape(A4))) pdf.drawString(10,800, 'Hello') pdf.save() RE: Using Reportlab to create a landscape pdf - bowlofred - Aug-07-2020 I don't see anything wrong with your first snippet, except the coordinates seem to be out of bounds. If I change it from 10,800 to 10,500, the text is rendered on a landscape page. RE: Using Reportlab to create a landscape pdf - SmukasPlays - Aug-09-2020 (Aug-07-2020, 05:42 AM)bowlofred Wrote: I don't see anything wrong with your first snippet, except the coordinates seem to be out of bounds. If I change it from 10,800 to 10,500, the text is rendered on a landscape page. Oh, it was just it. Thanks! |