当前位置: 首页>>代码示例>>Python>>正文


Python ParagraphStyle.alignment方法代码示例

本文整理汇总了Python中reportlab.lib.styles.ParagraphStyle.alignment方法的典型用法代码示例。如果您正苦于以下问题:Python ParagraphStyle.alignment方法的具体用法?Python ParagraphStyle.alignment怎么用?Python ParagraphStyle.alignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.lib.styles.ParagraphStyle的用法示例。


在下文中一共展示了ParagraphStyle.alignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _prepare_styles

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
def _prepare_styles():
	styles = {}
	stylesheet = getSampleStyleSheet()

	style = ParagraphStyle("Normal", stylesheet['Normal'])
	style.alignment = TA_LEFT
	style.fontSize = 6
	style.fontName = 'FreeSans'
	style.leading = 8
	styles['Normal'] = style

	style = ParagraphStyle("ItemTitle", stylesheet['Heading1'])
	style.alignment = TA_LEFT
	style.fontSize = 8
	style.fontName = 'FreeSansBold'
	style.fontSize = 10
	styles['ItemTitle'] = style

	style = ParagraphStyle("Heading", stylesheet['Heading2'])
	style.alignment = TA_CENTER
	style.fontSize = 6
	style.fontName = 'FreeSansBold'
	styles['Heading'] = style

	style = ParagraphStyle("FieldHead", stylesheet['Heading2'])
	style.alignment = TA_LEFT
	style.fontSize = 6
	style.fontName = 'FreeSansBold'
	style.leading = 8
	styles['FieldHead'] = style

	return styles
开发者ID:KarolBedkowski,项目名称:alldb,代码行数:34,代码来源:pdf_support.py

示例2: build_tabla_contenido

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
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,代码行数:62,代码来源:albaran_porte.py

示例3: _add_secondary_scale

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
    def _add_secondary_scale(self):
        """ add the secondary scale to the table (text + styles) """

        Y_pos = 1
        X_pos = 1

        # write the label
        ps = ParagraphStyle("secondary_scale_label")
        ps.alignment = TA_RIGHT
        ps.fontName = self.DEFAULT_FONT
        ps.fontSize = self.DEFAULT_FONT_SIZE

        title = Paragraph(self.data.scale.secondary_label, ps)
        self.table[Y_pos][0] = title

        ps = ParagraphStyle("secondary_scale")
        ps.alignment = TA_CENTER
        ps.fontName = self.DEFAULT_FONT
        ps.fontSize = self.DEFAULT_FONT_SIZE

        # the secondary scale is not define the same way as the primary scale.
        # it's defined by groups of same label. (start_pos, start_end, item)
        # see ScaleData._group_scale() for details
        for group in self.data.scale.secondary_scale_groups:
            pos_start, pos_end, item = group
            p = Paragraph(item, ps)

            # draw the label in the middle of the similar cells
            self.table[Y_pos][int((pos_start + pos_end) / 2) + 1] = p

            # draw light border arrounds items
            self.styles.append(("BOX", (pos_start + X_pos, Y_pos), (pos_end + X_pos, Y_pos), 0.2, "#bbbbbb"))
开发者ID:dxyuniesky,项目名称:openerp-extra-6.1,代码行数:34,代码来源:timebox_chart.py

示例4: drawHeader

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
	def drawHeader(self, canvas, doc):
		logo_path = os.path.join(settings.STATIC_ROOT, 'assets/escudo.jpg')
		logo = Image(logo_path, width=0.7*inch, height=0.7*inch)

		title_style = ParagraphStyle(name='Title')
		title_style.fontName = 'Helvetica-Bold'
		title_style.fontSize = 11
		title_style.alignment = TA_CENTER
		
		subtitle_style = ParagraphStyle(name='Subtitle')
		subtitle_style.fontName = 'Helvetica'
		subtitle_style.fontSize = 8
		subtitle_style.alignment = TA_CENTER

		subtitle2_style = ParagraphStyle(name='Subtitle2')
		subtitle2_style.fontName = 'Helvetica'
		subtitle2_style.fontSize = 8
		subtitle2_style.alignment = TA_CENTER

		subtitle3_style = ParagraphStyle(name='Subtitle3')
		subtitle3_style.fontName = 'Helvetica'
		subtitle3_style.fontSize = 8
		subtitle3_style.alignment = TA_CENTER

		subtitle4_style = ParagraphStyle(name='Subtitle4')
		subtitle4_style.fontName = 'Helvetica'
		subtitle4_style.fontSize = 8
		subtitle4_style.alignment = TA_CENTER

		data = [
			[logo, [
					Paragraph('INSTITUCION EDUCATIVA AUGUSTO ESPINOSA VALDERRAMA', title_style),
					Paragraph('Reconocido oficialmente por la Secretaría de Educación Municipal de Montería mediante resolución 0751 de junio 12 de 2009', subtitle_style),
					Paragraph('Corregimiento Santa Clara – Municipio de Montería', subtitle2_style),
					Paragraph('Tel. 7905949 Código DANE 223001005404', subtitle3_style),
					Paragraph('Nit 812007342', subtitle4_style)
				]
			]
		]
		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'),
			('FONTSIZE', (-1, -1), (-1, -1), 8),
			('VALIGN',(0,0),(-1,-1),'MIDDLE'),
			('TOPPADDING', (0, 0), (-1, -1), 0),
			('BOTTOMPADDING', (0, 0), (-1, -1), 0),
			('LEFTPADDING', (0, 0), (-1, -1), 0),
			('RIGHTPADDING', (0, 0), (-1, -1), 0),
		])
		colWidths = [0.7*inch, '*']
		table = Table(data, colWidths=colWidths, style=LIST_STYLE)
		w, h = table.wrap(doc.width, 0)
		table.drawOn(canvas, doc.leftMargin + 5, doc.height + 150)
开发者ID:dairdr,项目名称:notes,代码行数:57,代码来源:log.py

示例5: main_data

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
def main_data(tutor, academic_year, session_exam, styles, learning_unit_year, pgm, content):
    content.append(SMALL_INTER_LINE)
    p_structure = ParagraphStyle('entete_structure')
    p_structure.alignment = TA_LEFT
    p_structure.fontSize = 10

    p = ParagraphStyle('entete_droite')
    p.alignment = TA_RIGHT
    p.fontSize = 10

    content.append(Paragraph('%s : %s' % (_('Academic year'), str(academic_year)), p))
    content.append(Paragraph('Session : %d' % session_exam.number_session, p))
    content.append(BIG_INTER_LINE)

    if pgm.structure is not None:
        content.append(Paragraph('%s' % pgm.structure, p_structure))
        content.append(SMALL_INTER_LINE)

    content.append(Paragraph("<strong>%s : %s</strong>" % (learning_unit_year.acronym,learning_unit_year.title), styles["Normal"]) )
    content.append(SMALL_INTER_LINE)

    tutor = None
    if tutor is None:
        p_tutor = Paragraph(''' ''' , styles["Normal"])
    else:
        p_tutor = Paragraph('''<b>%s %s</b>''' % (tutor.person.last_name, tutor.person.first_name), styles["Normal"])

    data_tutor= [[p_tutor],
       [''],
       [''],
       ['']]
    table_tutor=Table(data_tutor)
    p_pgm = Paragraph('''<b>%s : %s</b>''' % (_('Program'),pgm.acronym), styles["Normal"])
    data_pgm= [[p_pgm],
               [_('Deliberation date') + ' : '],
               [_('Chair of the exam board') + ' : '],
               [_('Exam board secretary') + ' : '],
              ]
    table_pgm=Table(data_pgm)
    table_pgm.setStyle(TableStyle([
    ('LEFTPADDING',(0,0),(-1,-1), 0),
                         ('RIGHTPADDING',(0,0),(-1,-1), 0),
                       ('VALIGN',(0,0), (-1,-1), 'TOP')
                       ]))
    dataTT = [[table_pgm,table_tutor]]

    tt=Table(dataTT, colWidths='*')
    tt.setStyle(TableStyle([
        ('LEFTPADDING',(0,0),(-1,-1), 0),
                             ('RIGHTPADDING',(0,0),(-1,-1), 0),
                       ('VALIGN',(0,0), (-1,-1), 'TOP')
                       ]))
    content.append(tt)
    content.append(Spacer(1, 12))
开发者ID:fthuin,项目名称:osis,代码行数:56,代码来源:pdf_utils.py

示例6: tabla_detalle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
 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,代码行数:31,代码来源:reports.py

示例7: build_tabla_totales

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
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,代码行数:36,代码来源:presupuesto.py

示例8: cuadritos_en_ruta

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
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,代码行数:35,代码来源:albaran_porte.py

示例9: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
 def toParagraphStyle(self, first, full=False):
     style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext)
     style.fontName = first.fontName
     style.fontSize = first.fontSize
     style.leading = max(first.leading, first.fontSize * 1.25)
     style.backColor = first.backColor
     style.spaceBefore = first.spaceBefore
     style.spaceAfter = first.spaceAfter
     style.leftIndent = first.leftIndent
     style.rightIndent = first.rightIndent
     style.firstLineIndent = first.firstLineIndent
     style.textColor = first.textColor
     style.alignment = first.alignment
     style.bulletFontName = first.bulletFontName or first.fontName 
     style.bulletFontSize = first.fontSize
     style.bulletIndent = first.bulletIndent
     # Border handling for Paragraph
     style.borderWidth = 0
     if getBorderStyle(first.borderTopStyle):
         style.borderWidth = max(first.borderLeftWidth, first.borderRightWidth, first.borderTopWidth, first.borderBottomWidth)
         style.borderPadding = first.borderPadding # + first.borderWidth
         style.borderColor = first.borderTopColor
         # If no border color is given, the text color is used (XXX Tables!)
         if (style.borderColor is None) and style.borderWidth:
             style.borderColor = first.textColor      
     if full:
         style.fontName = tt2ps(first.fontName, first.bold, first.italic)
     return style       
开发者ID:nbio,项目名称:frnda,代码行数:30,代码来源:pisa_context.py

示例10: build_tabla_totales

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
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,代码行数:33,代码来源:albaran_multipag.py

示例11: build_encabezado

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
def build_encabezado(datos_empresa = []):
    """
    Devuelve una lista de "Flowables" de reportlab con los datos de la empresa. 
    Los datos de la empresa se reciben como una lista de textos.
    """
    cabecera = []
    estilo_encabezado = ParagraphStyle("Encabezado", 
                                       parent = estilos["Heading2"])
    estilo_encabezado.rightIndent = PAGE_WIDTH * 0.25
    estilo_encabezado.alignment = enums.TA_JUSTIFY
    estilo_encabezado.spaceAfter = 0
    estilo_encabezado.spaceBefore = 4
    datos_empresa[0] = datos_empresa[0].upper()
    for linea in datos_empresa:
        if linea is datos_empresa[0]:
            estilo_encabezado.fontSize += 3
        p = Paragraph(escribe(linea), estilo_encabezado) 
        cabecera.append(p)
        estilo_encabezado.fontSize -= 1
        if estilo_encabezado.spaceAfter > -4:
            estilo_encabezado.spaceAfter -= 1
        estilo_encabezado.spaceBefore = estilo_encabezado.spaceAfter
        if linea is datos_empresa[0]:
            estilo_encabezado.fontSize -= 3
    return cabecera
开发者ID:pacoqueen,项目名称:upy,代码行数:27,代码来源:presupuesto2.py

示例12: get_content

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
    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,代码行数:29,代码来源:table_elements.py

示例13: test3

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
 def test3(self):
     '''compare CJK splitting in some edge cases'''
     from reportlab.pdfgen.canvas import Canvas
     from reportlab.platypus.paragraph import Paragraph
     from reportlab.lib.styles import ParagraphStyle
     from reportlab.pdfbase import pdfmetrics
     from reportlab.lib.enums import TA_LEFT
     sty = ParagraphStyle('A')
     sty.fontSize = 15
     sty.leading = sty.fontSize*1.2
     sty.fontName = 'Courier'
     sty.alignment = TA_LEFT
     sty.wordWrap = 'CJK'
     p0=Paragraph('ABCDEFGHIJKL]N',sty)
     p1=Paragraph('AB<font color="red">C</font>DEFGHIJKL]N',sty)
     canv = Canvas('test_platypus_paragraph_cjk3.pdf')
     ix = len(canv._code)
     aW = pdfmetrics.stringWidth('ABCD','Courier',15)
     w,h=p0.wrap(aW,1000000)
     y = canv._pagesize[1]-72-h
     p0.drawOn(canv,72,y)
     w,h=p1.wrap(aW,1000000)
     y -= h+10
     p1.drawOn(canv,72,y)
     w,h=p0.wrap(aW*0.25-2,1000000)
     y -= h+10
     p0.drawOn(canv,72,y)
     w,h=p1.wrap(aW/4.-2,1000000)
     y -= h+10
     p1.drawOn(canv,72,y)
     assert canv._code[ix:]==['q', '1 0 0 1 72 697.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 57 Tm /F2 15 Tf 18 TL (ABCD) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 615.8898 cm', 'q', 'BT 1 0 0 1 0 57 Tm 18 TL /F2 15 Tf 0 0 0 rg (AB) Tj 1 0 0 rg (C) Tj 0 0 0 rg (D) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 353.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 237 Tm /F2 15 Tf 18 TL (A) Tj T* (B) Tj T* (C) Tj T* (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 91.88976 cm', 'q', 'BT 1 0 0 1 0 237 Tm 18 TL /F2 15 Tf 0 0 0 rg (A) Tj T* (B) Tj T* 1 0 0 rg (C) Tj T* 0 0 0 rg (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q']
     canv.showPage()
     canv.save()
开发者ID:Jbaumotte,项目名称:web2py,代码行数:35,代码来源:test_platypus_paragraphs.py

示例14: _add_items

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
    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,代码行数:27,代码来源:color_legend.py

示例15: _build_table

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import alignment [as 别名]
 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,代码行数:28,代码来源:color_legend.py


注:本文中的reportlab.lib.styles.ParagraphStyle.alignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。