New to Report Lab

23 views
Skip to first unread message

James Miller

unread,
Jan 19, 2023, 9:30:44 PM1/19/23
to reportlab-users
Hi - 
Very new to this library. I hope someone can answer this simple question.
Why is this code generating a PDF with 2 images in one row on 2 pages that appear to have margins or padding. On the first page, the left image extends over the left page boundary and the right image extends over the page boundary. Both images have padding or margin at the top of each image. I assume this is the reason why the next row moves to a 2nd page. I want all four images on one page flush against each other and the page boundaries

This is my code - Any help greatly appreciated

#Table Test
from reportlab.platypus import Paragraph,SimpleDocTemplate,Table,TableStyle,Image,PageTemplate,PageBreak, Frame
from reportlab.lib import colors
#from reportlab.pdfgen import canvas
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch

challengeBoard=SimpleDocTemplate("myChallengeBoard.pdf")

# Next Create Frame for Page
framePage2=Frame(0,0,11.0*inch,8.5*inch,showBoundary=0)
challengeBlock=PageTemplate(id="challengepage",pagesize=[11*inch,8.5*inch],frames=[framePage2])


challengeBoard.addPageTemplates([challengeBlock])
flow_challenge=[]
styles=getSampleStyleSheet()

im_data1=Image("sitc.png",5.5*inch,4.25*inch)
im_data2=Image("sitc.png",5.5*inch,4.25*inch)
im_data3=Image("sitc.png",5.5*inch,4.25*inch)
im_data4=Image("sitc.png",5.5*inch,4.25*inch)
tabledata = [[im_data1,im_data2],
             [im_data3,im_data4]]

t1=Table(tabledata,style=[('VALIGN',(0,0),(-1,-1),'TOP'),
                          ('ALIGN',(0,0),(-1,-1),'RIGHT'),
                         ])
flow_challenge.append(t1)
flow_challenge.append(NextPageTemplate("challengepage"))
challengeBoard.build(flow_challenge)

James Miller

unread,
Jan 19, 2023, 10:29:44 PM1/19/23
to reportlab-users
I fixed the problem by trimming the images by 0.1 for both width and height
Reply all
Reply to author
Forward
0 new messages