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


Python platypus.Paragraph方法代码示例

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


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

示例1: afterFlowable

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def afterFlowable(self, flowable):
        if flowable.__class__.__name__ == 'Paragraph':
            text = flowable.getPlainText()
            style = flowable.style.name
            if style == 'Heading1':
                 key = 'h1-%s' % self.seq.nextf('heading1')
                 self.canv.bookmarkPage(key)
                 self.notify('TOCEntry', (0, text, self.page, key))
            if style == 'Heading2':
                 key = 'h2-%s' % self.seq.nextf('heading2')
                 self.canv.bookmarkPage(key)
                 self.notify('TOCEntry', (1, text, self.page, key))
                 
            if style == 'Heading3':
                 key = 'h3-%s' % self.seq.nextf('heading3')
                 self.canv.bookmarkPage(key)
                 self.notify('TOCEntry', (2, text, self.page, key)) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:19,代码来源:generatereport.py

示例2: autoscale_text

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def autoscale_text(page, string, max_fontsize, max_leading, max_height, max_width, style):
    """Calculate font size and text placement given some base values

    These values passed by reference are modified in this function, and not passed back:
        - style.fontSize
        - style.leading
    """
    width = max_width + 1
    height = max_height + 1
    fontsize = max_fontsize
    leading = max_leading

    # Loop while size of text bigger than max allowed size as passed through
    while width > max_width or height > max_height:
        style.fontSize = fontsize
        style.leading = leading
        paragraph = Paragraph(string, style)
        width, height = paragraph.wrapOn(page, max_width, max_height)
        fontsize -= 1
        leading -= 1

    return paragraph 
开发者ID:edx,项目名称:edx-certificates,代码行数:24,代码来源:gen_cert.py

示例3: _item_raw_data_and_subtotal

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def _item_raw_data_and_subtotal(self):
        item_data = []
        item_subtotal = 0

        for item in self._items:
            if not isinstance(item, Item):
                continue

            item_data.append(
                (
                    item.name,
                    Paragraph(item.description, self._defined_styles.get('TableParagraph')),
                    item.units,
                    item.unit_price,
                    item.amount
                )
            )
            item_subtotal += item.amount

        return item_data, item_subtotal 
开发者ID:CiCiApp,项目名称:PyInvoice,代码行数:22,代码来源:templates.py

示例4: demo1

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [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 import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [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: _item_raw_data_and_subtotal

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def _item_raw_data_and_subtotal(self):
        item_data = []
        item_subtotal = 0

        for item in self._items:
            if not isinstance(item, Item):
                continue

            item_data.append(
                (
                    item.name,
                    Paragraph(item.description, self._defined_styles.get('TableParagraph')),
                    item.units,
                    item.unit_price,
                    item.unit_price_discounted,
                    ( item.unit_price - item.unit_price_discounted ) * item.units,
                    item.amount
                )
            )
            item_subtotal += item.amount

        return item_data, item_subtotal 
开发者ID:104H,项目名称:HH---POS-Accounting-and-ERP-Software,代码行数:24,代码来源:templates.py

示例7: draw_paragraph

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def draw_paragraph(self, text, max_width, max_height, style):
        if not text:
            text = ''
        if not isinstance(text, str):
            text = str(text)
        text = text.strip(string.whitespace)
        text = text.replace('\n', "<br/>")
        p = Paragraph(text, style)
        used_width, used_height = p.wrap(max_width, max_height)
        line_widths = p.getActualLineWidths0()
        number_of_lines = len(line_widths)
        if number_of_lines > 1:
            actual_width = used_width
        elif number_of_lines == 1:
            actual_width = min(line_widths)
            used_width, used_height = p.wrap(actual_width + 0.1, max_height)
        else:
            return 0, 0
        p.drawOn(self.canvas, self.cursor.x, self.cursor.y - used_height)
        return used_width, used_height 
开发者ID:codeforamerica,项目名称:intake,代码行数:22,代码来源:pdf_form_display.py

示例8: match_page

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def match_page(self, match_report, match_content):
        if match_content.voicemail:
            voicemail_pref = "Ok to leave voicemail"
        else:
            voicemail_pref = "Not okay to leave voicemail"

        return [
            Paragraph("Matching Report Contents", self.report_title_style),
            Paragraph(
                f"""
                    Perpetrator name given: {match_content.perp_name or "<i>Not available or none provided</i>"}<br />
                    Reported by: {self.get_user_identifier(match_report.report.owner)}<br />
                    Submitted to matching on: {match_report.added.strftime("%Y-%m-%d %H:%M")}<br />
                    Record created: {match_report.report.added.strftime("%Y-%m-%d %H:%M")}<br />
                    <br /><br />
                    Name: {match_content.contact_name or "<i>None provided</i>"}<br />
                    Phone: {match_content.phone}<br />
                    Voicemail preferences: {voicemail_pref}<br />
                    Email: {match_content.email}<br />
                    Notes on preferred contact time of day, gender of admin, etc.:<br />
                """,
                self.body_style,
            ),
            Paragraph(match_content.notes or "None provided", self.notes_style),
        ] 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:27,代码来源:report_delivery.py

示例9: get_cover_page

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def get_cover_page(self, report_id, recipient):
        # title = f"{self.report_title} No.: {report_id}"

        styles = getSampleStyleSheet()
        headline_style = styles["Heading1"]
        headline_style.alignment = TA_CENTER
        headline_style.fontSize = 48
        subtitle_style = styles["Heading2"]
        subtitle_style.fontSize = 24
        subtitle_style.leading = 26
        subtitle_style.alignment = TA_CENTER

        CoverPage = []
        logo = os.path.join(settings.BASE_DIR, self.logo_path)

        image = Image(logo, 3 * inch, 3 * inch)
        CoverPage.append(image)
        CoverPage.append(Spacer(1, 18))
        CoverPage.append(Paragraph("CONFIDENTIAL", headline_style))
        # paragraph = Paragraph(
        #     f"Intended for: {recipient}, Title IX Coordinator", subtitle_style)
        # CoverPage.append(paragraph)
        CoverPage.append(PageBreak())
        return CoverPage

    # entrypoints 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:28,代码来源:api.py

示例10: _getCaptionPara

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

示例11: convertSourceFiles

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def convertSourceFiles(filenames):
    "Helper function - makes minimal PDF document"

    from reportlab.platypus import Paragraph, SimpleDocTemplate, Spacer, XPreformatted
    from reportlab.lib.styles import getSampleStyleSheet
    styT=getSampleStyleSheet()["Title"]
    styC=getSampleStyleSheet()["Code"]
    doc = SimpleDocTemplate("pygments2xpre.pdf")
    S = [].append
    for filename in filenames:
        S(Paragraph(filename,style=styT))
        src = open(filename, 'r').read()
        fmt = pygments2xpre(src)
        S(XPreformatted(fmt, style=styC))
    doc.build(S.__self__)
    print 'saved pygments2xpre.pdf' 
开发者ID:gltn,项目名称:stdm,代码行数:18,代码来源:pygments2xpre.py

示例12: gather_elements

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def gather_elements(self, client, node, style):
        if isinstance(node.parent, docutils.nodes.sidebar):
            elements = [
                Paragraph(client.gen_pdftext(node), client.styles['sidebar-subtitle'])
            ]
        elif isinstance(node.parent, docutils.nodes.document):
            # elements = [Paragraph(client.gen_pdftext(node),
            # client.styles['subtitle'])]
            # The visible output is now done by the cover template
            elements = []
            # FIXME: looks like subtitles don't have a rawsource like
            # titles do.
            # That means that literals and italics etc in subtitles won't
            # work.
            client.doc_subtitle = getattr(node, 'rawtext', node.astext()).strip()
        else:
            elements = node.elements  # FIXME Can we get here???
        return elements 
开发者ID:rst2pdf,项目名称:rst2pdf,代码行数:20,代码来源:genelements.py

示例13: _put_lines

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def _put_lines(self, doc, canvas, lines, x, y, width, style, font_size, leading):
        """
        Place these lines, with given leading
        """
        ypos = y
        for line in lines:
            line = str(line).translate(doc.digit_trans)
            p = Paragraph(line, style)
            _,h = p.wrap(width, 1*inch)
            p.drawOn(canvas, x, ypos-h)
            ypos -= h + leading 
开发者ID:sfu-fas,项目名称:coursys,代码行数:13,代码来源:letters.py

示例14: add_paragraph

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def add_paragraph(self, text):
        "Add a paragraph (represented as a string) to the letter: used by OfficialLetter.add_letter"
        if text.startswith('||'):
            # it's our table microformat
            lines = text.split('\n')
            cells = [line.split('|')[2:] for line in lines] # [2:] effectively strips the leading '||'
            self.flowables.append(Table(cells, style=self.table_style))
        else:
            [self.flowables.append(Paragraph(line, self.content_style)) for line in text.split("\n")]
        self.flowables.append(Spacer(1, self.line_height)) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:12,代码来源:letters.py

示例15: _contents

# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Paragraph [as 别名]
def _contents(self, memo):
        """
        Produce a list of Flowables to form the body of the memo
        """
        contents = []
        space_height = self.line_height
        # the header block
        contents.append(MemoHead(key='Attention', value=', '.join(self.to_addr_lines), bold=True))
        contents.append(MemoHead(key='From', value=', '.join(self.from_name_lines)))
        contents.append(MemoHead(key='Re', value=self.subject[0]))
        for subjectline in self.subject[1:]:
            contents.append(MemoHead(key='', value=subjectline))
        contents.append(MemoHead(key='Date', value=self.date.strftime('%B %d, %Y').replace(' 0', ' ')))
        contents.append(Spacer(1, 2*space_height))

        # insert each paragraph
        for f in self.flowables:
            contents.append(f)
            #contents.append(Spacer(1, space_height))

        # the CC lines
        if self.cc_lines:
            data = []
            for cc in self.cc_lines:
                data.append(['', Paragraph(cc, self.content_style)])

            cc = Paragraph('cc:', self.content_style)
            data[0][0] = cc

            cc_table = Table(data, colWidths=[0.3 * inch, 5 * inch])
            cc_table.hAlign = "LEFT"
            cc_table.setStyle(TableStyle(
                [('LEFTPADDING', (0, 0), (-1, -1), 0),
                 ('RIGHTPADDING', (0, 0), (-1, -1), 0),
                 ('TOPPADDING', (0, 0), (-1, -1), 0),
                 ('BOTTOMPADDING', (0, 0), (-1, -1), 0)]))

            contents.append(cc_table)
        return contents 
开发者ID:sfu-fas,项目名称:coursys,代码行数:41,代码来源:letters.py


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