本文整理汇总了Python中reportlab.lib.styles.ParagraphStyle类的典型用法代码示例。如果您正苦于以下问题:Python ParagraphStyle类的具体用法?Python ParagraphStyle怎么用?Python ParagraphStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParagraphStyle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testRml
def testRml():
from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.platypus.flowables import Spacer
from reportlab.lib.randomtext import randomText
templ = SimpleDocTemplate('doclet_output.pdf')
#need a style
story = []
normal = ParagraphStyle('normal')
normal.firstLineIndent = 18
normal.spaceBefore = 6
para = Paragraph("Test of doclets. You should see a little table with a reversed word.", normal)
story.append(para)
story.append(Spacer(36,36))
theDoclet = TestReverseDoclet()
story.append(theDoclet.asFlowable())
for i in range(5):
para = Paragraph(randomText(), normal)
story.append(para)
templ.build(story)
print('saved doclet_output.pdf')
开发者ID:AndyKovv,项目名称:hostel,代码行数:30,代码来源:doclet.py
示例2: build_tabla_totales
def build_tabla_totales(dic_totales):
"""
Construye una tabla con los totales del presupuesto.
La tabla tiene dos columnas. En la primera están las claves del
diccionario «dic_totales». En la segunda los valores correspondientes.
La última fila de la tabla estará en negrita.
Si el diccionario de totales trae una clave "orden" (que debería) se
seguirá ese orden para mostrarlos en las filas.
"""
try:
claves = dic_totales["orden"]
except KeyError:
claves = dic_totales.keys()
datos = []
for clave in claves:
datos += [["", clave, dic_totales[clave]]]
datos[-1][1] = Paragraph("<b>%s</b>" % datos[-1][1],
estilos["BodyText"])
a_derecha = ParagraphStyle("A derecha",
parent = estilos["BodyText"])
a_derecha.alignment = enums.TA_RIGHT
datos[-1][-1] = Paragraph("<b>%s</b>" % datos[-1][-1],
a_derecha)
tabla = Table(datos,
colWidths = (PAGE_WIDTH * 0.55, # HACK: Para que ocupe lo
PAGE_WIDTH * 0.15, # mismo que la otra.
PAGE_WIDTH * 0.2)) # Si no, RL la centra.
tabla.setStyle(TableStyle([
("BOX", (1, 0), (-1, -1), 1.0, colors.black),
("INNERGRID", (1, 0), (-1, -1), 0.25, colors.black),
("ALIGN", (1, 0), (-2, -1), "LEFT"),
("ALIGN", (-1, 0), (-1, -1), "RIGHT"),
]))
return tabla
开发者ID:pacoqueen,项目名称:upy,代码行数:34,代码来源:presupuesto.py
示例3: getBody
def getBody(self, story=None):
story = story or self._story
header_style = ParagraphStyle(name='header_style', fontSize=12, alignment=TA_CENTER)
story.append(Paragraph('<b>{}</b>'.format(_('List of sessions')), header_style))
text_style = ParagraphStyle(name='text_style', fontSize=8, alignment=TA_LEFT, leading=10, leftIndent=10)
text_style.fontName = 'Times-Roman'
text_style.spaceBefore = 0
text_style.spaceAfter = 0
text_style.firstLineIndent = 0
rows = []
row_values = []
for col in [_('ID'), _('Type'), _('Title'), _('Code'), _('Description')]:
row_values.append(Paragraph('<b>{}</b>'.format(col), text_style))
rows.append(row_values)
for sess in self.sessions:
rows.append([
Paragraph(sess.friendly_id, text_style),
Paragraph(_('Poster') if sess.is_poster else _('Standard'), text_style),
Paragraph(sess.title.encode('utf-8'), text_style),
Paragraph(sess.code.encode('utf-8'), text_style),
Paragraph(sess.description.encode('utf-8'), text_style)
])
col_widths = (None,) * 5
table_style = TableStyle([
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
('LINEBELOW', (0, 0), (-1, 0), 1, colors.black),
('ALIGN', (0, 0), (-1, 0), 'CENTER'),
('ALIGN', (0, 1), (-1, -1), 'LEFT')
])
story.append(Table(rows, colWidths=col_widths, style=table_style))
return story
开发者ID:DirkHoffmann,项目名称:indico,代码行数:35,代码来源:util.py
示例4: build_encabezado
def build_encabezado(datos_albaran):
"""
Devuelve una tabla de dos líneas con los datos del albarán, que es un
diccionario de: fecha -como texto-, número (de albarán), kilos,
bultos.
"""
datos_albaran = sanitize(datos_albaran)
datos = [["Fecha", escribe("Nº Albarán"), "Kilos", "Bultos"],
[datos_albaran["fecha"], datos_albaran["número"],
datos_albaran["kilos"], datos_albaran["bultos"]]]
estilo_centrado = ParagraphStyle("Alineado centrado",
parent=estilos["Normal"])
estilo_centrado.alignment = enums.TA_CENTER
estilo_centrado.fontSize += 2
datos = [[Paragraph(celda, estilos["Normal"]) for celda in datos[0]] ,
[Paragraph(celda, estilo_centrado) for celda in datos[1]]]
tabla = Table(datos,
colWidths = (PAGE_WIDTH * 0.9/4,)*4)
tabla.setStyle(TableStyle([
("BOX", (0, 1), (-1, -1), 1.0, colors.black),
("INNERGRID", (0, 1), (-1, -1), 0.25, colors.black),
("ALIGN", (0, 0), (-1, 0), "LEFT"),
("ALIGN", (0, 1), (-1, 1), "CENTER"),
]))
return tabla
开发者ID:pacoqueen,项目名称:bbinn,代码行数:25,代码来源:albaran_porte.py
示例5: cuadritos_en_ruta
def cuadritos_en_ruta():
"""
Devuelve dos flowables:
Un texto centrado con el texto de "ENVASES VACÍOS..." y una tabla
con el texto y los cuadraditos que se rellenan a mano durante la ruta
del transportista.
"""
estilo_centrado = ParagraphStyle("Alineado centrado",
parent=estilos["Normal"])
estilo_centrado.alignment = enums.TA_CENTER
cab = Paragraph(escribe("ENVASES VACÍOS SIN LIMPIAR, 3 A.D.R."),
estilo_centrado)
datos = [["G.R.G. 1.000L", "", "", "BIDONES 100L", ""],
["", "", "", "", ""],
["DEPÓSITO 600L", "", "", "BIDONES 50L", ""],
["", "", "", "", ""],
["BIDONES 200L", "", "", "GARRAFAS 60L", ""],
["", "", "", "", ""],
["BIDONES 25L", "", "", "BIDONES 10L", ""]]
datos = [[escribe(c) for c in fila] for fila in datos]
tabla = Table(datos,
colWidths = (3*cm, 0.75*cm, 5*cm, 3*cm, 0.75*cm))
tabla.setStyle(TableStyle([
("BOX", (1, 0), (1, 0), 1.0, colors.black),
("BOX", (4, 0), (4, 0), 1.0, colors.black),
("BOX", (1, 2), (1, 2), 1.0, colors.black),
("BOX", (4, 2), (4, 2), 1.0, colors.black),
("BOX", (1, 4), (1, 4), 1.0, colors.black),
("BOX", (4, 4), (4, 4), 1.0, colors.black),
("BOX", (1, 6), (1, 6), 1.0, colors.black),
("BOX", (4, 6), (4, 6), 1.0, colors.black),
]))
return KeepTogether([Spacer(1, 0.3*cm), cab, Spacer(1, 0.5*cm), tabla])
开发者ID:pacoqueen,项目名称:bbinn,代码行数:33,代码来源:albaran_porte.py
示例6: build_tabla_totales
def build_tabla_totales(totales):
"""
Construye una tabla con los totales del albaranSalida.
La tabla tiene dos filas, cabecera y desglose. La variable «totales» es
una lista con los totales *en el siguiente orden*:
base imponible, porcentaje IVA en fracción de 1, y total.
La base imponible incluye los descuentos de las LDVs y demás.
"""
datos = [["Base imponible", "%d%% IVA" % (totales[1]*100), "Total"],
[totales[0], totales[2] - totales[0], totales[2]]]
datos = sanitize(datos)
estilo_numeros_tabla = ParagraphStyle("Números tabla",
parent=estilos["Normal"])
estilo_numeros_tabla.alignment = enums.TA_RIGHT
estilo_numeros_tabla.fontSize += 2
datos = [[Paragraph(celda, estilos["Normal"]) for celda in datos[0]] ,
[Paragraph(celda, estilo_numeros_tabla) for celda in datos[1]]]
tabla = TablaFija(78,
2*cm,
datos,
colWidths = (PAGE_WIDTH * (0.9/3),)*3)
#tabla = Table(datos,
# colWidths = (PAGE_WIDTH * (0.9/3),)*3)
tabla.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), colors.lightgrey),
("LINEBELOW", (0, 0), (-1, 0), 1.0, colors.black),
("BOX", (0, 0), (-1, -1), 1.0, colors.black),
("INNERGRID", (0, 0), (-1, -1), 1.0, colors.black),
("ALIGN", (0, 0), (-1, 0), "LEFT"),
]))
return tabla
开发者ID:pacoqueen,项目名称:bbinn,代码行数:31,代码来源:albaran_multipag.py
示例7: tabla_detalle
def tabla_detalle(self):
requerimiento = self.requerimiento
encabezados = ['Nro', 'Cantidad', 'Unidad', u'Descripción', 'Uso']
detalles = DetalleRequerimiento.objects.filter(requerimiento=requerimiento)
sp = ParagraphStyle('parrafos')
sp.alignment = TA_JUSTIFY
sp.fontSize = 8
sp.fontName = "Times-Roman"
lista_detalles = []
for detalle in detalles:
tupla_producto = [Paragraph(str(detalle.nro_detalle), sp),
Paragraph(str(detalle.cantidad), sp),
Paragraph(detalle.producto.unidad_medida.descripcion, sp),
Paragraph(detalle.producto.descripcion, sp),
Paragraph(detalle.uso, sp)]
lista_detalles.append(tupla_producto)
adicionales = [('', '', '', '', '')] * (15 - len(detalles))
tabla_detalle = Table([encabezados] + lista_detalles, colWidths=[0.8 * cm, 2 * cm, 2.5 * cm, 7 * cm, 7.7 * cm])
style = TableStyle(
[
('ALIGN', (0, 0), (4, 0), 'CENTER'),
('GRID', (0, 0), (-1, -1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 7),
('ALIGN', (4, 1), (-1, -1), 'LEFT'),
('VALIGN', (0, 0), (-1, -1), 'TOP'),
]
)
tabla_detalle.setStyle(style)
return tabla_detalle
开发者ID:joseamaya,项目名称:tambox,代码行数:29,代码来源:reports.py
示例8: get_content
def get_content(self, column_data, row_values, col_values):
"""return the content formated as defined in the constructor or in the column """
if self.value == None or self.value == False:
return ""
format = self.DEFAULT_FORMAT
if self.format != None:
format = self.format
elif type(column_data) == DateColData and column_data.format != None:
format = column_data.format
value = super(DateCellData,self).get_content(column_data, row_values, col_values)
if format != None:
value = time.strftime(format, value)
else:
value = time.strftime(self.format, value)
ps = ParagraphStyle('date_cell')
ps.fontName = self.get_font(column_data)
ps.fontSize = self.get_font_size(column_data)
ps.alignment = self.get_align_code(column_data)
res = Paragraph(c2c_helper.encode_entities(value), ps)
return res
开发者ID:3dfxmadscientist,项目名称:odoo-extra-1,代码行数:27,代码来源:table_elements.py
示例9: drawText
def drawText(self,txt,x,y,w,h,style={}):
margin = 0
self.canvas.saveState()
path = self.canvas.beginPath()
path.rect(x,y,w,h)
self.canvas.clipPath(path,stroke=1)
_s = styles['BodyText']
_s = ParagraphStyle({})
_s.fontSize = style['fontSize']*1.0
# _s.fontSize = style['fontSize']
_s.leading = style['fontSize']
print _s
print 'writing text',txt,x,y
while _s.fontSize > 1.0:
p = Paragraph(txt.strip(),_s)
aw,ah = p.wrapOn(self.canvas,w-margin*2,h-margin*2)
print aw,w-margin*2,ah,h-margin*2,_s.fontSize
break
if (aw > w-margin*2) or (ah > h-margin*2):
_s.fontSize = _s.fontSize - 1
_s.leading = _s.fontSize*1.9
else:
break
p.drawOn(self.canvas,x+margin,y+margin)
self.canvas.restoreState()
开发者ID:shivanan,项目名称:labelmaker,代码行数:25,代码来源:makelabels.py
示例10: _add_items
def _add_items(self):
""" add labels and color to the table """
#X starting position
X_pos = 0
if self.title != None:
X_pos = 1
Y_pos = 0
cpt = 0
for i in self.items_order:
#add the label
txt = c2c_helper.encode_entities(self.items[i].label)
ps = ParagraphStyle('color_legend')
ps.alignment = TA_CENTER
ps.fontName = self.DEFAULT_FONT
ps.fontSize = self.DEFAULT_FONT_SIZE
p = Paragraph(txt, ps)
self.table[0][cpt+X_pos] = p
#add the color
self.styles.append(('BACKGROUND', (cpt+X_pos,0), (cpt+X_pos,0), self.items[i].color))
cpt+=1
开发者ID:Yajo,项目名称:c2c-rd-addons,代码行数:25,代码来源:color_legend.py
示例11: build_tabla_contenido
def build_tabla_contenido(data):
"""
Construye la tabla del contenido del albaranSalida.
Los datos deben venir en listas. Cada línea de la tabla, una tupla o lista
con el código, descripción, cantidad, precio unitario (con dto. si lo
lleva e IVA) y número de pedido.
El precio y cantidad deben ser flotantes para poder calcular el subtotal.
"""
estilo_cabecera_tabla = ParagraphStyle("Cabecera tabla",
parent=estilos["Heading3"])
estilo_cabecera_tabla.fontName = "Times-Bold"
estilo_cabecera_tabla.alignment = enums.TA_CENTER
estilo_numeros_tabla = ParagraphStyle("Números tabla",
parent=estilos["Normal"])
estilo_numeros_tabla.alignment = enums.TA_RIGHT
datos = [(Paragraph(escribe("Código"), estilo_cabecera_tabla),
Paragraph(escribe("Descripción"), estilo_cabecera_tabla),
Paragraph("Cantidad", estilo_cabecera_tabla),
Paragraph("Precio/U", estilo_cabecera_tabla),
#Paragraph("Total c/IVA", estilo_cabecera_tabla),
# CWT: Prefiere la carta de portes sin IVA.
Paragraph("Total", estilo_cabecera_tabla),
Paragraph(escribe("Nº Pedido"), estilo_cabecera_tabla))
]
for d in data:
fila = (escribe(d[0]),
Paragraph(escribe(d[1]),estilos["Normal"]),
Paragraph(escribe(utils.float2str(d[2])),estilo_numeros_tabla),
Paragraph(escribe(utils.float2str(d[3])),estilo_numeros_tabla),
Paragraph(escribe(utils.float2str(d[2] * d[3])),
estilo_numeros_tabla),
escribe(d[4])
)
datos.append(fila)
tabla = Table(datos,
colWidths = (PAGE_WIDTH * 0.13,
PAGE_WIDTH * 0.35,
PAGE_WIDTH * 0.09,
PAGE_WIDTH * 0.09,
PAGE_WIDTH * 0.13,
PAGE_WIDTH * 0.11),
repeatRows = 1)
tabla.setStyle(TableStyle([
("BACKGROUND", (0, 0), (-1, 0), colors.lightgrey),
("LINEBEFORE", (0, 0), (-1, -1), 0.25, colors.black),
("LINEBELOW", (0, 0), (-1, 0), 1.0, colors.black),
("LINEBELOW", (0, "splitlast"), (-1, "splitlast"), 1.0, colors.black),
("BOX", (0, 0), (-1, -1), 1.0, colors.black),
("INNERGRID", (0, 0), (-1, -1), 0.25, colors.black),
("VALIGN", (0, 0), (-1, 0), "CENTER"),
("VALIGN", (0, 0), (0, -1), "TOP"),
("ALIGN", (0, 0), (-1, 0), "CENTER"),
("ALIGN", (-3, 1), (-1, -1), "RIGHT"),
#("ALIGN", (0, 1), (0, -1), "DECIMAL"), <- No puedo cambiar
# el pivotChar de "." a ",". No me vale.
("ALIGN", (-1, 1), (-1, -1), "CENTER"),
("ALIGN", (0, 1), (0, -1), "CENTER"),
#("RIGHTPADDING", (0, 1), (0, -1), 0.75 * cm),
]))
return tabla
开发者ID:pacoqueen,项目名称:bbinn,代码行数:60,代码来源:albaran_porte.py
示例12: _build_table
def _build_table(self):
""" return the list of list that represent the table structure """
line = []
if self.title != None:
txt = c2c_helper.encode_entities(self.title)
ps = ParagraphStyle('color_legend')
ps.alignment = TA_CENTER
ps.fontName = self.DEFAULT_FONT
ps.fontSize = self.DEFAULT_FONT_SIZE
p = Paragraph(txt, ps)
line.append([p])
for i in self.items_order:
line.append('')
self.table.append(line)
#global font for the whole graphic
self.styles.append(('FONT', (0,0), (-1,-1),self.DEFAULT_FONT, self.DEFAULT_FONT_SIZE))
# main frame arround the whole table
self.styles.append(('BOX', (0,0), (-1,-1), 1, "#000000"))
#in cells, text start in the top left corner
self.styles.append(('VALIGN', (0,0), (-1,-1), 'TOP'))
if self.title != None:
#background of the legend title
self.styles.append(('BACKGROUND', (0,0), (0,0), "#cccccc"))
开发者ID:Yajo,项目名称:c2c-rd-addons,代码行数:26,代码来源:color_legend.py
示例13: _add_Y_items
def _add_Y_items(self):
""" add Y items labels to the chart (Text and styles). Add also light grid for their lines """
X_pos = 0
Y_pos = 3
# draw the items titles with the right indentation
for i in self.data.items_order:
item = self.data.items[i]
ps = ParagraphStyle("indent")
ps.fontName = self.DEFAULT_FONT
ps.fontSize = self.DEFAULT_FONT_SIZE
ps.leftIndent = item.indent * self.INDENT_SPACE
p = Paragraph(self._encode_entities(item.label), ps)
self.table[Y_pos + item.Y_pos][X_pos] = p
# draw the inner grid for this lines
start_X = X_pos
end_X = -1
start_Y = Y_pos + item.Y_pos
end_Y = Y_pos + item.Y_pos + item.line_number
self.styles.append(("LINEABOVE", (start_X, end_Y), (end_X, end_Y), 0.2, "#bbbbbb"))
self.styles.append(("LINEAFTER", (start_X, start_Y), (end_X, end_Y), 0.2, "#bbbbbb"))
# line that separate the Y items and the datas
self.styles.append(("LINEAFTER", (X_pos, Y_pos - 2), (X_pos, -1), 1, colors.black))
开发者ID:dxyuniesky,项目名称:openerp-extra-6.1,代码行数:30,代码来源:timebox_chart.py
示例14: build_datos_cliente
def build_datos_cliente(datos_cliente = []):
"""
Devuelve una lista de Flowables con las líneas recibidas como texto.
"""
datos_c = []
estilo_datos_c = ParagraphStyle("Cliente",
parent = estilos["Heading3"])
estilo_datos_c.alignment = enums.TA_RIGHT
estilo_datos_c.spaceAfter = estilo_datos_c.spaceBefore = 2
if datos_cliente:
try:
datos_cliente[0] = "<strong>%s</strong>" % datos_cliente[0]
except TypeError:
datos_cliente = ["<strong>%s</strong>" % datos_cliente[0]] \
+ list(datos_cliente[1:])
tamanno_predeterminado = estilo_datos_c.fontSize
for linea in datos_cliente:
# ¡Esto debería hacerlo ReportLab, pero no sé por qué el markup
# sólo funciona con el estilo normal!
if "<strong>" in linea:
estilo_datos_c.fontSize += 4
else:
estilo_datos_c.fontSize = tamanno_predeterminado
p = Paragraph(escribe(linea), estilo_datos_c)
datos_c.append(p)
return datos_c
开发者ID:pacoqueen,项目名称:upy,代码行数:26,代码来源:presupuesto.py
示例15: _content
def _content(self):
# TODO: move styles somewhere else
# style for additional information box
ibs = ParagraphStyle('inputBoxStyle',styles['Message'])
ibs.fontName = 'Courier'
ibs.leftIndent = cm
ibs.spaceBefore = 0.2*cm
ibs.spaceAfter = 0.5*cm
# font style for letter subject
styles['Subject'].fontName = 'Helvetica-Bold'
content = [
Paragraph(_("auskunft_subject"), styles['Subject']),
Paragraph(_("auskunft_greeting"), styles['Greeting']),
Spacer(0,0.5*cm),
Paragraph(_("auskunft_question_text"), styles['Message']),
ListFlowable([
ListItem(Paragraph(_("auskunft_question_1"),styles['Message'])),
ListItem(Paragraph(_("auskunft_question_2"),styles['Message'])),
ListItem(Paragraph(_("auskunft_question_3"),styles['Message'])),
ListItem(Paragraph(_("auskunft_question_4"),styles['Message'])),
],
bulletType='bullet',
start='square'
),
Paragraph(_("auskunft_reference"), styles['Message']),
Paragraph(_("auskunft_par_10"), styles['Message']),
Paragraph(_("auskunft_par_4"), styles['Message']),
Paragraph(_("auskunft_par_12"), styles['Message']),
Paragraph(_("auskunft_standard_application"), styles['Message'])
]
# Registered Applications
if self.table_apps:
content += [
Paragraph(_("auskunft_registered_application_pre"),styles['Message']),
self.table_apps,
Paragraph(_("auskunft_registered_application_post"),styles['Message'])
]
# Additional Information
if self.add_info:
content += [
Paragraph(_("auskunft_additional_info_text"), styles['Message']),
Paragraph(self.add_info,ibs)
]
content += [
Paragraph(_("auskunft_method_identity"),styles['Message']),
Paragraph(_("auskunft_expected_response"),styles['Message']),
Spacer(0,0.5*cm),
Paragraph(_("auskunft_signature"),styles['Signature']),
Spacer(0,1.5*cm),
Paragraph(self.sender_name,styles['Signature'])
]
return content
开发者ID:n0g,项目名称:auskunftsbegehren_at,代码行数:59,代码来源:informationrequest.py
示例16: drawResume
def drawResume(self, canvas, doc):
# First table
style = ParagraphStyle(name='Style')
style.fontName = 'Helvetica-Bold'
style.fontSize = 10
style.alignment = TA_CENTER
data = [
[Paragraph('INFORME ACADÉMICO DEL %s' % self.time.upper(), style)],
['SEDE PRINCIPAL BACHILLERATO']
]
LIST_STYLE = TableStyle([
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
('BOX', (0,0), (-1,-1), 0.25, colors.black),
('TEXTCOLOR',(0,0),(-1,-1),colors.black),
('ALIGN', (0,0), (-1,-1), 'CENTER'),
('BACKGROUND', (0, 0), (-1, -1), colors.gray),
('FONTSIZE', (-1, -1), (-1, -1), 8),
('VALIGN',(0,0),(-1,-1),'MIDDLE')
])
table = Table(data, colWidths='*', rowHeights=0.2 * inch, style=LIST_STYLE)
w, h = table.wrap(doc.width, 0)
# Second table
data = [
[self.getResumeFirstColum(), self.getSecondColum(), self.getThirdColum(), self.getFourthColum()]
]
LIST_STYLE = TableStyle([
('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.25, colors.black),
('BACKGROUND', (0, 0), (-1, -1), colors.gray),
('TOPPADDING', (0, 0), (-1, -1), 0),
('BOTTOMPADDING', (0, 0), (-1, -1), 0),
('LEFTPADDING', (0, 0), (-1, -1), 0),
('RIGHTPADDING', (0, 0), (-1, -1), 0),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('VALIGN',(0, 0),(-1, -1),'TOP')
])
colWidths = [3*inch, 1.2*inch, 1.4*inch, '*']
table2 = Table(data, colWidths=colWidths, style=LIST_STYLE)
w, h = table2.wrap(doc.width, 0)
wrapper_style = TableStyle([
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('VALIGN',(0, 0),(-1, -1),'MIDDLE'),
('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
('BOX', (0, 0), (-1, -1), 0.25, colors.black),
('TOPPADDING', (0, 0), (-1, -1), 0),
('BOTTOMPADDING', (0, 0), (-1, -1), 0),
('LEFTPADDING', (0, 0), (-1, -1), 0),
('RIGHTPADDING', (0, 0), (-1, -1), 0),
])
data = [
[table],
[table2]
]
wrapper = Table(data, colWidths='*', style=wrapper_style)
w, h = wrapper.wrap(doc.width, 0)
wrapper.drawOn(canvas, doc.leftMargin, doc.height + 80)
开发者ID:dairdr,项目名称:notes,代码行数:59,代码来源:log.py
示例17: build_condicionado
def build_condicionado(condicionado):
a_derecha = ParagraphStyle("A derecha",
parent = estilos["Normal"])
a_derecha.alignment = enums.TA_LEFT
a_derecha.fontName = "Courier"
a_derecha.fontSize = 13
texto_condicionado = "Condiciones particulares: " + condicionado
return Paragraph(texto_condicionado, a_derecha)
开发者ID:pacoqueen,项目名称:ginn,代码行数:8,代码来源:presupuesto2.py
示例18: _ptoTestCase
def _ptoTestCase(self):
"""PTO stands for Please Turn Over and is a means for
specifying content to be inserted when stuff goes over a page.
This makes one long multi-page paragraph."""
# Build story.
story = []
def fbreak(story=story):
story.append(FrameBreak())
styleSheet = getSampleStyleSheet()
H1 = styleSheet['Heading1']
H1.pageBreakBefore = 0
H1.keepWithNext = 0
bt = styleSheet['BodyText']
pto = ParagraphStyle('pto',parent=bt)
pto.alignment = TA_RIGHT
pto.fontSize -= 1
def ColorParagraph(c,text,style):
return Paragraph('<para color="%s">%s</para>' % (c,text),style)
def ptoblob(blurb,content,trailer=None,header=None, story=story, H1=H1):
if type(content) not in (type([]),type(())): content = [content]
story.append(PTOContainer([Paragraph(blurb,H1)]+list(content),trailer,header))
t0 = [ColorParagraph('blue','Please turn over', pto )]
h0 = [ColorParagraph('blue','continued from previous page', pto )]
t1 = [ColorParagraph('red','Please turn over(inner)', pto )]
h1 = [ColorParagraph('red','continued from previous page(inner)', pto )]
ptoblob('First Try at a PTO',[Paragraph(text0,bt)],t0,h0)
fbreak()
c1 = Table([('alignment', 'align\012alignment'),
('bulletColor', 'bulletcolor\012bcolor'),
('bulletFontName', 'bfont\012bulletfontname'),
('bulletFontSize', 'bfontsize\012bulletfontsize'),
('bulletIndent', 'bindent\012bulletindent'),
('firstLineIndent', 'findent\012firstlineindent'),
('fontName', 'face\012fontname\012font'),
('fontSize', 'size\012fontsize'),
('leading', 'leading'),
('leftIndent', 'leftindent\012lindent'),
('rightIndent', 'rightindent\012rindent'),
('spaceAfter', 'spaceafter\012spacea'),
('spaceBefore', 'spacebefore\012spaceb'),
('textColor', 'fg\012textcolor\012color')],
style = [
('VALIGN',(0,0),(-1,-1),'TOP'),
('INNERGRID', (0,0), (-1,-1), 0.25, black),
('BOX', (0,0), (-1,-1), 0.25, black),
],
)
ptoblob('PTO with a table inside',c1,t0,h0)
fbreak()
ptoblob('A long PTO',[Paragraph(text0+' '+text1,bt)],t0,h0)
fbreak()
ptoblob('2 PTO (inner split)',[ColorParagraph('pink',text0,bt),PTOContainer([ColorParagraph(black,'Inner Starts',H1),ColorParagraph('yellow',text2,bt),ColorParagraph('black','Inner Ends',H1)],t1,h1),ColorParagraph('magenta',text1,bt)],t0,h0)
_showDoc('test_platypus_pto.pdf',story)
开发者ID:makinacorpus,项目名称:reportlab-ecomobile,代码行数:58,代码来源:test_platypus_pleaseturnover.py
示例19: get_title
def get_title(self):
"""return the title of the col"""
ps = ParagraphStyle('header')
ps.fontName = self.header_font
ps.fontSize = self.header_font_size
ps.alignment = self.get_align_code()
return Paragraph(self._title, ps)
开发者ID:3dfxmadscientist,项目名称:odoo-extra-1,代码行数:9,代码来源:table_elements.py
示例20: get_prequal_eval_lines_table
def get_prequal_eval_lines_table(prequal_eval_sobject):
prequal_eval_lines_search = Search('twog/prequal_evaluation_line')
prequal_eval_lines_search.add_filter('prequal_evaluation_code', prequal_eval_sobject.get_code())
prequal_eval_lines = prequal_eval_lines_search.get_sobjects()
# If no prequal eval lines exist for this report, return None so that the PDF won't display a table
if not prequal_eval_lines:
return None
style_sheet = getSampleStyleSheet()
style_sheet.font_size = 10
prequal_eval_lines_table_data = [['Timecode', 'F', 'Description', 'Code', 'Scale', 'Sector/Ch', 'In Source']]
lines_with_values = []
lines_without_values = []
for line in prequal_eval_lines:
if line.get_value('timecode'):
lines_with_values.append(line)
else:
lines_without_values.append(line)
prequal_eval_lines = sorted(lines_with_values, key=lambda x: x.get_value('timecode'))
prequal_eval_lines.extend(lines_without_values)
for line in prequal_eval_lines:
timecode = line.get('timecode')
field = line.get('field')
prequal_line_description = line.get('prequal_line_description')
type_code = line.get('type_code')
scale = line.get('scale')
sector_or_channel = line.get('sector_or_channel')
in_source = line.get('in_source')
if any([timecode, field, prequal_line_description, type_code, scale, sector_or_channel, in_source]):
description_paragraph_style = ParagraphStyle(prequal_line_description)
description_paragraph_style.fontSize = 8
description_paragraph = Paragraph(line.get('description'), description_paragraph_style)
line_data = [timecode, field, description_paragraph, type_code, scale, sector_or_channel, in_source]
prequal_eval_lines_table_data.append(line_data)
prequal_eval_lines_table = Table(prequal_eval_lines_table_data, hAlign='LEFT', spaceBefore=5, spaceAfter=5,
colWidths=[(.7 * inch), (.19 * inch), (inch * 2.6), (.4 * inch), (.82 * inch),
(.19 * inch), (.75 * inch), (.3 * inch), (.55 * inch),
(.55 * inch)])
prequal_eval_lines_table.setStyle([('BOX', (0, 0), (-1, -1), 0.2, colors.black),
('INNERGRID', (0, 0), (-1, -1), 0.2, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('LEFTPADDING', (0, 0), (-1, -1), 1),
('RIGHTPADDING', (0, 0), (-1, -1), 1)])
return prequal_eval_lines_table
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:56,代码来源:export_prequal_eval_command.py
注:本文中的reportlab.lib.styles.ParagraphStyle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论