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


Python styles.ParagraphStyle方法代码示例

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


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

示例1: __init__

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def __init__(self, pdf_components):
        self.style = getSampleStyleSheet()
        self.style['Normal'].leading = 16
        self.style.add(ParagraphStyle(name='centered', alignment=TA_CENTER))
        self.style.add(ParagraphStyle(name='centered_wide', alignment=TA_CENTER,
                                      leading=18))
        self.style.add(ParagraphStyle(name='section_body',
                                      parent=self.style['Normal'],
                                      spaceAfter=inch * .05,
                                      fontSize=11))
        self.style.add(ParagraphStyle(name='bullet_list',
                                      parent=self.style['Normal'],
                                      fontSize=11))
        if six.PY3:
            self.buffer = six.BytesIO()
        else:
            self.buffer = six.StringIO()
        self.firstPage = True
        self.document = SimpleDocTemplate(self.buffer, pagesize=letter,
                                          rightMargin=12.7 * mm, leftMargin=12.7 * mm,
                                          topMargin=120, bottomMargin=80)

        self.tlp_color = pdf_components.get('tlp_color', '')
        self.pdf_components = pdf_components
        self.pdf_list = [] 
开发者ID:mitre,项目名称:multiscanner,代码行数:27,代码来源:generic_pdf.py

示例2: test2

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def test2(canv,testpara):
    #print test_program; return
    from reportlab.lib.units import inch
    from reportlab.lib.styles import ParagraphStyle
    from reportlab.lib import rparsexml
    parsedpara = rparsexml.parsexmlSimple(testpara,entityReplacer=None)
    S = ParagraphStyle("Normal", None)
    P = Para(S, parsedpara)
    (w, h) = P.wrap(5*inch, 10*inch)
    print("wrapped as", (h,w))
    canv.saveState()
    canv.translate(1*inch, 1*inch)
    canv.rect(0,0,5*inch,10*inch, fill=0, stroke=1)
    P.canv = canv
    canv.saveState()
    P.draw()
    canv.restoreState()
    canv.setStrokeColorRGB(1, 0, 0)
    #canv.translate(0, 3*inch)
    canv.rect(0,0,w,h, fill=0, stroke=1)
    canv.restoreState()
    canv.showPage() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:para.py

示例3: run

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def run():
        objects_to_draw = []
        from reportlab.lib.styles import ParagraphStyle
        #from paragraph import Paragraph
        from reportlab.platypus.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:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:doctemplate.py

示例4: demo1

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def demo1(canvas):
    frame = Frame(
                    2*inch,     # x
                    4*inch,     # y at bottom
                    4*inch,     # width
                    5*inch,     # height
                    showBoundary = 1  # helps us see what's going on
                    )
    bodyStyle = ParagraphStyle('Body', fontName=_baseFontName, fontSize=24, leading=28, spaceBefore=6)
    para1 = Paragraph('Spam spam spam spam. ' * 5, bodyStyle)
    para2 = Paragraph('Eggs eggs eggs. ' * 5, bodyStyle)
    mydata = [para1, para2]

    #this does the packing and drawing.  The frame will consume
    #items from the front of the list as it prints them
    frame.addFromList(mydata,canvas) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:figures.py

示例5: create_img_table

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def create_img_table(self, dir):
        item_tbl_data = []
        item_tbl_row = []
         
        for i, file in enumerate(os.listdir(dir)):
            last_item = len(os.listdir(dir)) - 1
            if ".png" in file:
                img = Image(os.path.join(dir, file), inch, inch)
                img_name = file.replace(".png", "")
                              
                if len(item_tbl_row) == 4:
                    item_tbl_data.append(item_tbl_row)
                    item_tbl_row = []
                elif i == last_item:
                    item_tbl_data.append(item_tbl_row)
                      
                i_tbl = Table([[img], [Paragraph(img_name, ParagraphStyle("item name style", wordWrap='CJK'))]])
                item_tbl_row.append(i_tbl)    
                    
        if len(item_tbl_data) > 0:
            item_tbl = Table(item_tbl_data, colWidths=125)
            self.elements.append(item_tbl)
            self.elements.append(Spacer(1, inch * 0.5)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:fd_api_doc.py

示例6: test2

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def test2(canv,testpara):
    #print test_program; return
    from reportlab.lib.units import inch
    from reportlab.lib.styles import ParagraphStyle
    from reportlab.lib import rparsexml
    parsedpara = rparsexml.parsexmlSimple(testpara,entityReplacer=None)
    S = ParagraphStyle("Normal", None)
    P = Para(S, parsedpara)
    (w, h) = P.wrap(5*inch, 10*inch)
    print "wrapped as", (h,w)
    canv.saveState()
    canv.translate(1*inch, 1*inch)
    canv.rect(0,0,5*inch,10*inch, fill=0, stroke=1)
    P.canv = canv
    canv.saveState()
    P.draw()
    canv.restoreState()
    canv.setStrokeColorRGB(1, 0, 0)
    #canv.translate(0, 3*inch)
    canv.rect(0,0,w,h, fill=0, stroke=1)
    canv.restoreState()
    canv.showPage() 
开发者ID:gltn,项目名称:stdm,代码行数:24,代码来源:para.py

示例7: run

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [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:gltn,项目名称:stdm,代码行数:23,代码来源:doctemplate.py

示例8: _getCaptionPara

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def _getCaptionPara(self):
        caption = self.caption
        captionFont = self.captionFont
        captionSize = self.captionSize
        captionTextColor = self.captionTextColor
        captionBackColor = self.captionBackColor
        if self._captionData!=(caption,captionFont,captionSize,captionTextColor,captionBackColor):
            self._captionData = (caption,captionFont,captionSize,captionTextColor,captionBackColor)
            self.captionStyle = ParagraphStyle(
                'Caption',
                fontName=captionFont,
                fontSize=captionSize,
                leading=1.2*captionSize,
                textColor = captionTextColor,
                backColor = captionBackColor,
                #seems to be getting ignored
                spaceBefore=self.captionGap or 0.5*captionSize,
                alignment=TA_CENTER)
            #must build paragraph now to get sequencing in synch with rest of story
            self.captionPara = Paragraph(self.caption, self.captionStyle) 
开发者ID:gltn,项目名称:stdm,代码行数:22,代码来源:figures.py

示例9: run

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def run(self):
        cp = rlab.CoverPage(self.title, subtitle2=self.author)
        self.pdf = pdf = rlab.PdfBuilder(self.path, coverpage=cp)
        # Setup stylesheet
        tb = ParagraphStyle('TitleBar', parent=pdf.stylesheet['Normal'], fontName='Helvetica-Bold', fontSize=10,

                    leading=10, alignment=TA_CENTER)
        'TitleBar' not in pdf.stylesheet and pdf.stylesheet.add(tb)
        # define templates
        self.define_portfolio_summary_template()
        self.define_position_summary_template()
        self.define_summary_template()
        # Show the summary page
        self.add_summary_page()
        # Build the portfolio and position details for each result
        for r in self.results:
            self.add_portfolio_page(r)
            self.add_position_page(r)
        pdf.save() 
开发者ID:bpsmith,项目名称:tia,代码行数:21,代码来源:pdf_rpts.py

示例10: __init__

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def __init__(self, to_addr_lines, from_name_lines, date=None,
                 closing="Yours truly", signer=None, paragraphs=None, cosigner_lines=None, use_sig=True,
                 body_font_size=None, cc_lines=None):
        self.date = date or datetime.date.today()
        self.closing = closing
        self.flowables = []
        self.to_addr_lines = to_addr_lines
        self.from_name_lines = from_name_lines
        self.cosigner_lines = cosigner_lines
        self.signer = signer
        self.use_sig = use_sig
        if cc_lines:
            self.cc_lines = [cc for cc in cc_lines if cc.strip()]
        else:
            self.cc_lines = None
        if paragraphs:
            self.add_paragraphs(paragraphs)

        # styles
        self.line_height = (body_font_size or 12) + 1
        self.content_style = ParagraphStyle(name='Normal',
                                            fontName='BemboMTPro',
                                            fontSize=body_font_size or 12,
                                            leading=self.line_height,
                                            allowWidows=0,
                                            allowOrphans=0,
                                            alignment=TA_JUSTIFY,
                                            textColor=black)
        self.table_style = TableStyle([
                    ('FONT', (0,0), (-1,-1), 'BemboMTPro', 12, self.line_height),
                    ('TOPPADDING', (0,0), (-1,-1), 0),
                    ('BOTTOMPADDING', (0,0), (-1,-1), 0),
                    ]) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:35,代码来源:letters.py

示例11: paragraph_model

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def paragraph_model(msg):
    """
    添加一段文字
    :param msg:
    :return:
    """
    # 设置文字样式
    style = ParagraphStyle(
        name='Normal',
        fontName='SimSun',
        fontSize=50,
    )

    return Paragraph(msg, style=style) 
开发者ID:qzq1111,项目名称:flask-restful-example,代码行数:16,代码来源:report.py

示例12: getLevelStyle

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def getLevelStyle(self, n):
        '''Returns the style for level n, generating and caching styles on demand if not present.'''
        try:
            return self.levelStyles[n]
        except IndexError:
            prevstyle = self.getLevelStyle(n-1)
            self.levelStyles.append(ParagraphStyle(
                    name='%s-%d-indented' % (prevstyle.name, n),
                    parent=prevstyle,
                    firstLineIndent = prevstyle.firstLineIndent+delta,
                    leftIndent = prevstyle.leftIndent+delta))
            return self.levelStyles[n] 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:tableofcontents.py

示例13: setup

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def setup(self, style=None, dot=None, tableStyle=None, headers=True, name=None, format='123', offset=0):
        """
        This method makes it possible to change styling and other parameters on an existing object.

        style is the paragraph style to use for index entries.
        dot can either be None or a string. If it's None, entries are immediatly followed by their
            corresponding page numbers. If it's a string, page numbers are aligned on the right side
            of the document and the gap filled with a repeating sequence of the string.
        tableStyle is the style used by the table which the index uses to draw itself. Use this to
            change properties like spacing between elements.
        headers is a boolean. If it is True, alphabetic headers are displayed in the Index when the first
        letter changes. If False, we just output some extra space before the next item
        name makes it possible to use several indexes in one document. If you want this use this
            parameter to give each index a unique name. You can then index a term by refering to the
            name of the index which it should appear in:

                <index item="term" name="myindex" />

        format can be 'I', 'i', '123',  'ABC', 'abc'
        """

        if style is None:
            style = ParagraphStyle(name='index',
                                        fontName=_baseFontName,
                                        fontSize=11)
        self.textStyle = style
        self.tableStyle = tableStyle or defaultTableStyle
        self.dot = dot
        self.headers = headers
        if name is None:
            from reportlab.platypus.paraparser import DEFAULT_INDEX_NAME as name
        self.name = name
        self.formatFunc = self.getFormatFunc(format)
        self.offset = offset 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:36,代码来源:tableofcontents.py

示例14: _getCaptionPara

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def _getCaptionPara(self):
        caption = self.caption
        captionFont = self.captionFont
        captionSize = self.captionSize
        captionTextColor = self.captionTextColor
        captionBackColor = self.captionBackColor
        captionAlign = self.captionAlign
        captionPosition = self.captionPosition
        if self._captionData!=(caption,captionFont,captionSize,captionTextColor,captionBackColor,captionAlign,captionPosition):
            self._captionData = (caption,captionFont,captionSize,captionTextColor,captionBackColor,captionAlign,captionPosition)
            if isinstance(caption,Paragraph):
                self.captionPara = caption
            elif isinstance(caption,strTypes):
                self.captionStyle = ParagraphStyle(
                    'Caption',
                    fontName=captionFont,
                    fontSize=captionSize,
                    leading=1.2*captionSize,
                    textColor = captionTextColor,
                    backColor = captionBackColor,
                    #seems to be getting ignored
                    spaceBefore=self.captionGap,
                    alignment=TA_LEFT if captionAlign=='left' else TA_RIGHT if captionAlign=='right' else TA_CENTER,
                    )
                #must build paragraph now to get sequencing in synch with rest of story
                self.captionPara = Paragraph(self.caption, self.captionStyle)
            else:
                raise ValueError('Figure caption of type %r is not a string or Paragraph' % type(caption)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:30,代码来源:figures.py

示例15: create_hdr

# 需要导入模块: from reportlab.lib import styles [as 别名]
# 或者: from reportlab.lib.styles import ParagraphStyle [as 别名]
def create_hdr(self, name, font_size):
        hdr_style = TableStyle([('TEXTCOLOR', (0, 0), (-1, -1), colors.black),
                                ('BOTTOMPADDING', (0, 0), (-1, -1), 15),
                                ('TOPPADDING', (0, 0), (-1, -1), 15),
                                ('FONTSIZE', (0, 0), (-1, -1), 8),
                                ('VALIGN', (0, 0), (-1, -1), 'TOP'),
                                ('ALIGN', (0, 0), (-1, 0), 'LEFT'),
                                ('LINEBELOW', (0, 0), (-1, -1), 2, colors.black),
                                ('BACKGROUND', (0, 1), (-1, -1), colors.white)])        
        
        name_p = Paragraph(name, ParagraphStyle("Category name style", fontSize=font_size))
        hdr_tbl = Table([[name_p]], colWidths = 500, rowHeights = None, repeatRows = 1)
        hdr_tbl.setStyle(hdr_style)
        self.elements.append(hdr_tbl) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:fd_api_doc.py


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