本文整理汇总了Python中reportlab.platypus.tables.Table.textLines方法的典型用法代码示例。如果您正苦于以下问题:Python Table.textLines方法的具体用法?Python Table.textLines怎么用?Python Table.textLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.tables.Table
的用法示例。
在下文中一共展示了Table.textLines方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from reportlab.platypus.tables import Table [as 别名]
# 或者: from reportlab.platypus.tables.Table import textLines [as 别名]
def save(self):
# We can fit 15 rows on one page. We might want to do something
# cute to avoid a single row on it's own page in the future, but
# for now, just split it evenly.
for pagenum in range(0, (len(self.rows)-1)/15+1):
self._pageheader()
islastpage = (pagenum == (len(self.rows)-1)/15)
if len(self.rows) > 15:
suffix = " (page %s/%s)" % (pagenum+1, len(self.rows)/15+1)
else:
suffix = ''
# Center between 2 and 19 is 10.5
if self.invoicenum:
if self.receipt:
self.canvas.drawCentredString(10.5*cm,19*cm, "RECEIPT FOR INVOICE NUMBER %s%s" % (self.invoicenum, suffix))
else:
self.canvas.drawCentredString(10.5*cm,19*cm, "INVOICE NUMBER %s - %s%s" % (self.invoicenum, self.invoicedate.strftime("%B %d, %Y"),suffix))
else:
self.canvas.drawCentredString(10.5*cm,19*cm, "RECEIPT - %s%s" % (self.invoicedate.strftime("%B %d, %Y"), suffix))
if pagenum == 0:
tbldata = [["Item", "Price", "Count", "Amount"], ]
else:
tbldata = [["Item - continued from page %s" % pagenum, "Price", "count", "amount"], ]
tbldata.extend([(self.trimstring(title, 10.5*cm, "Times-Roman", 10),
"%.2f %s" % (cost, self.currency),
count,
"%.2f %s" % ((cost * count), self.currency))
for title,cost, count in self.rows[pagenum*15:(pagenum+1)*15]])
style = [
('BACKGROUND',(0,0),(3,0),colors.lightgrey),
('ALIGN',(1,0),(3,-1),'RIGHT'),
('LINEBELOW',(0,0),(-1,0), 2, colors.black),
('OUTLINE', (0,0), (-1, -1), 1, colors.black),
]
if islastpage:
tbldata.append(['','','Total',"%.2f %s" % (sum([cost*count for title,cost,count in self.rows]),self.currency)])
style.append(('LINEABOVE', (-2,-1), (-1, -1), 2, colors.black))
else:
tbldata.append([' Continued on page %s' % (pagenum + 2), '', '', ''])
style.append(('ALIGN', (0, -1), (-1, -1), 'CENTER'))
style.append(('FONT', (0, -1), (-1, -1), 'Times-Italic'))
t = Table(tbldata, [10.5*cm, 2.5*cm, 1.5*cm, 2.5*cm])
t.setStyle(TableStyle(style))
w,h = t.wrapOn(self.canvas,10*cm,10*cm)
t.drawOn(self.canvas, 2*cm, 18*cm-h)
if self.receipt:
self.canvas.drawCentredString(10.5*cm,17.3*cm-h, "This invoice was paid %s" % self.duedate.strftime("%B %d, %Y"))
else:
self.canvas.drawCentredString(10.5*cm,17.3*cm-h, "This invoice is due: %s" % self.duedate.strftime("%B %d, %Y"))
t = self.canvas.beginText()
t.setTextOrigin(2*cm, 5*cm)
t.setFont("Times-Italic", 10)
t.textLine("PostgreSQL Europe is a French non-profit under the French 1901 Law. The association is not VAT registered.")
t.textLine("")
if islastpage and self.bankinfo:
t.setFont("Times-Bold", 10)
t.textLine("Bank references / Références bancaires / Bankverbindungen / Referencias bancarias")
t.setFont("Times-Roman", 8)
t.textLines("""CCM PARIS 1-2 LOUVRE MONTORGUEIL
28 RUE ETIENNE MARCEL
75002 PARIS
FRANCE
IBAN: FR76 1027 8060 3100 0205 2290 114
BIC: CMCIFR2A
""")
self.canvas.drawText(t)
# Finish this page off, and optionally loop to another one
self.canvas.showPage()
# Last page is finished, flush the PDF output
self.canvas.save()
return self.pdfdata
注:本文中的reportlab.platypus.tables.Table.textLines方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。