Python Forum
Using Reportlab to create a landscape pdf
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Reportlab to create a landscape pdf
#1
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()
Reply
#2
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.
Reply
#3
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cyrillic symbols in tables in reportlab. hiroz 5 2,667 Sep-10-2020, 04:57 AM
Last Post: bradmalcom
  Help! - How to create a Title for a Reportlab Table crabbylou 0 985 Mar-29-2020, 09:14 PM
Last Post: crabbylou
  ReportLab Polypop77 0 340 Mar-20-2020, 01:17 PM
Last Post: Polypop77
  Python Reportlab Wordwrap Table Mady 0 2,552 Dec-18-2018, 06:31 AM
Last Post: Mady
  Reportlab Dynamic Table Q Gutt 0 2,734 Jun-13-2018, 10:18 PM
Last Post: Gutt
  Reportlab: Add xlabel, ylabel and grid to lineplot denissanga 2 3,123 Dec-19-2017, 04:48 PM
Last Post: denissanga
  ReportLab ek5442 2 2,214 Aug-24-2017, 01:29 PM
Last Post: ek5442
  Python ReportLab ek5442 6 4,570 Mar-15-2017, 07:47 PM
Last Post: ek5442

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020