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


Python ParagraphStyle.firstLineIndent方法代码示例

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


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

示例1: getBody

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

示例2: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [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

示例3: testRml

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

示例4: addPara

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
    def addPara(self, force=False):

        # Cleanup the trail
        for frag in reversed(self.fragList):
            frag.text = frag.text.rstrip()
            if frag.text:
                break

        if force or (self.text.strip() and self.fragList):

            # Strip trailing whitespaces
            # for f in self.fragList:
            #    f.text = f.text.lstrip()
            #    if f.text:
            #        break
            # self.fragList[-1].lineBreak = self.fragList[-1].text.rstrip()

            # Update paragraph style by style of first fragment
            first = self.fragBlock
            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.alignment = first.alignment

            style.bulletFontName = first.fontName
            style.bulletFontSize = first.fontSize
            style.bulletIndent = first.bulletIndent

            style.borderWidth = max(
                first.borderLeftWidth, first.borderRightWidth, first.borderTopWidth, first.borderBottomWidth
            )
            style.borderPadding = first.borderPadding  # + first.borderWidth
            style.borderColor = first.borderTopColor
            # borderRadius: None,

            # print repr(self.text.strip()), style.leading, "".join([repr(x.text) for x in self.fragList])

            # print first.leftIndent, first.listStyleType,repr(self.text)

            # Add paragraph to story
            para = PmlParagraph(
                self.text, style, frags=self.fragAnchor + self.fragList, bulletText=copy.copy(first.bulletText)
            )
            para.outline = frag.outline
            para.outlineLevel = frag.outlineLevel
            para.outlineOpen = frag.outlineOpen
            self.addStory(para)

            self.fragAnchor = []
            first.bulletText = None

        self.clearFrag()
开发者ID:ahmedsalman,项目名称:django-project,代码行数:61,代码来源:pisa_context.py

示例5: build_todavia_mas_texto

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
def build_todavia_mas_texto():
    """
    Construye más texto genérico de la carta de portes.
    """
    estilo_texto = ParagraphStyle("Texto", parent=estilos["Normal"])
    estilo_texto.alignment = enums.TA_JUSTIFY
    estilo_texto.firstLineIndent = 24
    estilo_texto.fontSize = 12
    texto = """
    Transporte que no excede de los límites establecidos en el capítulo 1.1.3.6.
    """
    estilo_texto2 = ParagraphStyle("Texto2", parent=estilo_texto)
    estilo_texto2.alignment = enums.TA_CENTER
    estilo_texto2.firstLineIndent = 0
    # estilo_texto2.fontSize = 8
    p = Paragraph(escribe(texto), estilo_texto2)
    return p
开发者ID:pacoqueen,项目名称:upy,代码行数:19,代码来源:albaran_porte.py

示例6: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
    def toParagraphStyle(self, first):
        style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext)
        style.fontName = first.fontName
        style.fontSize = first.fontSize
        style.letterSpacing = first.letterSpacing
        style.leading = max(first.leading + first.leadingSpace, 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
        style.wordWrap = first.wordWrap

        # Border handling for Paragraph

        # Transfer the styles for each side of the border, *not* the whole
        # border values that reportlab supports. We'll draw them ourselves in
        # PmlParagraph.
        style.borderTopStyle = first.borderTopStyle
        style.borderTopWidth = first.borderTopWidth
        style.borderTopColor = first.borderTopColor
        style.borderBottomStyle = first.borderBottomStyle
        style.borderBottomWidth = first.borderBottomWidth
        style.borderBottomColor = first.borderBottomColor
        style.borderLeftStyle = first.borderLeftStyle
        style.borderLeftWidth = first.borderLeftWidth
        style.borderLeftColor = first.borderLeftColor
        style.borderRightStyle = first.borderRightStyle
        style.borderRightWidth = first.borderRightWidth
        style.borderRightColor = first.borderRightColor

        # If no border color is given, the text color is used (XXX Tables!)
        if (style.borderTopColor is None) and style.borderTopWidth:
            style.borderTopColor = first.textColor
        if (style.borderBottomColor is None) and style.borderBottomWidth:
            style.borderBottomColor = first.textColor
        if (style.borderLeftColor is None) and style.borderLeftWidth:
            style.borderLeftColor = first.textColor
        if (style.borderRightColor is None) and style.borderRightWidth:
            style.borderRightColor = first.textColor

        style.borderPadding = first.borderPadding

        style.paddingTop = first.paddingTop
        style.paddingBottom = first.paddingBottom
        style.paddingLeft = first.paddingLeft
        style.paddingRight = first.paddingRight
        style.fontName = tt2ps(first.fontName, first.bold, first.italic)

        return style
开发者ID:AntycSolutions,项目名称:xhtml2pdf,代码行数:58,代码来源:context.py

示例7: build_texto_riesgo

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
def build_texto_riesgo(texto_riesgo):
    # a_derecha = ParagraphStyle("A derecha", 
    #                             parent = estilos["Normal"])
    # a_derecha.alignment = enums.TA_RIGHT
    # a_derecha.fontName = "Courier"
    # a_derecha.fontSize = 8
    estilo_texto = ParagraphStyle("Texto", 
                                  parent = estilos["Normal"])
    estilo_texto.alignment = enums.TA_JUSTIFY
    estilo_texto.firstLineIndent = 24
    return Paragraph(texto_riesgo, estilo_texto) # , a_derecha)     # CWT
开发者ID:pacoqueen,项目名称:ginn,代码行数:13,代码来源:presupuesto2.py

示例8: build_texto

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
def build_texto(titular):
    """
    Construye el texto genérico de la carta de portes.
    """
    estilo_texto = ParagraphStyle("Texto", parent=estilos["Normal"])
    estilo_texto.alignment = enums.TA_JUSTIFY
    estilo_texto.firstLineIndent = 24
    estilo_texto.fontSize = 8
    estilo_texto.leading = 9
    texto = (
        """%s hace constar que esta materia se admite al transporte por carretera de acuerdo con las disposiciones del proyecto europeo del transporte de mercancías peligrosas por carretera (ADR) y del reglamento nacional para el transporte de mercancías peligrosas por carretera (TPC).
            El abajo firmante (conductor y/o transportista) declara:
            1.- Que el vehículo cargado cumple las condiciones que establece el reglamento nacional para el transporte de mercancías peligrosas por carretera (ADR/TPC).
            2.- Que se ha efectuado correctamente la carga y/o estiba de la mercancía de acuerdo con el citado reglamento.
            3.- Que ha recibido la hoja de instrucciones escritas respecto a:
                &nbsp;&nbsp;&nbsp;&nbsp;- Naturaleza del peligro de la mercancía a transportar.
                &nbsp;&nbsp;&nbsp;- Medidas de seguridad y otras a tener en cuenta en caso de accidentes, incendio, derrame y otros, todas las cuales ha leído y conoce.
            4.- Conocer las disposiciones generales y especiales sobre vehículos, carga, descarga y manipulación de la mercancía, circulación y otras que se establecen para este transporte en el citado reglamento.
            5.- El transportista asume la responsabilidad por cualquier accidente ocurrido durante el transporte, sea cual fuere el lugar del siniestro una vez que la mercancía le haya sido entregada.
            """
        % titular
    )
    p = [Paragraph(escribe(t), estilo_texto) for t in texto.split("\n")]
    estilo_texto2 = ParagraphStyle("Texto2", parent=estilo_texto)
    estilo_texto2.alignment = enums.TA_CENTER
    estilo_texto2.firstLineIndent = 0
    # estilo_texto2.fontSize = 8
    texto2 = """<b><font size=12>UN 1263, PINTURAS O PRODUCTOS PARA LA PINTURA, 3, II, ADR</b></font>"""
    texto3 = """

GRG    DEPÓSITO 600L    BIDÓN 200L    BIDÓN 100L    ENVASES METÁLICOS    GARRAFAS 60L    GARRAFAS 25L

LEY 11/79 (ART.18.1 DEL REGLAMENTO) el responsable de la entrega del envase usado será el poseedor final

Fdo. Conductor  Matrícula:         Fdo. El expedidor        Fdo. El cliente        Fdo. Central de carga
            """
    p.append(XPreformatted(escribe(texto2), estilo_texto2))
    p.append(XPreformatted(escribe(texto3), estilo_texto2))
    return KeepTogether(p)
开发者ID:pacoqueen,项目名称:upy,代码行数:41,代码来源:albaran_porte.py

示例9: build_mas_texto

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
def build_mas_texto(titular):
    """
    Construye más texto genérico de la carta de portes.
    """
    estilo_texto = ParagraphStyle("Texto", parent=estilos["Normal"])
    estilo_texto.alignment = enums.TA_JUSTIFY
    estilo_texto.firstLineIndent = 24
    estilo_texto.fontSize = 8
    texto = (
        """%s hace constar que esta materia se admite al transporte por carretera, de acuerdo con las disposiciones del proyecto europeo del transporte de mercancías peligrosas por carretera (ADR) y del reglamento nacional para el transporte de mercancías peligrosas por carretera (TPC).
            El abajo firmante (conductor y/o transportista) declara:
            6.- Que el vehículo cargado cumple las condiciones que establece el Reglamento Nacional para el Transporte de Mercancías Peligrosas por carretera (ADR/TPC).
            7.- Que se ha efectuado correctamente la carga y/o estiba de la mercancía de acuerdo con el citado Reglamento.
            8.- Que ha recibido la hoja de instrucciones escrita respecto a:
                &nbsp;&nbsp;&nbsp;&nbsp;- Naturaleza del peligro de la mercancía a transportar.
                &nbsp;&nbsp;&nbsp;- Medidas de seguridad y otras a tener en cuenta en caso de accidentes, incendio, derrame y otros, todas las cuales ha leído y conoce.
            9.- Conocer las disposiciones generales y especiales sobre vehículos, carga, descarga y manipulación de la mercancía, circulación y otras que se establecen para este transporte en el citado Reglamento.
            10.- El transportista asume la responsabilidad por cualquier accidente ocurrido durante el transporte, sea cual fuere el lugar del siniestro una vez que la mercancía le haya sido entregada.
            """
        % titular
    )
    p = [Paragraph(escribe(t), estilo_texto) for t in texto.split("\n")]
    estilo_texto2 = ParagraphStyle("Texto2", parent=estilo_texto)
    estilo_texto2.alignment = enums.TA_CENTER
    estilo_texto2.firstLineIndent = 0
    # estilo_texto2.fontSize = 8
    texto2 = """<b><font size=12>UN 1263, PINTURAS O PRODUCTOS PARA LA PINTURA, 3, II, ADR</b></font>

GRG    DEPÓSITO 600L    BIDÓN 200L    BIDÓN 100L    ENVASES METÁLICOS    GARRAFAS 60L    GARRAFAS 25L

LEY 11/79 (ART.18.1 DEL REGLAMENTO) EL RESPONSABLE DE LA ENTREGA DEL ENVASE USADO SERÁ EL POSEEDOR FINAL

FDO. CONDUCTOR  MATRÍCULA:         FDO. EL EXPEDIDOR        FDO. EL CLIENTE
    """
    p.append(XPreformatted(escribe(texto2), estilo_texto2))
    p.append(XPreformatted("    FECHA:", estilo_texto))
    return p
开发者ID:pacoqueen,项目名称:upy,代码行数:39,代码来源:albaran_porte.py

示例10: build_texto

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
def build_texto(texto):
    """
    El texto que encabeza la tabla.
    """
    res = None
    if texto:
        estilo_texto = ParagraphStyle("Texto", 
                                      parent = estilos["Normal"])
        estilo_texto.alignment = enums.TA_JUSTIFY
        estilo_texto.firstLineIndent = 24
        _res = [Paragraph(escribe(i), estilo_texto) for i in texto.split("\n")]
        espacio = Spacer(1, 0.25*cm)
        res = [_res[0]]
        for i in _res[1:]:
            res.extend([espacio, i])
    return res
开发者ID:pacoqueen,项目名称:upy,代码行数:18,代码来源:presupuesto.py

示例11: run

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
    def run():
        objects_to_draw = []
        from reportlab.lib.styles import ParagraphStyle
        #from paragraph import Paragraph
        from doctemplate import SimpleDocTemplate

        #need a style
        normal = ParagraphStyle('normal')
        normal.firstLineIndent = 18
        normal.spaceBefore = 6
        from reportlab.lib.randomtext import randomText
        import random
        for i in range(15):
            height = 0.5 + (2*random.random())
            box = XBox(6 * inch, height * inch, 'Box Number %d' % i)
            objects_to_draw.append(box)
            para = Paragraph(randomText(), normal)
            objects_to_draw.append(para)

        SimpleDocTemplate('doctemplate.pdf').build(objects_to_draw,
            onFirstPage=myFirstPage,onLaterPages=myLaterPages)
开发者ID:eaudeweb,项目名称:naaya,代码行数:23,代码来源:doctemplate.py

示例12: build_texto

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
def build_texto(datos_de_la_empresa):
    """
    Construye el texto genérico de la carta de portes.
    """
    estilo_texto = ParagraphStyle("Texto", 
                                  parent = estilos["Normal"])
    estilo_texto.alignment = enums.TA_JUSTIFY
    estilo_texto.firstLineIndent = 24
    estilo_texto.fontSize = 8
    estilo_texto.leading = 9
    texto = """Norma UNE EN 13249:2001 y UNE EN 13249:2001/A1:2005, Norma UNE EN 13250:2001 y UNE EN 13250:2001/A1:2005, Norma UNE EN 13251:2001 y UNE EN 13251:2001/A1:2005, Norma UNE EN 13252:2001, UNE EN 13252/Erratum:2002 y UNE EN 13252:2001/A1:2005, Norma UNE EN 13253:2001 y UNE EN 13253:2001/A1:2005, Norma UNE EN 13254:2001, UNE EN 13254/AC:2003 y UNE EN 13254:2001/A1:2005, Norma UNE EN 13255:2001, UNE EN 13255/AC:2003 y UNE EN 13255:2001/A1:2005, Norma UNE EN 13256:2001, UNE EN 13256/AC:2003 y UNE EN 13256:2001/A1:2005,Norma UNE EN 13257:2001, UNE EN 13257/AC:2003 y UNE EN 13257:2001/A1:2005, Norma UNE EN 13265:2001, UNE EN 13265/AC:2003 y UNE EN 13265:2001/A1:2005.

Geotextil no tejido formado por fibras vírgenes <b>100% de polipropileno</b>, unidas mecánicamente por un proceso de agujado con posterior termofijado. Campo de aplicación: en carreteras y otras zonas de tráfico, construcciones ferroviarias, movimientos de tierras, cimentaciones y estructuras de contención, sistemas de drenaje, control de la erosión (protección costera y revestimiento de taludes), construcción de embalses y presas, construcción de canales, construcción de túneles y estructuras subterráneas, vertederos de residuos sólidos, proyectos de contenedores de residuos sólidos.
    """ 
    p = [Paragraph(escribe(t), estilo_texto) for t in texto.split("\n") if t]
    p.insert(1, Spacer(1, 0.25*cm))
    logo_ce = Image(os.path.join("..", "imagenes", "CE.png"))
    logo_ce.drawHeight = 0.75*cm
    logo_ce.drawWidth = 1*cm
    p.insert(0, logo_ce)
    p.insert(1, Spacer(1, 0.15*cm))
    estilo_numero_marcado = ParagraphStyle("NumeroMarcado", 
                                           parent = estilos["Normal"])
    estilo_numero_marcado.alignment = enums.TA_CENTER
    estilo_numero_marcado.fontSize = 7
    estilo_numero_marcado.fontName = "Courier"
    p.insert(2, Paragraph(escribe("1035-CPD-ES033858"), estilo_numero_marcado))
    estilo_nombre_empresa = ParagraphStyle("NombreEmpresa", 
                                           parent = estilos["Normal"])
    estilo_nombre_empresa.alignment = enums.TA_CENTER
    estilo_nombre_empresa.fontSize = 7
    estilo_nombre_empresa.fontName = "Courier-Bold"
    nombre_empresa = datos_de_la_empresa.nombre
    p.insert(3, Paragraph(escribe(nombre_empresa.upper()), 
                          estilo_nombre_empresa))
    p.insert(4, Spacer(1, 0.15*cm))
    return KeepTogether(p)
开发者ID:pacoqueen,项目名称:ginn,代码行数:39,代码来源:informe_certificado_calidad.py

示例13: getExamples

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [as 别名]
def getExamples():
    """Returns all the example flowable objects"""
    styleSheet = getSampleStyleSheet()

    story = []

    #make a style with indents and spacing
    sty = ParagraphStyle('obvious', None)
    sty.leftIndent = 18
    sty.rightIndent = 18
    sty.firstLineIndent = 18
    sty.spaceBefore = 6
    sty.spaceAfter = 6
    story.append(Paragraph("""Now for some demo stuff - we need some on this page,
        even before we explain the concepts fully""", styleSheet['BodyText']))
    p = Paragraph("""
        Platypus is all about fitting objects into frames on the page.  You
        are looking at a fairly simple Platypus paragraph in Debug mode.
        It has some gridlines drawn around it to show the left and right indents,
        and the space before and after, all of which are attributes set in
        the style sheet.  To be specific, this paragraph has left and
        right indents of 18 points, a first line indent of 36 points,
        and 6 points of space before and after itself.  A paragraph
        object fills the width of the enclosing frame, as you would expect.""", sty)

    p.debug = 1   #show me the borders
    story.append(p)

    story.append(Paragraph("""Same but with justification 1.5 extra leading and green text.""", styleSheet['BodyText']))
    p = Paragraph("""
        <para align=justify leading=+1.5 fg=green><font color=red>Platypus</font> is all about fitting objects into frames on the page.  You
        are looking at a fairly simple Platypus paragraph in Debug mode.
        It has some gridlines drawn around it to show the left and right indents,
        and the space before and after, all of which are attributes set in
        the style sheet.  To be specific, this paragraph has left and
        right indents of 18 points, a first line indent of 36 points,
        and 6 points of space before and after itself.  A paragraph
        object fills the width of the enclosing frame, as you would expect.</para>""", sty)

    p.debug = 1   #show me the borders
    story.append(p)

    story.append(platypus.XBox(4*inch, 0.75*inch,
            'This is a box with a fixed size'))

    story.append(Paragraph("""
        All of this is being drawn within a text frame which was defined
        on the page.  This frame is in 'debug' mode so you can see the border,
        and also see the margins which it reserves.  A frame does not have
        to have margins, but they have been set to 6 points each to create
        a little space around the contents.
        """, styleSheet['BodyText']))

    story.append(FrameBreak())

    #######################################################################
    #     Examples Page 2
    #######################################################################

    story.append(Paragraph("""
        Here's the base class for Flowable...
        """, styleSheet['Italic']))

    code = '''class Flowable:
        """Abstract base class for things to be drawn.  Key concepts:
    1. It knows its size
    2. It draws in its own coordinate system (this requires the
        base API to provide a translate() function.
        """
    def __init__(self):
        self.width = 0
        self.height = 0
        self.wrapped = 0

    def drawOn(self, canvas, x, y):
        "Tell it to draw itself on the canvas.  Do not override"
        self.canv = canvas
        self.canv.saveState()
        self.canv.translate(x, y)

        self.draw()   #this is the bit you overload

        self.canv.restoreState()
        del self.canv

    def wrap(self, availWidth, availHeight):
        """This will be called by the enclosing frame before objects
        are asked their size, drawn or whatever.  It returns the
        size actually used."""
        return (self.width, self.height)
    '''

    story.append(Preformatted(code, styleSheet['Code'], dedent=4))
    story.append(FrameBreak())
    #######################################################################
    #     Examples Page 3
    #######################################################################

    story.append(Paragraph(
                "Here are some examples of the remaining objects above.",
#.........这里部分代码省略.........
开发者ID:roytest001,项目名称:PythonCode,代码行数:103,代码来源:test_platypus_general.py

示例14: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import firstLineIndent [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

        # Transfer the styles for each side of the border, *not* the whole
        # border values that reportlab supports. We'll draw them ourselves in
        # PmlParagraph.
        style.borderTopStyle = first.borderTopStyle
        style.borderTopWidth = first.borderTopWidth
        style.borderTopColor = first.borderTopColor
        style.borderBottomStyle = first.borderBottomStyle
        style.borderBottomWidth = first.borderBottomWidth
        style.borderBottomColor = first.borderBottomColor
        style.borderLeftStyle = first.borderLeftStyle
        style.borderLeftWidth = first.borderLeftWidth
        style.borderLeftColor = first.borderLeftColor
        style.borderRightStyle = first.borderRightStyle
        style.borderRightWidth = first.borderRightWidth
        style.borderRightColor = first.borderRightColor

        # If no border color is given, the text color is used (XXX Tables!)
        if (style.borderTopColor is None) and style.borderTopWidth:
            style.borderTopColor = first.textColor      
        if (style.borderBottomColor is None) and style.borderBottomWidth:
            style.borderBottomColor = first.textColor      
        if (style.borderLeftColor is None) and style.borderLeftWidth:
            style.borderLeftColor = first.textColor      
        if (style.borderRightColor is None) and style.borderRightWidth:
            style.borderRightColor = first.textColor      

        style.borderPadding = first.borderPadding

        style.paddingTop = first.paddingTop
        style.paddingBottom = first.paddingBottom
        style.paddingLeft = first.paddingLeft
        style.paddingRight = first.paddingRight
        
        # This is the old code replaced by the above, kept for reference
        #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:huongchinguyen0202,项目名称:helicopter,代码行数:69,代码来源:pisa_context.py


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