Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Frame, Spacer, Image
- from reportlab.lib import colors
- from reportlab.lib.units import cm, inch
- from reportlab.lib.pagesizes import A3, A4, landscape, portrait
- from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
- from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
- from reportlab.pdfgen import canvas
- SXmargin = 1.5 * cm
- DXmargin = 1.5 * cm
- def printTitle():
- st = ParagraphStyle('Normal')
- st.fontSize=30
- title = Paragraph("TITLE", st)
- data = [[None, title, None, None, title, None]]
- titleColumnSize = (doc.pagesize[0]-(SXmargin * 2 + DXmargin * 2)) /2
- tbl = Table(data, [SXmargin, titleColumnSize, DXmargin, SXmargin,
- titleColumnSize, DXmargin],None)
- tbl.hAlign = 'CENTER'
- tbl.vAlign = 'TOP'
- tblStyle = TableStyle([('TEXTCOLOR',(0,0),(-1,-1),colors.black),
- ('VALIGN',(0,0),(-1,-1),'MIDDLE'),
- ('LINEBELOW',(0,0),(-1,-1),1,colors.white),
- ('INNERGRID',(2,0),(3,0),1,colors.black),
- ('INNERGRID',(0,0),(-1,-1),1,colors.black),
- ('BOX',(0,0),(-1,-1),1,colors.black)])
- tblStyle.add('BACKGROUND',(0,0),(-1,-1),colors.white)
- tblStyle.add('ALIGN', (1, 0), (1, 0), "CENTER")
- tblStyle.add('ALIGN', (4, 0), (4, 0), "CENTER")
- tbl.setStyle(tblStyle)
- return tbl
- pdfReportPages = "test.pdf"
- doc = SimpleDocTemplate(pdfReportPages, pagesize=landscape(A4))
- elements = []
- styles=getSampleStyleSheet()
- styleN = styles["Normal"]
- elements.append(printTitle())
- doc.build(elements)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement