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


Python ParagraphStyle.borderPadding方法代码示例

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


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

示例1: toParagraphStyle

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

示例2: addPara

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

示例3: toParagraphStyle

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

示例4: legend_building

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderPadding [as 别名]
def legend_building(learning_unit_year, is_fac, content, styles):
    content.append(BIG_INTER_LINE)
    content.append(BIG_INTER_LINE)
    p = ParagraphStyle('legend')
    p.textColor = 'grey'
    p.borderColor = 'grey'
    p.borderWidth = 1
    p.alignment = TA_CENTER
    p.fontSize =8
    p.borderPadding = 5
    legend_text = "%s : %s" % (_('Other score legend'), ExamEnrollment.justification_label_authorized(is_fac))
    if not learning_unit_year.decimal_scores:
        legend_text += "<br/><font color=red>%s</font>" % _('UnAuthorized decimal for this activity')

    content.append(Paragraph('''
                            <para>
                                %s
                            </para>
                            ''' % legend_text, p))
开发者ID:fthuin,项目名称:osis,代码行数:21,代码来源:pdf_utils.py

示例5: cover

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderPadding [as 别名]
 def cover(self):
     """ Display a cover.
     """
     # Define a style for the cover
     cover = ParagraphStyle("Cover")
     cover.textColor = "black"
     cover.borderColor = "black"
     cover.borderPadding = 80
     cover.borderWidth = 1
     cover.alignment = TA_CENTER
     cover.fontSize = 30
     cover.borderRadius = 20
     cover.backColor = "gray"
     cover.leading = 40
     pagesize = self.templates["OneCol"]["pagesize"]
     self.story.append(Cover(pagesize[0], pagesize[1] / 3, self.author,
                             self.client, self.poweredby, self.project,
                             self.timepoint, self.subject, self.date))
     self.story.append(Spacer(0, pagesize[1] / 2))
     self.story.append(Paragraph(self.title, cover))
开发者ID:neurospin,项目名称:pyconnectomist,代码行数:22,代码来源:pdftools.py

示例6: build_pdf

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderPadding [as 别名]
def build_pdf(image_file):
    filename = "%s.pdf" % _('scores_sheet')
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="%s"' % filename

    buffer = BytesIO()
    doc = SimpleDocTemplate(buffer,
                            pagesize=PAGE_SIZE,
                            rightMargin=MARGIN_SIZE,
                            leftMargin=MARGIN_SIZE,
                            topMargin=TOP_MARGIN,
                            bottomMargin=BOTTOM_MARGIN)
    image1 = get_image2(image_file)

    styles = getSampleStyleSheet()
    styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
    content = [image1]
    p = ParagraphStyle('legend')
    p.textColor = 'grey'
    p.borderColor = 'grey'
    p.borderWidth = 1
    p.alignment = TA_CENTER
    p.fontSize = 8
    p.borderPadding = 5

    legend_text = 'justification_legend'
    legend_text += "<br/><font color=red>%s</font>" % 'fffff'

    content.append(Paragraph('''
                            <para>
                                %s
                            </para>
                            ''' % legend_text, p))
    doc.build(content)
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    return response
开发者ID:verpoorten,项目名称:immobilier,代码行数:40,代码来源:image.py

示例7: _test0

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderPadding [as 别名]
def _test0(self):
    "This makes one long multi-page paragraph."

    # Build story.
    story = []
    a = story.append

    styleSheet = getSampleStyleSheet()
    h1 = styleSheet['Heading1']
    h1.pageBreakBefore = 1
    h1.keepWithNext = 1

    h2 = styleSheet['Heading2']
    h2.frameBreakBefore = 1
    h2.keepWithNext = 1

    h3 = styleSheet['Heading3']
    h3.backColor = colors.cyan
    h3.keepWithNext = 1

    bt = styleSheet['BodyText']
    btj = ParagraphStyle('bodyText1j',parent=bt,alignment=TA_JUSTIFY)
    btr = ParagraphStyle('bodyText1r',parent=bt,alignment=TA_RIGHT)
    btc = ParagraphStyle('bodyText1c',parent=bt,alignment=TA_CENTER)
    a(Paragraph("""
        <a name='top'/>Subsequent pages test pageBreakBefore, frameBreakBefore and
        keepTogether attributes.  Generated at %s.  The number in brackets
        at the end of each paragraph is its position in the story. (%d)""" % (
            time.ctime(time.time()), len(story)), bt))

    for i in range(10):
        a(Paragraph('Heading 1 always starts a new page (%d)' % len(story), h1))
        for j in range(3):
            a(Paragraph('Heading1 paragraphs should always'
                            'have a page break before.  Heading 2 on the other hand'
                            'should always have a FRAME break before (%d)' % len(story), bt))
            a(Paragraph('Heading 2 always starts a new frame (%d)' % len(story), h2))
            a(Paragraph('Heading1 paragraphs should always'
                            'have a page break before.  Heading 2 on the other hand'
                            'should always have a FRAME break before (%d)' % len(story), bt))
            for j in range(3):
                a(Paragraph(randomText(theme=PYTHON, sentences=2)+' (%d)' % len(story), bt))
                a(Paragraph('I should never be at the bottom of a frame (%d)' % len(story), h3))
                a(Paragraph(randomText(theme=PYTHON, sentences=1)+' (%d)' % len(story), bt))

    for align,bts in [('left',bt),('JUSTIFIED',btj),('RIGHT',btr),('CENTER',btc)]:
        a(Paragraph('Now we do &lt;br/&gt; tests(align=%s)' % align, h1))
        a(Paragraph('First off no br tags',h3))
        a(Paragraph(_text1,bts))
        a(Paragraph("&lt;br/&gt; after 'the' in line 4",h3))
        a(Paragraph(_text1.replace('forms of the','forms of the<br/>',1),bts))
        a(Paragraph("2*&lt;br/&gt; after 'the' in line 4",h3))
        a(Paragraph(_text1.replace('forms of the','forms of the<br/><br/>',1),bts))
        a(Paragraph("&lt;br/&gt; after 'I suggested ' in line 5",h3))
        a(Paragraph(_text1.replace('I suggested ','I suggested<br/>',1),bts))
        a(Paragraph("2*&lt;br/&gt; after 'I suggested ' in line 5",h3))
        a(Paragraph(_text1.replace('I suggested ','I suggested<br/><br/>',1),bts))
        a(Paragraph("&lt;br/&gt; at the end of the paragraph!",h3))
        a(Paragraph("""text one<br/>text two<br/>""",bts))
        a(Paragraph("Border with &lt;br/&gt; at the end of the paragraph!",h3))
        bt1 = ParagraphStyle('bodyText1',bts)
        bt1.borderWidth = 0.5
        bt1.borderColor = colors.toColor('red')
        bt1.backColor = colors.pink
        bt1.borderRadius = 2
        bt1.borderPadding = 3
        a(Paragraph("""text one<br/>text two<br/>""",bt1))
        a(Paragraph("Border no &lt;br/&gt; at the end of the paragraph!",h3))
        bt1 = ParagraphStyle('bodyText1',bts)
        bt1.borderWidth = 0.5
        bt1.borderColor = colors.toColor('red')
        bt1.backColor = colors.pink
        bt1.borderRadius = 2
        bt1.borderPadding = 3
        a(Paragraph("""text one<br/>text two""",bt1))
        a(Paragraph("Different border style!",h3))
        bt2 = ParagraphStyle('bodyText1',bt1)
        bt2.borderWidth = 1.5
        bt2.borderColor = colors.toColor('blue')
        bt2.backColor = colors.gray
        bt2.borderRadius = 3
        bt2.borderPadding = 3
        a(Paragraph("""text one<br/>text two<br/>""",bt2))
    for i in 0, 1, 2:
        P = Paragraph("""This is a paragraph with <font color='blue'><a href='#top'>with an incredibly
long and boring link in side of it that
contains lots and lots of stupidly boring and worthless information.
So that we can split the link and see if we get problems like Dinu's.
I hope we don't, but you never do Know.</a></font>""",bt)
        a(P)

    doc = MyDocTemplate(outputfile('test_platypus_breaking.pdf'))
    doc.multiBuild(story)
开发者ID:FatihZor,项目名称:infernal-twin,代码行数:95,代码来源:test_platypus_breaking.py

示例8: _test0

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderPadding [as 别名]
def _test0(self):
    "This makes one long multi-page paragraph."

    # Build story.
    story = []
    a = story.append

    styleSheet = getSampleStyleSheet()
    h1 = styleSheet["Heading1"]
    h1.pageBreakBefore = 1
    h1.keepWithNext = 1

    h2 = styleSheet["Heading2"]
    h2.frameBreakBefore = 1
    h2.keepWithNext = 1

    h3 = styleSheet["Heading3"]
    h3.backColor = colors.cyan
    h3.keepWithNext = 1

    bt = styleSheet["BodyText"]
    a(
        Paragraph(
            """
        Subsequent pages test pageBreakBefore, frameBreakBefore and
        keepTogether attributes.  Generated at %s.  The number in brackets
        at the end of each paragraph is its position in the story. (%d)"""
            % (time.ctime(time.time()), len(story)),
            bt,
        )
    )

    for i in xrange(10):
        a(Paragraph("Heading 1 always starts a new page (%d)" % len(story), h1))
        for j in xrange(3):
            a(
                Paragraph(
                    "Heading1 paragraphs should always"
                    "have a page break before.  Heading 2 on the other hand"
                    "should always have a FRAME break before (%d)" % len(story),
                    bt,
                )
            )
            a(Paragraph("Heading 2 always starts a new frame (%d)" % len(story), h2))
            a(
                Paragraph(
                    "Heading1 paragraphs should always"
                    "have a page break before.  Heading 2 on the other hand"
                    "should always have a FRAME break before (%d)" % len(story),
                    bt,
                )
            )
            for j in xrange(3):
                a(Paragraph(randomText(theme=PYTHON, sentences=2) + " (%d)" % len(story), bt))
                a(Paragraph("I should never be at the bottom of a frame (%d)" % len(story), h3))
                a(Paragraph(randomText(theme=PYTHON, sentences=1) + " (%d)" % len(story), bt))

    a(Paragraph("Now we do &lt;br/&gt; tests", h1))
    a(Paragraph("First off no br tags", h3))
    a(Paragraph(_text1, bt))
    a(Paragraph("&lt;br/&gt; after 'the' in line 4", h3))
    a(Paragraph(_text1.replace("forms of the", "forms of the<br/>", 1), bt))
    a(Paragraph("2*&lt;br/&gt; after 'the' in line 4", h3))
    a(Paragraph(_text1.replace("forms of the", "forms of the<br/><br/>", 1), bt))
    a(Paragraph("&lt;br/&gt; after 'I suggested ' in line 5", h3))
    a(Paragraph(_text1.replace("I suggested ", "I suggested<br/>", 1), bt))
    a(Paragraph("2*&lt;br/&gt; after 'I suggested ' in line 5", h3))
    a(Paragraph(_text1.replace("I suggested ", "I suggested<br/><br/>", 1), bt))
    a(Paragraph("&lt;br/&gt; at the end of the paragraph!", h3))
    a(Paragraph("""text one<br/>text two<br/>""", bt))
    a(Paragraph("Border with &lt;nr/&gt; at the end of the paragraph!", h3))
    bt1 = ParagraphStyle("bodyText1", bt)
    bt1.borderWidth = 0.5
    bt1.borderColor = colors.toColor("red")
    bt1.backColor = colors.pink
    bt1.borderRadius = 2
    bt1.borderPadding = 3
    a(Paragraph("""text one<br/>text two<br/>""", bt1))
    a(Paragraph("Border no &lt;nr/&gt; at the end of the paragraph!", h3))
    bt1 = ParagraphStyle("bodyText1", bt)
    bt1.borderWidth = 0.5
    bt1.borderColor = colors.toColor("red")
    bt1.backColor = colors.pink
    bt1.borderRadius = 2
    bt1.borderPadding = 3
    a(Paragraph("""text one<br/>text two""", bt1))
    a(Paragraph("Different border style!", h3))
    bt2 = ParagraphStyle("bodyText1", bt1)
    bt2.borderWidth = 1.5
    bt2.borderColor = colors.toColor("blue")
    bt2.backColor = colors.gray
    bt2.borderRadius = 3
    bt2.borderPadding = 3
    a(Paragraph("""text one<br/>text two<br/>""", bt2))

    doc = MyDocTemplate(outputfile("test_platypus_breaking.pdf"))
    doc.multiBuild(story)
开发者ID:radical-software,项目名称:radicalspam,代码行数:99,代码来源:test_platypus_breaking.py

示例9: toParagraphStyle

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

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import borderPadding [as 别名]
    def to_pdf(self, user, response):
        def invoice_footer(canvas, doc):
            canvas.saveState()
            canvas.setFont('Times-Roman', 10)
            PAGE_WIDTH = defaultPageSize[0]
            footer_text = "%s %s - SIRET : %s - %s, %s %s" % (user.first_name,
                                                              user.last_name,
                                                              user.get_profile().company_id,
                                                              user.get_profile().address.street.replace("\n", ", ").replace("\r", ""),
                                                              user.get_profile().address.zipcode,
                                                              user.get_profile().address.city)
            if user.get_profile().address.country:
                footer_text = footer_text + u", %s" % (user.get_profile().address.country)

            canvas.drawCentredString(PAGE_WIDTH / 2.0, 0.5 * inch, footer_text)
            canvas.restoreState()

        filename = ugettext('invoice_%(invoice_id)d.pdf') % {'invoice_id': self.invoice_id}
        response['Content-Disposition'] = 'attachment; filename=%s' % (filename)

        doc = BaseDocTemplate(response, title=ugettext('Invoice #%(invoice_id)d') % {'invoice_id': self.invoice_id}, leftMargin=0.5 * inch, rightMargin=0.5 * inch)
        frameT = Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height + 0.5 * inch, id='normal')
        doc.addPageTemplates([PageTemplate(id='all', frames=frameT, onPage=invoice_footer), ])

        styleH = ParagraphStyle({})
        styleH.fontSize = 14
        styleH.leading = 16
        styleH.borderPadding = (5,) * 4

        styleTotal = ParagraphStyle({})
        styleTotal.fontSize = 14
        styleTotal.leading = 16
        styleTotal.borderColor = colors.black
        styleTotal.borderWidth = 0.5
        styleTotal.borderPadding = (5,) * 4

        styleH2 = ParagraphStyle({})
        styleH2.fontSize = 14
        styleH2.leading = 16


        styleTitle = ParagraphStyle({})
        styleTitle.fontSize = 14
        styleTitle.fontName = "Times-Bold"

        styleN = ParagraphStyle({})
        styleN.fontSize = 12
        styleN.leading = 14

        styleNSmall = ParagraphStyle({})
        styleNSmall.fontSize = 8
        styleNSmall.leading = 14

        styleF = ParagraphStyle({})
        styleF.fontSize = 10
        styleF.alignment = TA_CENTER

        styleLabel = ParagraphStyle({})

        story = []

        data = []
        user_header_content = """
        %s %s<br/>
        %s<br/>
        %s %s<br/>
        %s<br/>
        SIRET : %s<br/>
        """ % (user.first_name,
               user.last_name,
               user.get_profile().address.street.replace("\n", "<br/>"),
               user.get_profile().address.zipcode,
               user.get_profile().address.city,
               user.get_profile().address.country or '',
               user.get_profile().company_id)

        customer_header_content = """
        %s<br/>
        %s<br/>
        %s %s<br/>
        %s<br/>
        """

        if user.get_profile().logo_file:
            user_header = Image("%s%s" % (settings.FILE_UPLOAD_DIR, user.get_profile().logo_file))
        else:
            user_header = Paragraph(user_header_content, styleH)

        customer_header = customer_header_content % (self.customer.name,
                                                     self.customer.address.street.replace("\n", "<br/>"),
                                                     self.customer.address.zipcode,
                                                     self.customer.address.city,
                                                     self.customer.address.country or '')

        if self.customer.contact_type == CONTACT_TYPE_COMPANY \
            and self.customer.company_id:
            customer_header = "%sSIRET : %s<br/>" % (customer_header,
                                                     self.customer.company_id)

        customer_header = Paragraph(customer_header, styleH)
#.........这里部分代码省略.........
开发者ID:fouda2009,项目名称:aemanager,代码行数:103,代码来源:models.py

示例11: createPDF

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

#.........这里部分代码省略.........
        td_cell_right.spaceAfter = 6
        td_cell_right.fontSize = 10
        td_cell_right.fontName = 'Times-Roman'
        td_cell_right.alignment = TA_RIGHT

        bullet_list = ParagraphStyle('BulletList')
        bullet_list.spaceBefore = 4
        bullet_list.spaceAfter = 4
        bullet_list.fontName = 'Times-Roman'
        bullet_list.bulletIndent = 5
        bullet_list.leftIndent = 17
        bullet_list.bulletFontSize = 12

        blockquote = ParagraphStyle('Blockquote')
        blockquote.leftIndent = 12
        blockquote.rightIndent = 8
        blockquote.spaceAfter = 6
        blockquote.fontName = 'Times-Roman'

        discreet = ParagraphStyle('Discreet')
        discreet.fontSize = 9
        discreet.textColor = HexColor('#717171')
        discreet.spaceAfter = 12
        discreet.spaceBefore = 1

        callout = ParagraphStyle('Callout')
        callout.fontSize = 10
        callout.textColor = header_rgb
        callout.spaceAfter = 20
        callout.spaceBefore = 22
        callout.backColor = callout_background_rgb
        callout.borderColor = header_rgb
        callout.borderWidth = 1
        callout.borderPadding = (8, 12, 10, 12)
        callout.rightIndent = 15
        callout.leftIndent = 15

        statement = ParagraphStyle('Statement')
        statement.fontSize = 8
        statement.fontName = 'Times-Roman'
        statement.spaceAfter = 5
        statement.leading = 10

        description = ParagraphStyle('Description')
        description.spaceBefore = 6
        description.spaceAfter = 8
        description.fontSize = 11
        description.fontName = 'Helvetica-Bold'
        description.leading = 13

        padded_image = ParagraphStyle('PaddedImage')
        padded_image.spaceBefore = 12
        padded_image.spaceAfter = 12

        single_line = ParagraphStyle('SingleLine')
        single_line.fontSize = 9
        single_line.fontName = 'Times-Roman'
        single_line.spaceBefore = 0
        single_line.spaceAfter = 0

        single_line_cr = ParagraphStyle('SingleLineCR')
        single_line_cr.fontSize = 9
        single_line_cr.fontName = 'Times-Roman'
        single_line_cr.spaceBefore = 0
        single_line_cr.spaceAfter = 10
开发者ID:tsimkins,项目名称:agsci.ExtensionExtender,代码行数:69,代码来源:pdf.py


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