本文整理汇总了Python中reportlab.platypus.Table.wrapOn方法的典型用法代码示例。如果您正苦于以下问题:Python Table.wrapOn方法的具体用法?Python Table.wrapOn怎么用?Python Table.wrapOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.Table
的用法示例。
在下文中一共展示了Table.wrapOn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __budgets_spent
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def __budgets_spent(self):
self.l = 800
p = PageBreak()
p.drawOn(self.c, 0, 1000)
self.c.showPage()
self.c.setFont('Courier', 14)
self.c.drawString(30, self.l, 'Budgets')
header = ['Nombre', 'Gastado', 'Balance', 'Limite']
data = [header]
for bud in self.budgets:
data.append([bud.name, bud.spent,
bud.balance, bud.limit])
self.l -= len(data) * 19
t = Table(data)
t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, black),
('BOX', (0,0), (-1,-1), 0.25, black),
('FONTNAME', (0,0), (-1,0), 'Courier-Bold'),
('BACKGROUND', (0,0), (-1,0), HexColor('#efeded')),
('BACKGROUND', (0,0), (0,-1), HexColor('#efeded')),
('FONTSIZE', (0,0), (-1,0), 12),
('FONTSIZE', (0,1), (-1,-1), 8),
('FONTNAME', (0,1), (-1,-1), 'Courier')]))
t.wrapOn(self.c, 30, self.l)
t.drawOn(self.c, 30, self.l)
示例2: pdf
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def pdf(self):
"""
Metodo pdf:
Este metodo genera el pdf, y en el nombre
le pone la fecha en la que es generado
utilizamos canvas, y llamamos al metodo tabla
para agregar la tabla al pdf
"""
titulos = [
["MATRICULA", "VEHICULO", "KILOMETROS", "FECHA ENTRADA", "CLIENTE", "CIF/NIF", "TELEFONO", "DIRECCION"]]
clientes = titulos + list(self.cursor.execute("select * from taller"))
tabla = Table(clientes)
estilo = TableStyle([('GRID', (0, 0), (-1, -1), 2, colors.white),
('BACKGROUND', (0, 1), (-1, -1), colors.lightblue),
('BACKGROUND', (0, 0), (-1, 0), colors.lightred)])
tabla.setStyle(estilo)
canvas = canvas.Canvas(self.historialpdf, pagesize=letter)
canvas.drawString(20, 800, "Impresion lista clientes")
tabla.wrapOn(canvas, 20, 30)
tabla.drawOn(canvas, 20, 600)
canvas.save()
self.popup("PDF Generado")
示例3: setFooter
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def setFooter(self, pageNumber):
"""
sets all footer information per page, add page info, footer bar, and privacy info, aligned on the bottom center of the page
:param pageNumber:
:return:
"""
companyLogoW = self.setCompanyLogo()
companyLogoW += 5 if companyLogoW else 0 # add 5 for padding if company logo exists
self.canvas.setLineWidth(width=1)
self.canvas.setFillColor(lightslategray)
self.canvas.setStrokeColor(black)
self.canvas.rect(self.marginSize+companyLogoW, self.header, (self.pageWidth-(self.marginSize*2))-companyLogoW, (self.marginSize/2), fill=True, stroke=True)
self.canvas.setFillColor(black)
# footer text
self.canvas.setFont(self.fontType, 9)
self.canvas.drawRightString(self.pageWidth-(self.marginSize*1.25), (self.marginSize*1.625),"%s Page - %d" % (self.pageInfo, pageNumber))
# set privacy info on the bottom of the page
privacyInfo = {'msg1':"CONFIDENTIAL: The images, artwork and other materials displayed are the proprietary property of %s."%self.companyName,
'msg2':"Any unauthorized use, printing, copying or distribution of such images, artwork and materials is strictly prohibited. All rights reserved.",
'textColor':self.textColor,
'fontName':self.fontType,
'size':7}
shotName = Paragraph('''<para align=center spaceb=3>
<font name=%(fontName)s size=%(size)s color=%(textColor)s>%(msg1)s<br/>
%(msg2)s</font></para>'''%privacyInfo, self.styles['BodyText'])
privacyTable = Table([[shotName]], colWidths=(self.pageWidth-(self.marginSize*2)))
privacyTable.setStyle(TableStyle([('VALIGN',(-1,-1),(-1,-1),'TOP')]))
privacyTable.wrapOn(self.canvas, self.marginSize, 10)
privacyTable.drawOn(self.canvas, self.marginSize, 10)
示例4: __reminders
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def __reminders(self):
self.l = 800
p = PageBreak()
p.drawOn(self.c, 0, 1000)
self.c.showPage()
self.c.setFont('Courier', 14)
self.c.drawString(30, self.l, 'Recordatorio de pagos')
header = ['Fecha', 'Descripcion', 'Monto']
data = [header]
for rem in self.reminders:
data.append([rem.start_date, rem.description,
rem.amount])
self.l -= len(data) * 19
t = Table(data)
t.setStyle(TableStyle([('INNERGRID', (0,0), (-1,-1), 0.25, black),
('BOX', (0,0), (-1,-1), 0.25, black),
('FONTNAME', (0,0), (-1,0), 'Courier-Bold'),
('BACKGROUND', (0,0), (-1,0), HexColor('#efeded')),
('BACKGROUND', (0,0), (0,-1), HexColor('#efeded')),
('FONTSIZE', (0,0), (-1,0), 12),
('FONTSIZE', (0,1), (-1,-1), 8),
('FONTNAME', (0,1), (-1,-1), 'Courier')]))
t.wrapOn(self.c, 30, self.l)
t.drawOn(self.c, 30, self.l)
示例5: export_notes
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def export_notes(self, request, suffix=''):
""" Return an pdf export of user and public notes
Returns:
response
"""
res = Response()
student = self.__get_current_user()
try:
timecoded_data_set = self.__list_notes()
timecoded_data_array = []
for timecoded_data in timecoded_data_set:
timecoded_data_array.append([timecoded_data.seconds, Paragraph(timecoded_data.content.replace('\n','<br />'), ParagraphStyle("Page"))])
res.headerlist = [('Content-type', 'application/pdf'), ('Content-Disposition', 'attachment; filename=%s' % str(self.scope_ids.user_id)+".pdf")]
p = canvas.Canvas(res)
if (len(timecoded_data_array)>0):
table = Table(timecoded_data_array, colWidths=[20, 500])
table.setStyle(TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))
table.wrapOn(p, 700, 700)
table.drawOn(p, 50, 700)
p.showPage()
p.save()
return res
except KNoteList.DoesNotExist:
res.status = 404
return res
示例6: drawForceUnitsPlatypusTable
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def drawForceUnitsPlatypusTable(p, force, WIDTH, HEIGHT):
styleSheet = getSampleStyleSheet()
TABLE_WIDTH=.9*WIDTH
TABLE_HEIGHT=.65*HEIGHT
desc=paragraph.Paragraph('''
<para align=center spaceb=3>blah blah blah blah blah blah blah blah blah blah long description of some very uniteresting force.</para>''', styleSheet["BodyText"])
unitTitle = paragraph.Paragraph('''
<para align=center spaceb=3>Unit</para>''',
styleSheet["BodyText"])
countTitle = paragraph.Paragraph('Count', styleSheet['BodyText'])
costTitle = paragraph.Paragraph('Cost', styleSheet['BodyText'])
units = getForceUnits(force)
data= [ [unitTitle, countTitle, costTitle]]
count = int(0)
for unit in units:
namePara = paragraph.Paragraph(unit.name, styleSheet['BodyText'])
data.append([namePara, units[unit], units[unit]*unit.cost])
print 'appending [%s][%d][%d]' % (namePara, units[unit], units[unit]*unit.cost)
count = count+1
print 'i think last cell is 2,%d' % (count-1)
t=Table(data,style=[('BACKGROUND', (0, 0), (2, 0), colors.darkgrey),
('TEXTCOLOR', (0, 0), (2,0), colors.white),
('BACKGROUND', (0, 1), (2,count-2), colors.white),
('GRID',(0,0),(-1,-1),0.5,colors.black),
('ALIGN',(0,0),(-1,-1),'CENTER'),
], colWidths=[.68*TABLE_WIDTH, .17 * TABLE_WIDTH, .15 * TABLE_WIDTH])
t.wrapOn(p, TABLE_WIDTH, TABLE_HEIGHT)
t.drawOn(p, (WIDTH-TABLE_WIDTH)/2, .02*HEIGHT)
return p
示例7: tradingReport
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def tradingReport(self, c):
title = "DAILY TRADING"
c.setFont("Helvetica", 24)
c.drawString(50,770, title)
c.setFont("Helvetica", 16)
c.drawString(50,730, "DATE :")
c.drawString(110,730, str(today.year) + "/" + str(today.month) + "/" + str(today.day) ) # DATE
c.line(110, 727, 185, 727)
c.drawString(300,730, "Today's Performance :")
c.line(465, 727, 515, 727)
c.drawString(470,730, "4%") # PROFIT value
c.drawString(50,680, "Market Analysis")
columHeight = [1*cm, 1*cm, 1*cm, 1*cm]
t=Table(self._data, 2.5*cm, columHeight) # The size of each cells
t.setStyle(TableStyle([('GRID',(0,0),(-1,-1),1,colors.black),
('VALIGN',(0,0),(-1,-1),'TOP')]))
t.wrapOn(c, 50,50)
t.drawOn(c, 50,550) #Table Location
c.drawString(50,500, "Intraday performance of Algorithm1")
graph_1 = Image("example.png")
graph_1.drawHeight = 6*cm
graph_1.drawWidth = 17.5*cm
#graph_1.wrapOn(c, 50,20)
graph_1.drawOn(c,50,322)
c.drawString(50,295, "Intraday performance of Algorithm2")
graph_2 = Image("example2.png")
graph_2.drawHeight = 6*cm
graph_2.drawWidth = 17.5*cm
#graph_2.wrapOn(c, 50,20)
graph_2.drawOn(c,50,117)
示例8: pdf
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def pdf(self):
"""
Metodo pdf:
Este metodo genera el pdf, y en el nombre
le pone la fecha en la que es generado
utilizamos canvas, y llamamos al metodo tabla
para agregar la tabla al pdf
"""
self.canvas = canvas.Canvas(self.historialpdf, pagesize=letter)
titulos = [
["DNI", "NOMBRE", "APELLIDOS", "DIRECCION", "TELEFONO", "FNACIMIENTO"]]
clientes = titulos + list(self.cursor.execute("select * from CLIENTE"))
tabla = Table(clientes)
estilo = TableStyle([('GRID', (0, 0), (-1, -1), 2, colors.white),
('BACKGROUND', (0, 1), (-1, -1), colors.lightblue),
('BACKGROUND', (0, 0), (-1, 0), colors.lightcoral)])
tabla.setStyle(estilo)
self.canvas.drawString(20, 800, "Impresion lista clientes")
tabla.wrapOn(self.canvas, 20, 30)
tabla.drawOn(self.canvas, 20, 600)
self.canvas.save()
self.popup("PDF Generado")
示例9: tmplPage
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def tmplPage(canvas, doc): # шаблон страницы
canvas.saveState()
class rotateText(Flowable): # определение класса поворачиваемого текста на 90 градусов
def __init__(self, text):
self.text = text
self.parag = Paragraph(self.text, styleSheet)
def wrap(self, availWidth, availHeight):
return -availWidth, availHeight
def draw(self):
self.canv.rotate(90)
self.parag.wrapOn(self.canv, self._fixedHeight, self.parag._fixedWidth)
self.parag.drawOn(self.canv, 0, 0)
dataTable = [[u'Инвен-\nтарный\nномер', u'Дата', u'Обозначение', rotateText(u'Кол. листов'), # заголовок таблицы
rotateText(u'Формат'), u'Наименование', u'Кем\nвыпу-\nщен',
Paragraph(u'Подпись\nо\nприем-\nке до-\nкумента', styleSheet), u'При-\nмечание']]
t = Table(dataTable, columnWidths, 18*mm) # формирование таблицы
t.setStyle(tabStyle) # присвоение таблице стиля
t.wrapOn(canvas, *pagesizes.A4)
t.drawOn(canvas, 20*mm, pagesizes.A4[1] - (pagesizes.A4[1] - rowHeight*rowCount - t._height)/2 - t._height + Hoffset) # отрисовка таблицы
canvas.drawString(pagesizes.A4[0] - 10*mm, 5*mm, str(doc.page)) # отрисовка номера страницы
canvas.restoreState()
示例10: createDocument
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def createDocument(self, address, body, greetings):
voffset = 120
# create return address
paragraph = Paragraph(address.nombre+"<br />"+address.direccion1+"<br />"+address.direccion2+"<br />"+address.direccion3+"<br />"+address.direccion4, self.styles["Normal"])
header = [["",paragraph]]
table = Table(header, colWidths=4*inch)
table.setStyle([("VALIGN", (0,0), (0,0), "TOP")])
table.wrapOn(self.c, self.width, self.height)
table.drawOn(self.c, *self.coord(18, 60, mm))
# insert body of letter
print "bodyyy"
print body
body = body.replace('\n','<br />')
p = Paragraph(body, self.styles["Normal"])
p.wrapOn(self.c, self.width-70, self.height)
p.drawOn(self.c, *self.coord(20, voffset+50, mm))
# greetings
try:
p = Paragraph(greetings.nombre+"<br />"+greetings.direccion1+"<br />"+greetings.direccion2+"<br />"+greetings.direccion3+"<br />"+greetings.direccion4, self.styles["Normal"])
except:
p = Paragraph("", self.styles["Normal"])
p.wrapOn(self.c, self.width-70, self.height)
p.drawOn(self.c, *self.coord(20, voffset+75, mm))
示例11: get
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def get(self, request, *args, **kwargs):
sales_invoice_id = kwargs['sales_invoice_id']
sales_invoice = SalesInvoice.objects.get(id=sales_invoice_id)
sales = sales_invoice.sales
response = HttpResponse(content_type='application/pdf')
p = canvas.Canvas(response, pagesize=(1000, 1000))
status_code = 200
y=850
data=[['', sales_invoice.date.strftime('%d-%m-%Y'), '', sales_invoice.invoice_no]]
table = Table(data, colWidths=[0, 100, 650, 100], rowHeights=40)
table.wrapOn(p, 200, 400)
table.drawOn(p,100, 750)
quotation = sales_invoice.quotation
data=[['', '', sales_invoice.delivery_note.lpo_number if sales_invoice.delivery_note else '' ]]
table = Table(data, colWidths=[450, 60, 100], rowHeights=40)
table.wrapOn(p, 200, 400)
table.drawOn(p,100, 700)
data=[['', '', sales_invoice.date.strftime('%d-%m-%Y')]]
table = Table(data, colWidths=[450, 30, 100], rowHeights=40)
table.wrapOn(p, 200, 400)
table.drawOn(p,100, 650)
if sales_invoice.quotation or sales_invoice.delivery_note:
data=[['', '', sales_invoice.delivery_note.delivery_note_number if sales_invoice.delivery_note else sales_invoice.quotation.reference_id]]
table = Table(data, colWidths=[450, 30, 100], rowHeights=40)
table.wrapOn(p, 200, 400)
table.drawOn(p,150, 620)
x=600
i = 0
i = i + 1
for s_item in sales.salesitem_set.all():
x=x-40
item_price = s_item.item.inventory_set.all()[0].selling_price
final_price = item_price+(item_price*(s_item.item.tax/100))
data1=[[i, s_item.item.code, s_item.item.name, s_item.quantity_sold, s_item.item.uom.uom, s_item.item.inventory_set.all()[0].unit_price, (final_price*s_item.quantity_sold)]]
table = Table(data1, colWidths=[50, 100, 400, 70, 90, 100, 50], rowHeights=40)
table.wrapOn(p, 200, 400)
table.drawOn(p,50,x)
i = i + 1
p.showPage()
p.save()
return response
示例12: detalle_iva
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def detalle_iva(p, detalle):
table = Table(detalle, [5*cm, 3*cm])
table.setStyle([
('FONT', (0, 0), (-1, -1), font_bld),
('LEADING', (0, 0), (-1, -1), 4),
('ALIGN', (0, 0), (-1, -1), 'RIGHT'),
('FONTSIZE',(0,0),(-1,-1),9),
])
table.wrapOn(p, width, height)
table.drawOn(p, width - margin - 8*cm, 55*mm)
示例13: get
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def get(self, request, *args, **kwargs):
invoice_id = kwargs['invoice_id']
sales = Sales.objects.get(id=invoice_id)
response = HttpResponse(content_type='application/pdf')
p = canvas.Canvas(response, pagesize=(1000, 1300))
y = 1200
p = header(p, y)
p = invoice_body_layout(p, y, sales)
total_amount = 0
y1 = y - 400
for s_item in sales.salesitem_set.all():
data=[[Paragraph(s_item.item.name, para_style)]]
if y1 <= 170:
y1 = y - 400
p.showPage()
p = header(p, y)
p = invoice_body_layout(p, y, sales)
p.drawString(60, y1, str(s_item.quantity_sold))
p.drawString(190, y1, str(s_item.item.code))
# p.drawString(300, y1, str(item_name))
table = Table(data, colWidths=[385], rowHeights=100, style=style)
table.wrapOn(p, 200, 400)
table.drawOn(p, 300, y1-10)
p.drawString(710, y1, str(s_item.selling_price))
p.drawString(850, y1, str(s_item.net_amount))
total_amount = total_amount + s_item.net_amount
y1 = y1 - 50
# total box start
p.line(50, y - 1020, 950, y - 1020)
p.line(650, y - 980, 650, y - 1020)
p.line(50, y - 980, 50, y - 1020)
p.line(950, y - 980, 950, y - 1020)
# total box end
p.drawString(820, y - 1010, 'DHS')
p.drawString(850, y - 1010, str(total_amount))
p.setFont("Helvetica-Bold", 30)
p.drawString(660, y - 1010, 'Total')
p = footer(p, y)
# Item Box end
p.showPage()
p.save()
return response
示例14: createDocument
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def createDocument(self):
""""""
for page in self.e.findall("page"):
for image in page.findall("image"):
logo = Image(image.get("src"))
logo.drawHeight = int(image.get("height"))
logo.drawWidth = int(image.get("width"))
logo.wrapOn(self.c, self.width, self.height)
logo.drawOn(self.c, *self.coord(int(image.get("left")),int(image.get("top"))+int(image.get("height")) ))
for text in page.findall("text"):
if len(text.getchildren())==0:
font = self.fonts[text.get("font")]
style = ParagraphStyle(
'default',
fontName="Arial",
leading=int(font["size"])+7,
fontSize=font["size"],
textColor=font["color"],
backColor=font["background"],
firstLineIndent=int(font["indent"]),
)
self.createParagraph(text.text, int(text.get("left")), (int(text.get("top"))+int(text.get("height"))),style)
else:
innerText = ElementTree.tostring(text.getchildren()[0])
font = self.fonts[text.get("font")]
style = ParagraphStyle(
'default',
fontName="Arial",
leading=int(font["size"])+7,
fontSize=font["size"],
textColor=font["color"],
backColor=font["background"],
firstLineIndent=int(font["indent"]),
)
self.createParagraph(innerText, int(text.get("left")), (int(text.get("top"))+int(text.get("height"))),style)
for line in page.findall("line"):
self.c.setDash(int(line.get("on")),int(line.get("off")))
self.c.setStrokeColor(line.get("color"))
self.c.line(int(line.get("x1")),self.height-int(line.get("y1")),int(line.get("x2")),self.height-int(line.get("y2")))
for table in page.findall("table"):
self.c.setDash(1,0)
tabDat = dataDictionary[table.get("data")]
if table.get("widths"):
colWidths = [float(width) for width in table.get("widths").split(",")]
else:
colWidths = float(table.get("width"))/len(tabDat[0])
if table.get("heights"):
rowHeights = [float(height) for height in table.get("heights").split(",")]
else:
rowHeights = float(table.get("height"))/len(tabDat)
t = Table(tabDat,colWidths,rowHeights,style=tableStyles[table.get("data")])
t.wrapOn(self.c, self.width, self.height)
t.drawOn(self.c, *self.coord(int(table.get("left")), int(table.get("top"))+int(table.get("height"))))
self.c.showPage()
示例15: dibujar_tabla
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrapOn [as 别名]
def dibujar_tabla(c, data, high):
width, height = letter # ancho y alto de la hoja
table = Table(data, colWidths=[2.3 * cm, 1.8 * cm, 4.4 * cm, 2 * cm, 2 * cm, 1.8 * cm, 2 * cm, 2.1 * cm, 1.3 * cm])
table.setStyle(TableStyle([
('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.25, colors.black),
('ALIGN', (-3, 0), (-1, -1), 'RIGHT'),
('ALIGN', (3, 0), (-4, -1), 'CENTER'),
# ('TEXTCOLOR',(-3,1),(-1,-1),colors.red),
]))
# pdf size
table.wrapOn(c, width, height)
table.drawOn(c, 30, high)