سؤال

I am using python 2.7 and I am working in reportLab . But I want to set minimum size of the page myFileFormat.pdf. Same problem here but this is not answer to my question. The code is here:

        self.tokenFile = "myFileFormat.pdf"
        data=[["val 1"] ,["val 2"],["val 3"]]
        t=Table(data,5*[0.4*inch], 4*[0.4*inch])
        t.setStyle(TableStyle([('ALIGN',(0,0),(0,-1),'CENTER'),
                               ('BACKGROUND',(0,0),(0,0),'#D1D1D1'),
                               ]))
        self.doc = SimpleDocTemplate(self.tokenFile,pagesize=letter,
                    rightMargin=72,leftMargin=72,
                    topMargin=72,bottomMargin=60)
        self.report = []
        styleN = styles['Normal']
        self.report.append(t)
        self.doc.build(self.report)

I want to set page size manually. How I reach this problem?

Edit:

When I set pagesize=(3*inch, 3*inch). It distribute the data on page into two pages. The data include only one table form having one column and four rows. I want that data static on the same page.

هل كانت مفيدة؟

المحلول

You can specify the pagesize like you did! Just replace the argument pagesize=letter with pagesize=(5*inch, 5*inch) or whatever you want.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top