本文整理汇总了Python中reportlab.platypus.tables.Table类的典型用法代码示例。如果您正苦于以下问题:Python Table类的具体用法?Python Table怎么用?Python Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: imprimir_alertas
def imprimir_alertas(self,items):
buffer = self.buffer
doc = SimpleDocTemplate(buffer,
rightMargin = 15*mm,
leftMargin = 15*mm,
topMargin = 15*mm,
bottomMargin = 15*mm,
pagesize = self.pagesize)
elements = []
styles = getSampleStyleSheet()
styles.add(ParagraphStyle(name='logo',alignment=TA_LEFT,leftIndent=8*mm,
fontSize=14))
logo = MEDIA_ROOT + "/logo.jpg"
elements.append(ImageAndFlowables(Image(logo,width=75*mm,height=25*mm),
[Paragraph("<b>Departamento de Mantenimiento</b>",styles['logo']),
Paragraph("Alertas de falta de material en inventario",styles['Heading2'])],
imageSide = 'left'))
tablaItems = Table(items, colWidths=[doc.width/4.0]*4)
tablaItems.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),colors.HexColor(0xD8D8D8)),
('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))
elements.append(tablaItems)
doc.build(elements, canvasmaker=CanvasNumerado)
pdf = buffer.getvalue()
buffer.close()
return pdf
开发者ID:vickyjm,项目名称:SistemaHOI,代码行数:29,代码来源:generarPdf.py
示例2: renderToc
def renderToc(self, tocpath, toc_entries, rtl):
doc = SimpleDocTemplate(tocpath, pagesize=(pdfstyles.page_width, pdfstyles.page_height))
elements = []
elements.append(
Paragraph(_("Contents"), pdfstyles.heading_style(mode="chapter", text_align="left" if not rtl else "right"))
)
toc_table = []
styles = []
col_widths = self._getColWidths()
for row_idx, (lvl, txt, page_num) in enumerate(toc_entries):
if lvl == "article":
page_num = str(page_num)
elif lvl == "chapter":
page_num = "<b>%d</b>" % page_num
styles.append(("TOPPADDING", (0, row_idx), (-1, row_idx), 10))
elif lvl == "group":
page_num = " "
styles.append(("TOPPADDING", (0, row_idx), (-1, row_idx), 10))
toc_table.append(
[
Paragraph(txt, pdfstyles.text_style(mode="toc_%s" % str(lvl), text_align="left")),
Paragraph(page_num, pdfstyles.text_style(mode="toc_article", text_align="right")),
]
)
t = Table(toc_table, colWidths=col_widths)
t.setStyle(styles)
elements.append(t)
doc.build(elements)
开发者ID:pediapress,项目名称:mwlib.rl,代码行数:29,代码来源:toc.py
示例3: __format_data
def __format_data(data):
styles = getSampleStyleSheet()
assets = data['assets']
liabilities = data['liabilities']
d = [['NR.\nCRT.', 'ELEMENTE DE ACTIV', 'VALORI\n(LEI)', 'ELEMENTE DE PASIV', 'VALORI\n(LEI)'],
['1.', Paragraph(u'Sold în casă', styles['Normal']), assets['cash'], Paragraph('Sold fond de rulment', styles['Normal']), liabilities['rulment']],
['2.', Paragraph(u'Sold conturi la bănci', styles['Normal']), assets['bank'], Paragraph(u'Sold fond de reparații', styles['Normal']), liabilities['repairs']],
['3.', Paragraph(u'Sume neachitate de proprietarii din asociație pentru lista de plată curentă', styles['Normal']), assets['apartment_pending'], Paragraph('Sold fond sume speciale', styles['Normal']), liabilities['special']],
['4.', Paragraph(u'Restanțe existente la data întocmirii acestei situații', styles['Normal']), assets['penalties_pending'], Paragraph('Soldul altor fonduri legal stabilite', styles['Normal']), '0'],
['5.', Paragraph(u'Debitori, alții decât mebrii asociației', styles['Normal']), '0', Paragraph('Furnizori pentru facturi neachitate', styles['Normal']), '0'],
['6.', Paragraph(u'Acte de plată pe luna în curs, nerepartizate proprietarilor', styles['Normal']), assets['outstanding_invoices'], Paragraph(u'Creditori diverși', styles['Normal']), liabilities['3rd party']],
['7.', Paragraph(u'Acte de plăți pentru cheltuielile aferente fondurilor de reparații, speciale, de penalizări care nu au fost încă scăzute din fondurile respective', styles['Normal']), '0', '', ''],
['', Paragraph(u'TOTAL PARTEA I', styles['Normal']), sum(assets.values()), Paragraph(u'TOTAL PARTEA II', styles['Normal']), sum(liabilities.values())]
]
table = Table(d, colWidths=[1.3 * cm, 7 * cm, 4 * cm, 7 * cm, 4 * cm])
table.setStyle(TableStyle([
('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
('ALIGN', (0, 0), (-1, 0), 'CENTER'),
('VALIGN', (0, 0), (-1, 0), 'MIDDLE'),
('ALIGN', (0, 0), (0, -1), 'CENTER'),
('VALIGN', (0, 0), (0, -1), 'MIDDLE'),
('ALIGN', (2, 0), (2, -1), 'CENTER'),
('VALIGN', (2, 0), (2, -1), 'MIDDLE'),
('ALIGN', (4, 0), (4, -1), 'CENTER'),
('VALIGN', (4, 0), (4, -1), 'MIDDLE'),
('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.25, colors.black)
]))
return table
开发者ID:habitam,项目名称:habitam-core,代码行数:32,代码来源:balance.py
示例4: SQL_to_table
def SQL_to_table(fn):
'Convert a SQLITE db to a table object'
data = SQL_to_2D_list(fn)
# add blank column to the end for clean splitting between pages
for i in range(len(data)):
newrow = data[i] + ['']
data[i] = newrow
# Style Sheet
style=[('VALIGN',(0,0),(-1,-1),'TOP'),
('ALIGN',(0,0),(0,-1),'CENTER'),#number col
('VALIGN',(0,0),(0,-1),'MIDDLE'),#number col
('ALIGN',(2,0),(-1,-1),'CENTER'),#answer col
('VALIGN',(2,0),(-1,-1),'MIDDLE'),#answer col
('RIGHTPADDING',(0,0),(-1,-1),5),
('LEFTPADDING',(0,0),(-1,-1),5),
('TOPPADDING',(0,0),(-1,-1),1),
('BOTTOMPADDING',(0,0),(-1,-1),1)]
# special styles
for i in range(0,len(data),3):
style.append( ('SPAN',(-1,i),(-1,i+2)) ) # merge blank column rows
style.append( ('SPAN',(1,i),(1,i+1)) ) # merge text rows
style.append( ('GRID',(1,i),(-2,i+1),1,colors.black) ) # add grid lines
style.append( ('BOX',(0,i),(0,i+1),1,colors.black) ) # grid around numbers
style.append( ('BOX',(0,i+2),(-2,i+2),1,colors.black) ) # grid around separator
style.append( ('TOPPADDING',(0,i+2),(-2,i+2),29) ) # Leave space for comments
t = Table(data, colWidths=(25,355,26,26,26,26,26,1))
t.setStyle(TableStyle(style))
return t
开发者ID:codemaker1999,项目名称:SurveyGen,代码行数:28,代码来源:create_survey_form.py
示例5: build_revisions_table
def build_revisions_table(self):
body_style = self.styles['BodyText']
self.styles.add(ParagraphStyle(
name='BodyCentered',
parent=body_style,
alignment=TA_CENTER,
))
centered = self.styles['BodyCentered']
header = (
'Document Number',
'Title',
'Rev.',
'Status',
'RC')
data = [header]
for revision in self.revisions:
data.append((
Paragraph(revision.document.document_number, body_style),
Paragraph(revision.document.title, body_style),
Paragraph(revision.name, centered),
Paragraph(revision.status, centered),
Paragraph(revision.get_final_return_code(), centered)))
table = Table(
data,
hAlign='LEFT',
colWidths=[70 * mm, 75 * mm, 10 * mm, 15 * mm, 10 * mm])
style = self.get_table_style()
style.add('ALIGN', (0, 0), (-1, 0), 'CENTER')
table.setStyle(style)
return table
开发者ID:Talengi,项目名称:phase,代码行数:32,代码来源:pdf.py
示例6: tabela
def tabela(self, largura, altura, dados, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1, emptyTableAction=None, ident=None, hAlign=None, vAlign=None):
# Escape dados str ou unicode
dados = [[escape(d) if isinstance(d, (str, unicode)) else d for d in l] for l in dados]
# Renderizar 1 linha
tabela = Table(dados[:1], colWidths, rowHeights, style, repeatRows, repeatCols, splitByRow, emptyTableAction, ident, hAlign, vAlign)
l, a = tabela.wrapOn(self.canvas, largura, altura)
# Quantas linhas dessa altura cabem
linhas = int(altura/a)
# Renderizar linhas
tabela = Table(dados[:linhas], colWidths, rowHeights, style, repeatRows, repeatCols, splitByRow, emptyTableAction, ident, hAlign, vAlign)
l, a = tabela.wrapOn(self.canvas, largura, altura)
# Se não couber, vou tirando de 1 em 1
if a > altura:
for i in range(linhas, 0, -1):
tabela = Table(dados[:i], colWidths, rowHeights, style, repeatRows, repeatCols, splitByRow, emptyTableAction, ident, hAlign, vAlign)
l, a = tabela.wrapOn(self.canvas, largura, altura)
if a <= altura:
break
return (tabela, i, a)
# Se couber, vou colocando de 1 em 1
i = linhas
for i in range(linhas, len(dados)):
tabela = Table(dados[:i], colWidths, rowHeights, style, repeatRows, repeatCols, splitByRow, emptyTableAction, ident, hAlign, vAlign)
l, a = tabela.wrapOn(self.canvas, largura, altura)
if a > altura:
break
i -= 1
tabela = Table(dados[:i], colWidths, rowHeights, style, repeatRows, repeatCols, splitByRow, emptyTableAction, ident, hAlign, vAlign)
l, a = tabela.wrapOn(self.canvas, largura, altura)
return (tabela, i, a)
开发者ID:JuniorPolegato,项目名称:pole,代码行数:30,代码来源:PolePDF.py
示例7: endFunctions
def endFunctions(self, names):
h1, h2, h3, bt, code = self.h1, self.h2, self.h3, self.bt, self.code
styleSheet = getSampleStyleSheet()
bt1 = styleSheet['BodyText']
story = self.story
if not names:
return
tsa = tableStyleAttributes = []
# Make table with class and method rows
# and add it to the story.
p = Paragraph('<b>%s</b>' % self.classCompartment, bt)
p.style.alignment = TA_CENTER
rows = [(p,)]
lenRows = len(rows)
tsa.append(('BOX', (0,0), (-1,lenRows-1), 0.25, colors.black))
for name, doc, sig in self.methodCompartment:
nameAndSig = Paragraph('<b>%s</b>%s' % (name, sig), bt1)
rows.append((nameAndSig,))
# No doc strings, now...
# docStr = Paragraph('<i>%s</i>' % reduceDocStringLength(doc), bt1)
# rows.append((docStr,))
tsa.append(('BOX', (0,lenRows), (-1,-1), 0.25, colors.black))
t = Table(rows, (12*cm,))
tableStyle = TableStyle(tableStyleAttributes)
t.setStyle(tableStyle)
self.story.append(t)
self.story.append(Spacer(1*cm, 1*cm))
开发者ID:JeffBerger,项目名称:solcorporation,代码行数:29,代码来源:docpy.py
示例8: buildHowToPayTable
def buildHowToPayTable(mem, dic_styles):
'''
Return a Reportlab table with payment instructions
'''
data= [[Paragraph('How to pay ?', dic_styles['MEDIUM'])],
[Paragraph('1', dic_styles['SMALL']), Paragraph(PAYOPTIONBANKTRANSFER.format(acname=mem.organisation.bank_account_name,
acnum=mem.organisation.bank_account_number,
payref='15A-' + str(mem.id),
adveml=mem.organisation.treasurer_email),
dic_styles['SMALL'])],
[Paragraph('2', dic_styles['SMALL']), Paragraph(PAYOPTIONBANKCHEQUE.format(acname=mem.organisation.bank_account_name,
orgadd=mem.organisation.postal_address,
payref='15A-' + str(mem.id)),
dic_styles['SMALL'])]]
t=Table(data,colWidths=(7.5*mm, None))
t.setStyle(TableStyle([
('BOTTOMPADDING', (0, 0), (-1, 0), 9),
('TOPPADDING', (0, 1), (-1, 1), 0),
('BOTTOMPADDING', (0, 1), (-1, 1), 9),
('VALIGN', (0, 1), (-1, -1), 'TOP'),
('SPAN', (0, 0), (-1, 0)),
]))
return t
开发者ID:g--,项目名称:membaman,代码行数:27,代码来源:admin_action.py
示例9: buildPriceTable
def buildPriceTable(dic_styles):
'''
Return a Reportlab table with pricing information
'''
data= [[Paragraph("Annual Fee", dic_styles['MEDIUM']), "", Paragraph(ANNUALFEE, dic_styles['MEDIUM'])],
[Paragraph("Options", dic_styles['MEDIUM'])],
[Paragraph('1', dic_styles['SMALL']), Paragraph(ANNUALPAYINFULLTERMS, dic_styles['SMALL']), Paragraph(ANNUALPAYINFULLAMOUNT, dic_styles['SMALL'])],
[Paragraph('2', dic_styles['SMALL']), Paragraph(ANNUALPAYAUTO, dic_styles['SMALL']), Paragraph(ANNUALPAYAUTOAMOUNT, dic_styles['SMALL'])],
[Paragraph('3', dic_styles['SMALL']), Paragraph(ANNUALPAYONETERMTERMS, dic_styles['SMALL']), Paragraph(ANNUALPAYONETERMAMOUNT, dic_styles['SMALL'])]]
t=Table(data,colWidths=(7.5*mm, None, 30*mm))
t.setStyle(TableStyle([
('TOPPADDING', (0, 0), (-1, 0), 0),
('BOTTOMPADDING', (0, 0), (-1, 0), 9),
('TOPPADDING', (0, 1), (-1, 1), 0),
('BOTTOMPADDING', (0, 1), (-1, 1), 9),
('TOPPADDING', (0, 1), (-1, 1), 6),
('BOTTOMPADDING', (0, 1), (-1, 1), 6),
('SPAN', (0, 1), (-1, 1)),
('SPAN', (0, 0), ( 1, 0)),
('VALIGN', (0, 0), (-1, -1), 'TOP'),
]))
return t
开发者ID:g--,项目名称:membaman,代码行数:25,代码来源:admin_action.py
示例10: renderToc
def renderToc(self, tocpath, toc_entries):
doc = SimpleDocTemplate(tocpath, pagesize=(pdfstyles.page_width, pdfstyles.page_height))
elements = []
elements.append(Paragraph(_('Contents'), pdfstyles.heading_style(mode='chapter', text_align='left')))
toc_table =[]
styles = []
col_widths = self._getColWidths()
for row_idx, (lvl, txt, page_num) in enumerate(toc_entries):
if lvl == 'article':
page_num = str(page_num)
elif lvl == 'chapter':
page_num = '<b>%d</b>' % page_num
styles.append(('TOPPADDING', (0, row_idx), (-1, row_idx), 10))
elif lvl == 'group':
page_num = ' '
styles.append(('TOPPADDING', (0, row_idx), (-1, row_idx), 10))
toc_table.append([
Paragraph(txt, pdfstyles.text_style(mode='toc_%s' % str(lvl), text_align='left')),
Paragraph(page_num, pdfstyles.text_style(mode='toc_article', text_align='right'))
])
t = Table(toc_table, colWidths=col_widths)
t.setStyle(styles)
elements.append(t)
doc.build(elements)
开发者ID:ingob,项目名称:mwlib.rl,代码行数:25,代码来源:toc.py
示例11: endClass
def endClass(self, name, doc, bases):
h1, h2, h3, bt, code = self.h1, self.h2, self.h3, self.bt, self.code
styleSheet = getSampleStyleSheet()
bt1 = styleSheet['BodyText']
story = self.story
# Use only the first line of the class' doc string --
# no matter how long! (Do the same later for methods)
classDoc = reduceDocStringLength(doc)
tsa = tableStyleAttributes = []
# Make table with class and method rows
# and add it to the story.
p = Paragraph('<b>%s</b>' % self.classCompartment, bt)
p.style.alignment = TA_CENTER
rows = [(p,)]
# No doc strings, now...
# rows = rows + [(Paragraph('<i>%s</i>' % classDoc, bt1),)]
lenRows = len(rows)
tsa.append(('BOX', (0,0), (-1,lenRows-1), 0.25, colors.black))
for name, doc, sig in self.methodCompartment:
nameAndSig = Paragraph('<b>%s</b>%s' % (name, sig), bt1)
rows.append((nameAndSig,))
# No doc strings, now...
# docStr = Paragraph('<i>%s</i>' % reduceDocStringLength(doc), bt1)
# rows.append((docStr,))
tsa.append(('BOX', (0,lenRows), (-1,-1), 0.25, colors.black))
t = Table(rows, (12*cm,))
tableStyle = TableStyle(tableStyleAttributes)
t.setStyle(tableStyle)
self.story.append(t)
self.story.append(Spacer(1*cm, 1*cm))
开发者ID:JeffBerger,项目名称:solcorporation,代码行数:33,代码来源:docpy.py
示例12: Naryad_Zakaz_PrintForm
def Naryad_Zakaz_PrintForm(ul,dom,date,date_str):
day_task = GetListTaskDom(ul,dom,date)
data = [['№пп','Наименование\nработ','Подъезд','Квартира','Примечание'],
]
n = 1
elements = []
### --- Имя файла для вывода ---
FILE_NAME = os.getcwd()+'/tmp/'+str(time.time())+'.pdf'
Font = ttfonts.TTFont('Arial','font/arial.ttf')
Font2 = ttfonts.TTFont('ArialBD','font/arialbd.ttf')
pdfmetrics.registerFont(Font)
pdfmetrics.registerFont(Font2)
style = getSampleStyleSheet()
style.add(ParagraphStyle(name='Disp',wordWrap=True,fontName='ArialBD',fontSize=12,spaceAfter=5*mm,spaceBefore=5*mm,alignment=2))
style.add(ParagraphStyle(name='Naryad_Zakaz',wordWrap=True,fontName='ArialBD',fontSize=14,spaceAfter=5*mm,spaceBefore=5*mm,alignment=1))
style.add(ParagraphStyle(name='DateDom',wordWrap=True,fontName='ArialBD',fontSize=12,spaceAfter=5*mm,spaceBefore=5*mm,alignment=1))
style.add(ParagraphStyle(name='Table',wordWrap=True,fontName='Arial',fontSize=11,spaceAfter=1*mm,spaceBefore=1*mm,alignment=0))
doc = SimpleDocTemplate(FILE_NAME,topMargin=10*mm,bottomMargin=10*mm,leftMargin=10*mm,rightMargin=10*mm)
for item in day_task:
row = [n,Paragraph(item[9],style["Table"]),item[13],item[12],'']
n = n + 1
data.append(row)
t=Table(data)
t.setStyle([('FONTNAME',(0,0),(-1,0),'ArialBD'),
('FONTSIZE',(0,0),(-1,0),11),
('ALIGN',(0,0),(-1,0),'CENTER'),
('VALIGN',(0,0),(-1,0),'MIDDLE'),
('GRID',(0,0),(-1,-1),0.25,colors.black),
('FONTNAME',(0,1),(-1,-1),'Arial'),
('FONTSIZE',(0,1),(-1,-1),11),
('ALIGN',(0,1),(0,-1),'CENTER'),
('ALIGN',(1,1),(-1,-1),'LEFT'),
('VALIGN',(0,1),(-1,-1),'TOP'),
])
elements.append(Paragraph('Наряд-Заказ',style["Naryad_Zakaz"]))
elements.append(Paragraph('на выполнение работ по адресу: '+ul+' дом '+dom+' на '+date_str,style["DateDom"]))
elements.append(t)
elements.append(Paragraph('Диспетчер ООО "Артэкс"',style["Disp"]))
doc.build(elements)
os.system(PDFVIEW+" "+FILE_NAME+" &")
开发者ID:v-komarov,项目名称:psv3,代码行数:59,代码来源:PrintTask.py
示例13: signatures
def signatures(font_size=None):
d = [[u'PREȘEDINTE\n(numele și semnătura)', u'CENZOR\n(numele și semnătura)', u'ADMINISTRATOR\n(numele și semnătura)']]
table = Table(d, colWidths=[7 * cm, 7 * cm, 7 * cm])
style = [('ALIGN', (0, 0), (-1, 0), 'CENTER'), ]
if font_size:
style.append(('FONTSIZE', (0, 0), (-1, -1), font_size))
table.setStyle(TableStyle(style))
return table
开发者ID:habitam,项目名称:habitam-core,代码行数:8,代码来源:common.py
示例14: _make
def _make(self, rows):
ta = Table(rows)
ta.hAlign = 'LEFT'
self._set_column_widths(ta)
self._set_row_heights(ta, rows)
s = self._get_style(rows)
ta.setStyle(s)
return ta
开发者ID:softtrainee,项目名称:arlab,代码行数:9,代码来源:pdf_table.py
示例15: build_ack_table
def build_ack_table(self):
data = [
('Name:', 'Date:'),
('Position:', 'Signature:')
]
table = Table(data, hAlign='LEFT', colWidths=[90 * mm, 90 * mm])
style = self.get_table_style()
style.add('INNERGRID', (0, 0), (-1, -1), 0, colors.white)
table.setStyle(style)
return table
开发者ID:Talengi,项目名称:phase,代码行数:10,代码来源:pdf.py
示例16: print_work_order
def print_work_order(self):
""" Render the quote PDF """
buffer = self.buffer
doc = SimpleDocTemplate(buffer,
rightMargin=1 * inch,
leftMargin=1 * inch,
topMargin=2 * inch,
bottomMargin=1 * inch,
pagesize=self.pagesize,
showBoundary=0)
# Our container for 'Flowable' objects
elements = []
# A large collection of style sheets pre-made for us
stylesheet = getSampleStyleSheet()
stylesheet.add(ParagraphStyle(name='centered', alignment=TA_CENTER))
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
project = get_object_or_404(Project, pk=self.pk)
lineitems = project.line_item.all()
# Parse lineitems and put into list [(name, description2),(name2, description2)]
data = [('Name', 'Description', 'Quantity')]
for lineitem in lineitems:
lineitem.description = "\n".join(lineitem.description.splitlines())
if "\n" not in lineitem.description:
if len(lineitem.description) > 63:
lineitem.description = textwrap.fill(lineitem.description, 64)
item = (Paragraph(lineitem.name, stylesheet['Normal']), lineitem.description, lineitem.quantity)
data.append(item)
table = Table(data, colWidths=(doc.width/5, None,0.75*inch))
table.setStyle(TableStyle([('INNERGRID', (0, 1), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.5, colors.black),
('VALIGN', (0, 0), (-1, 0), 'MIDDLE'),
('BACKGROUND', (0, 0), (-1, 0), colors.gray)]))
# Insert content tables and build doc
elements.append(Spacer(1,.5*inch))
elements.append(table)
doc.build(elements, onFirstPage=self._header_footer, onLaterPages=self._header_footer)
# Get the value of the BytesIO buffer and write it to the response.
pdf = buffer.getvalue()
buffer.close()
return pdf
开发者ID:ssbothwell,项目名称:fabco.la,代码行数:55,代码来源:printing.py
示例17: build_trs_meta
def build_trs_meta(self):
date = dateformat.format(
self.revision.created_on,
'd/m/Y')
data = [
('Transmittal Number', self.document.document_number),
('Issue Date', date),
]
table = Table(data, hAlign='LEFT', colWidths=[70 * mm, 60 * mm])
table.setStyle(self.get_table_style())
return table
开发者ID:Talengi,项目名称:phase,代码行数:11,代码来源:pdf.py
示例18: _header_footer
def _header_footer(self, canvas, doc):
""" Renders a header and footer which will be inserted regardless of pdf method"""
# Save the state of our canvas so we can draw on it
canvas.saveState()
stylesheet = getSampleStyleSheet()
# Header
logo = Image("http://www.fabco.la/fabco-seal-1.png", width=1.5*inch, height=1.5*inch)
logo.hAlign = 'CENTER'
stylesheet['BodyText'].fontSize = 10
stylesheet['BodyText'].leading = 14
stylesheet['BodyText'].leftIndent = 5
stylesheet['BodyText'].textColor = 'gray'
FabcoAddress = "Fabco Art Services\n166 West Avenue 34\nLos Angeles CA 90031"
project = get_object_or_404(Project, pk=self.pk)
rightHeader = "Job #%s\nCompletion Date %s" % (project.project_id, project.due_date)
# Build and format Left Header Table:
leftHeaderData = [[FabcoAddress],
[project.client.first_name + ' ' + project.client.last_name+'\n'+project.client.address.street+'\n'+project.client.address.city + ' ' + project.client.address.zip_code],
]
leftHeaderTable = Table(leftHeaderData)
leftHeaderTable.setStyle(TableStyle([
('LEFTPADDING',(0,0),(0, 1),0),
('TOPPADDING',(0,1),(0, 1), 30),
('BOTTOMPADDING',(0,1),(0, 1), 0),
]))
# Build and format Header Table:
headerData = [([leftHeaderTable, logo, rightHeader])]
headerTable = Table(headerData, colWidths=doc.width/3)
headerTable.setStyle(TableStyle([
('VALIGN', (0, 0), (-3, 0), 'MIDDLE'),
('VALIGN', (0, 0), (0, 0), 'TOP'),
('ALIGN',(1,0),(1,0),'CENTER'),
('ALIGN',(2,0),(2,0),'RIGHT'),
('LEFTPADDING',(0,0),(0,0),-1),
('RIGHTPADDING',(2,0),(2,0),-1),
]))
# find required space | I don't really understand this..
w, h = headerTable.wrap(doc.width, doc.height)
# render to canvas | I also don't really understand this..
headerTable.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin - doc.bottomMargin)
# Footer
footer = Paragraph('Client Signature: _________________________', stylesheet['Normal'])
w, h = footer.wrap(doc.width, doc.bottomMargin)
footer.drawOn(canvas, doc.leftMargin, doc.bottomMargin)
# Release the canvas
canvas.restoreState()
开发者ID:ssbothwell,项目名称:fabco.la,代码行数:58,代码来源:printing.py
示例19: Stamp
def Stamp(buff,d_id,person):
### --- Список согласователей ---
per = FIO_Job_Person(person)
Font1 = ttfonts.TTFont('PT','kis/fonts/PTC55F.ttf')
Font2 = ttfonts.TTFont('PTB','kis/fonts/PTC75F.ttf')
Font3 = ttfonts.TTFont('PTI','kis/fonts/PTS56F.ttf')
pdfmetrics.registerFont(Font1)
pdfmetrics.registerFont(Font2)
pdfmetrics.registerFont(Font3)
style = getSampleStyleSheet()
style.add(ParagraphStyle(name='Head',wordWrap=True,fontName='PTB',fontSize=14,spaceAfter=5*mm,spaceBefore=5*mm,alignment=1))
style.add(ParagraphStyle(name='DepName',wordWrap=True,fontName='PTB',fontSize=10,spaceAfter=5*mm,spaceBefore=5*mm,alignment=1))
style.add(ParagraphStyle(name='Data',wordWrap=True,fontName='PT',fontSize=8,spaceAfter=1*mm,spaceBefore=1*mm,alignment=0))
doc = SimpleDocTemplate(buff,topMargin=10*mm,bottomMargin=10*mm,leftMargin=20*mm,rightMargin=10*mm)
elements = []
elements.append(Paragraph('КИС Договоры заявки',style["Head"]))
elements.append(Paragraph('Номер заявки '+str(d_id),style["Head"]))
Tdata = [['Участники договорной\nработы','ФИО лица,\nзавизировавшего договор'],]
author = per[0]
Tdata.append([Paragraph(u'Ответственный исполнитель, '+author[0],style["Data"]),Paragraph(author[1],style["Data"])],)
for item in per[1:]:
Tdata.append([Paragraph(item[0],style["Data"]),Paragraph(item[1],style["Data"])],)
TableHead=Table(Tdata)
TableHead.setStyle([('FONTNAME',(0,0),(-1,-1),'PTB'),
('FONTSIZE',(0,0),(-1,-1),10),
('ALIGN',(0,0),(-1,0),'CENTER'),
('ALIGN',(0,1),(-1,-1),'LEFT'),
('VALIGN',(0,0),(-1,-1),'MIDDLE'),
('GRID',(0,0),(-1,-1),0.25,colors.black),
])
elements.append(TableHead)
doc.build(elements)
return buff
开发者ID:v-komarov,项目名称:kis,代码行数:52,代码来源:contract_print.py
示例20: _build_recap
def _build_recap(_recap_date, _recap_ref, recaps):
"""
"""
elements = []
_intro = Table([["Veuillez trouver ci-joint le r"+ u"é"+ "capitulatif des factures ainsi que le montant total " + u"à" +" payer"]], [10*cm, 5*cm], 1*[0.5*cm], hAlign='LEFT')
elements.append(_intro)
elements.append(Spacer(1, 18))
data = []
i = 0
data.append(("N d'ordre", u"Note no°", u"Nom et prénom", "Montant" ))
total = 0.0
_invoice_nrs = "";
for recap in recaps:
i+=1
data.append((i, recap[0], recap[1], recap[2]))
total = decimal.Decimal(total) + decimal.Decimal(recap[2])
_invoice_nrs += "-" + recap[0]
data.append(("", "", u"à reporter", round(total, 2), ""))
table = Table(data, [2*cm, 3*cm , 7*cm, 3*cm], (i+2)*[0.75*cm] )
table.setStyle(TableStyle([('ALIGN',(1,1),(-2,-2),'LEFT'),
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
('FONTSIZE', (0,0), (-1,-1), 9),
('BOX', (0,0), (-1,-1), 0.25, colors.black),
]))
elements.append(table)
elements.append(Spacer(1, 18))
elements.append(Spacer(1, 18))
_infos_iban = Table([["Lors du virement, veuillez indiquer la r" + u"é" + "f" + u"é" + "rence: %s " % _recap_ref]], [10 * cm], 1 * [0.5 * cm], hAlign='LEFT')
_date_infos = Table([["Date facture : %s " % _recap_date]], [10 * cm], 1 * [0.5 * cm], hAlign='LEFT')
elements.append(_date_infos)
elements.append(Spacer(1, 18))
elements.append(_infos_iban)
elements.append(Spacer(1, 18))
_total_a_payer = Table([["Total "+ u"à"+ " payer:", "%10.2f Euros" % total]], [10*cm, 5*cm], 1*[0.5*cm], hAlign='LEFT')
elements.append(_total_a_payer)
elements.append(Spacer(1, 18))
_infos_iban = Table([["Num" + u"é" + "ro IBAN: LU55 0019 4555 2516 1000 BCEELULL"]], [10*cm], 1*[0.5*cm], hAlign='LEFT')
elements.append( _infos_iban )
return elements
开发者ID:opefitoo,项目名称:nursev2,代码行数:49,代码来源:action_private_with_recap.py
注:本文中的reportlab.platypus.tables.Table类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论