Python reportlab.platypus.PageBreak() Examples

The following are 6 code examples of reportlab.platypus.PageBreak(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module reportlab.platypus , or try the search function .
Example #1
Source File: api.py    From callisto-core with GNU Affero General Public License v3.0 6 votes vote down vote up
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 
Example #2
Source File: report.py    From nanopype with MIT License 5 votes vote down vote up
def add_summary(self, summary_table=[]):
        self.story.append(Spacer(1, 8*cm))
        self.story.append(Paragraph("Sequencing Report", self.title_style))
        style = self.normal_style
        style.alignment = TA_CENTER
        self.story.append(Paragraph("{}".format(self.tag), style))
        self.story.append(Spacer(1, 4*cm))
        summary_table_style = [('ALIGN',(0,0),(0,-1),'RIGHT'),
                               ('ALIGN',(1,0),(1,-1),'LEFT')]
        if len(summary_table):
            self.story.append(Table(summary_table, style=summary_table_style))
        self.story.append(Spacer(1, 1*cm))
        self.story.append(Paragraph("Nanopype {}".format(self.version), style))
        self.story.append(PageBreak()) 
Example #3
Source File: report.py    From flask-restful-example with MIT License 5 votes vote down vote up
def pdf_write(generated_pdf_path):
    """
    生成pdf
    :return:
    """
    # 增加的字体,支持中文显示,需要自行下载支持中文的字体
    font_path = current_app.config.get("SIM_SUN")

    pdfmetrics.registerFont(TTFont('SimSun', os.path.join(font_path, 'SimSun.ttf')))
    styles = getSampleStyleSheet()
    styles.add(ParagraphStyle(fontName='SimSun', name='SimSun', leading=20, fontSize=12))
    data = list()
    # 添加一段文字
    paragraph = paragraph_model("测试添加一段文字")
    data.append(paragraph)
    data.append(PageBreak())  # 分页标识
    # 添加table和图片
    table = table_model()
    data.append(table)
    data.append(PageBreak())  # 分页标识
    img = image_model()
    data.append(img)

    # 设置生成pdf的名字和编剧
    pdf = SimpleDocTemplate(generated_pdf_path, rightMargin=0, leftMargin=0, topMargin=40, bottomMargin=0, )
    # 设置pdf每页的大小
    pdf.pagesize = (9 * inch, 10 * inch)

    pdf.multiBuild(data)
    return generated_pdf_path 
Example #4
Source File: report_delivery.py    From callisto-core with GNU Affero General Public License v3.0 5 votes vote down vote up
def report_pages(self, reports: list):
        pages = []
        for report in reports:
            pages.extend(self.report_page(report))
            pages.append(PageBreak())
        return pages 
Example #5
Source File: report_delivery.py    From callisto-core with GNU Affero General Public License v3.0 5 votes vote down vote up
def match_pages(self, match_report_and_report_content: list):
        pages = []
        for (match_report, match_content) in match_report_and_report_content:
            pages.extend(self.match_page(match_report, match_content))
            pages.append(PageBreak())
        return pages 
Example #6
Source File: report_delivery.py    From callisto-core with GNU Affero General Public License v3.0 5 votes vote down vote up
def cover_page(self):
        return [
            Image(
                os.path.join(settings.BASE_DIR, api.NotificationApi.logo_path),
                3 * inch,
                3 * inch,
            ),
            Spacer(1, 18),
            Paragraph("CONFIDENTIAL", self.headline_style),
            Spacer(1, 30),
            Spacer(1, 40),
            Paragraph(self.title, self.subtitle_style),
            Spacer(1, 40),
            PageBreak(),
        ]