[Python] Create A4 size PDF from image by using reportlab

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    I want to convert an A4 scanned image to PDF by using reportlab in python. I wrote bellow code but I get error. How can I fix it ?

    from reportlab.lib.pagesizes import A4
    from reportlab.lib.units import mm
    height, width = A4
    doc = SimpleDocTemplate("image.pdf", pagesize=A4)
    parts = []
    parts.append(Image("image.jpg",width=210*mm, height= 293*mm))
    doc.build(parts)


    reportlab.platypus.doctemplate.LayoutError: Flowable (595.275590551 x 830.551181102) too large on page 2 in frame 'normal'(439.275590551 x 685.88976378*) of template 'Later'

    Continue reading...

Compartilhe esta Página