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


Python ParagraphStyle.spaceAfter方法代码示例

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


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

示例1: build_encabezado

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

示例2: getBody

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

示例3: toParagraphStyle

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

示例4: addPara

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

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

示例6: toParagraphStyle

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

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import spaceAfter [as 别名]
def build_despedida(datos_comercial = [], idioma = "es"):
    estilo = ParagraphStyle("despedida", parent = estilos["Normal"])
    estilo.fontSize += 4
    if idioma == "en":
        strdespedida = "<b>Best regards:</b>"
    else:
        strdespedida = "<b>Atentamente:</b>"
    par = [Paragraph(strdespedida, estilo)]
    estilo.fontSize -= 2
    estilo.spaceAfter = 4
    par.append(Spacer(1, 0.3 * cm))
    for linea in datos_comercial:
        if datos_comercial.index(linea) == 1:
            linea = "<b>%s</b>" % linea
        par.append(Paragraph(linea, estilo))
    return par
开发者ID:pacoqueen,项目名称:ginn,代码行数:18,代码来源:carta_compromiso.py

示例8: getExamples

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

示例9: toParagraphStyle

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

示例10: rebStyleSeet

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import spaceAfter [as 别名]
def rebStyleSeet():
    """Return realestatebroker stylesheet."""
    stylesheet = {}
    colors = rebColors()
    fonts = {'LuxiSans': 'luxisr.ttf',
             'LuxiSansOblique': 'luxisri.ttf',
             'LuxiSansBold': 'luxisb.ttf',
             'LuxiSansBoldOblique': 'luxisbi.ttf'}
    for name, fn in fonts.items():
        filename = os.path.join(os.path.dirname(__file__), fn)
        pdfmetrics.registerFont(TTFont(name, filename))
    addMapping('LuxiSans', 0, 0, 'LuxiSans') #normal
    addMapping('LuxiSans', 0, 1, 'LuxiSansOblique') #italic
    addMapping('LuxiSans', 1, 0, 'LuxiSansBold') #bold
    addMapping('LuxiSans', 1, 1, 'LuxiSansBoldOblique') #italic and bold
    normal_font = 'LuxiSans'
    bold_font = 'LuxiSansBold'
    # Huge is for the huge "for sale" text on the default frontpage.
    huge = ParagraphStyle('huge')
    huge.fontSize = 48
    huge.leading = 50
    huge.spaceAfter = 0
    huge.fontName = bold_font
    stylesheet['huge'] = huge
    # Big: large text on the front page and for the address at the end.
    big = ParagraphStyle('big')
    big.fontSize = 24
    big.leading = 26
    big.spaceAfter = 10
    big.fontName = bold_font
    stylesheet['big'] = big
    # Footer: small text at the bottom of every page.
    footer = ParagraphStyle('footer')
    footer.fontSize = 10
    footer.spaceAfter = 0
    footer.fontName = normal_font
    stylesheet['footer'] = footer
    # Normal: normal text
    normal = ParagraphStyle('normal')
    normal.fontSize = 12
    normal.leading = 14
    normal.spaceAfter = 12
    normal.fontName = normal_font
    stylesheet['normal'] = normal
    # Description: description text, you might want to have this bold or so.
    description = ParagraphStyle('description')
    description.fontSize = 16
    description.leading = 18
    description.spaceAfter = 16
    description.fontName = bold_font
    stylesheet['description'] = description
    # Heading1: heading1 text
    heading1 = ParagraphStyle('heading1')
    heading1.fontSize = 16
    heading1.leading = 18
    heading1.spaceAfter = 16
    heading1.fontName = bold_font
    stylesheet['heading1'] = heading1
    # Heading2: heading2 text
    heading2 = ParagraphStyle('heading2')
    heading2.fontSize = 12
    heading2.leading = 14
    heading2.spaceAfter = 0
    heading2.spaceBefore = 14
    heading2.fontName = bold_font
    stylesheet['heading2'] = heading2
    # Table_header: table header text.
    table_header = ParagraphStyle('table_header')
    table_header.fontSize = 12
    table_header.leading = 14
    table_header.spaceAfter = 0
    table_header.fontName = bold_font
    table_header.textColor = colors['table_heading_textcolor']
    stylesheet['table_header'] = table_header
    # Table_text: table text.
    table_text = ParagraphStyle('table_text')
    table_text.fontSize = 10
    table_text.leading = 12
    table_text.spaceAfter = 0
    table_text.fontName = normal_font
    stylesheet['table_text'] = table_text

    utility = queryUtility(IStyleModifier)
    if not utility:
        return stylesheet
    else:
        return utility(stylesheet)
开发者ID:collective,项目名称:collective.realestatebroker,代码行数:89,代码来源:common.py

示例11: ParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import spaceAfter [as 别名]
# Create the styles for the document
logoStyle = ParagraphStyle('normal')
logoStyle.fontSize=16
logoStyle.leading=15
logoStyle.rightindent=5
logoStyle.backColor='grey'
#logoStyle.textColor='white'
logoStyle.borderWidth=5
logoStyle.borderColor='grey'

rightStyle = ParagraphStyle('normal')
rightStyle.alignment = TA_RIGHT
rightStyle.spaceBefore = 10

paraStyle = ParagraphStyle('normal')
paraStyle.spaceAfter = 10
paraStyle.alignment = TA_JUSTIFY

medStyle = ParagraphStyle('normal')
medStyle.fontSize = 8
medStyle.leading = 8
medStyle.spaceAfter = 10
medStyle.alignment = TA_JUSTIFY

smallStyle = ParagraphStyle('normal')
smallStyle.fontSize = 6
smallStyle.leading = 6
smallStyle.spaceAfter = 0
smallStyle.alignment = TA_JUSTIFY

开发者ID:fergusrossferrier,项目名称:mypidge.com,代码行数:31,代码来源:PocketPidge.py

示例12: makeSummary

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import spaceAfter [as 别名]
    def makeSummary(self, org, sa, sdas, cas, eus):
        """Generates a pdf of the sa_summary page."""
        # Prep document.
        doc = SimpleDocTemplate(self.response, pagesize=landscape(letter), topMargin=36,
                                bottomMargin=36)
        Story = [Spacer(1,0.5*inch)]
        style = self.styles["Normal"]
        light_gray = (0.9, 0.9, 0.9)
        dark_gray = (0.75, 0.75, 0.75)
        elements = []

        # Define styles.
        eu_style = ParagraphStyle('eu_style', fontName='Helvetica', bulletText=u'\u2022',
                                  leftIndent=10, borderWidth=0, borderColor='black')

        # Add title and subtitle.
        p_style = ParagraphStyle('title', fontName='Helvetica-Bold', fontSize=20,
                                 spaceAfter=0)
        elements.append(Paragraph(org.name, p_style))
        p_style.fontName = 'Helvetica'
        p_style.fontSize = 16
        p_style.spaceAfter = 20
        elements.append(Paragraph(sa.subject_area, p_style))

        spacer_width = 0.05*inch
        ca_col_width = 3*inch - spacer_width/2
        eu_col_width = 6*inch - spacer_width/2
        col_widths = (ca_col_width, spacer_width, eu_col_width)
        
        # Build a series of separate tables.
        #  Easy to manage styling this way.

        # --- Header row. ---
        data = [(org.alias_ca.title()+'s', '', org.alias_eu.title()+'s')]
        table = Table(data, colWidths=col_widths)
        elements.append(table)
        table.setStyle(TableStyle([('BACKGROUND', (0,0), (0,0), dark_gray),
                                   ('BACKGROUND', (2,0), (2,0), light_gray),
                                   ('BOTTOMPADDING', (0,0), (-1,-1), 10),
                                   ('FONTSIZE', (0,0), (-1,-1), 14),
                                   ('FONTNAME', (0,0), (-1,-1), 'Helvetica-Bold'),
                                   ]))
        # Clear data.
        data = []

        # Spacer row.
        self.add_spacer_row(elements, col_widths, spacer_width)

        # --- Subject area competency areas. ---
        # Each competency area and its eus are a separate table.
        for ca in cas:
            if not ca.subdiscipline_area:
                p_ca = Paragraph(ca.competency_area, style)
                first_eu = True
                for eu in eus:
                    if eu.competency_area == ca:
                        p_eu = Paragraph(eu.essential_understanding, eu_style)
                        if first_eu:
                            data.append((p_ca, '', p_eu))
                            first_eu = False
                        else:
                            data.append(('', '', p_eu))
                # Make sure to include ca if there were no eu's.
                if first_eu:
                    data.append((p_ca, '', ''))
            if data:
                # Build table.
                table = Table(data, colWidths=col_widths)
                elements.append(table)
                table.setStyle(TableStyle([('BACKGROUND', (0,0), (0,-1), dark_gray),
                                           ('BACKGROUND', (2,0), (2,-1), light_gray),
                                           ('BOTTOMPADDING', (0,-1), (-1,-1), 10),
                                           ('VALIGN', (0,0), (0,0), 'TOP'),
                                           ]))
                data = []
                self.add_spacer_row(elements, col_widths, spacer_width)


        # Add sda competency areas.
        for sda in sdas:
            # Add a single-row table for the sda.
            p_style = ParagraphStyle('title', fontName='Helvetica-Bold', fontSize=14,
                                 spaceBefore=5, spaceAfter=10)
            elements.append(Paragraph(sda.subdiscipline_area, p_style))

            # Each competency area and its eus are a separate table.
            for ca in cas:
                if (ca.subdiscipline_area
                    and ca.subdiscipline_area.subdiscipline_area == sda.subdiscipline_area):
                    p_ca = Paragraph(ca.competency_area, style)
                    #data.append((p, '', ''))
                    first_eu = True
                    for eu in eus:
                        if eu.competency_area == ca:
                            p_eu = Paragraph(eu.essential_understanding, eu_style)
                            if first_eu:
                                data.append((p_ca, '', p_eu))
                                first_eu = False
                            else:
                                data.append(('', '', p_eu))
#.........这里部分代码省略.........
开发者ID:openlearningtools,项目名称:opencompetencies,代码行数:103,代码来源:sa_summary_pdf.py

示例13: createPDF

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import spaceAfter [as 别名]

#.........这里部分代码省略.........
                        ('GRID', (c_index,r_index), (c_max,r_max), 0.5, grid),
                        ('FONTNAME', (c_index,r_index), (c_index,r_index), 'Times-Roman'),
                        ('FONTSIZE', (c_index,r_index), (c_index,r_index), 9),
                        ('LEFTPADDING', (c_index,r_index), (c_index,r_index), 3),
                        ('RIGHTPADDING', (c_index,r_index), (c_index,r_index), 3),
                        ('SPAN', (c_index,r_index), (c_max,r_max)),
                        ('ALIGN', (c_index,r_index), (c_index,r_index), td_align),
                      ]
                    )

                    c_index = c_index + 1

                table_data.append(table_row)
                r_index = r_index + 1

            caption = item.find('caption')

            return (table_data, TableStyle(table_style), caption)


        # Provides the PDF entities for the corresponding HTML tags.

        def getContent(item, bump_headings=False):
            pdf = []
            if isinstance(item, Tag):
                className=item.get('class', '').split()
                item_type = item.name
                if item_type in ['h2', 'h3', 'h4', 'h5', 'h6']:
                    item_style = tag_to_style.get(item_type)
                    h = Paragraph(getItemText(item), styles[item_style])
                    h.keepWithNext = True
                    pdf.append(h)
                    if item_type == 'h2' and not bump_headings:
                        hr = HRFlowable(width='100%', thickness=0.25, spaceBefore=2, spaceAfter=4, color=styles[item_style].textColor)
                        hr.keepWithNext = True
                        pdf.append(hr)
                elif item_type in ['table']:
                    (table_data, table_style, caption) = getTableData(item)
                    table = Table(table_data)
                    table.setStyle(table_style)
                    table.hAlign = 'LEFT'
                    table.spaceBefore = 10
                    table.spaceAfter = 10

                    if caption:
                        caption_el = Paragraph(getInlineContents(caption), discreet)
                        pdf.append(KeepTogether([table, caption_el]))
                    else:
                        pdf.append(table)

                elif item_type in ['ul']:
                    for i in item.findAll('li'):
                        pdf.append(Paragraph('<bullet>&bull;</bullet>%s' % getInlineContents(i), bullet_list))
                elif item_type in ['ol']:
                    # Sequences were incrementing based on previous PDF generations.
                    # Including explicit ID and reset
                    li_uuid = uuid1().hex
                    for i in item.findAll('li'):
                        pdf.append(Paragraph('<seq id="%s" />. %s' % (li_uuid, getInlineContents(i)), bullet_list))
                    pdf.append(Paragraph('<seqReset id="%s" />' % li_uuid, styles['Normal']))
                elif item_type in ['p'] or (item_type in ['div'] and 'captionedImage' in className or 'callout' in className or 'pullquote' in className):

                    has_image = False

                    # Pull images out of items and add before
                    for img in item.findAll('img'):
开发者ID:tsimkins,项目名称:agsci.ExtensionExtender,代码行数:70,代码来源:pdf.py


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