Python reportlab.lib.pagesizes 模块,landscape() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用reportlab.lib.pagesizes.landscape()

项目:pandas-100    作者:deeplook    | 项目源码 | 文件源码
def make_cards_file(path, cover, items, verbose=False):
    "Make cards with as many items as possible, shrinking too big ones."

    cardSize = (9.1 * cm, 5.9 * cm)
    cards = []
    for q, a in make_cards_platypus(cardSize, cover, items, verbose=verbose):
        cards += [q, a]

    outPath = os.path.splitext(path)[0] + ".pdf"
    pageSize = landscape(A4)
    layout(outPath, cards, pageSize, cardSize, frame=True, debug=False)

    if verbose:
        print("wrote %s" % outPath)
项目:tambox    作者:joseamaya    | 项目源码 | 文件源码
def __init__(self, pagesize, desde, hasta, almacen, grupos):
        self.desde = desde
        self.hasta = hasta
        self.almacen = almacen
        self.grupos = grupos
        self.total_paginas = 0
        self.buffer = BytesIO()
        if pagesize == 'A4':
            self.pagesize = landscape(A4)
        elif pagesize == 'Letter':
            self.pagesize = letter
        self.width, self.height = self.pagesize
项目:story-card-painter    作者:Cloudist    | 项目源码 | 文件源码
def __init__(self, input_path, output_path, fontname, fontpath,
                 is_landscape=False, padding=20):
        if is_landscape:
            self.canvas = canvas.Canvas(output_path, pagesize=landscape(A4))
            self.page_height, self.page_width = A4
        else:
            self.canvas = canvas.Canvas(output_path)
            self.page_width, self.page_height = A4

        self.padding = padding

        self.page = 0
        self.story_count = 0

        self.black = 0.3
        self.gray = 0.5
        self.lite_gray = 0.95
        self.white = 1

        if fontname and fontpath:
            pdfmetrics.registerFont(TTFont(fontname, fontpath))
            self.fontname = fontname
        else:
            self.fontname = 'Helvetica'

        self.load_backlog(input_path)
项目:certificate    作者:gileno    | 项目源码 | 文件源码
def main():
    context = {
        'instructor': INSTRUCTOR,
        'course': COURSE,
        'student': STUDENT,
        'hours': HOURS,
    }
    styles = getSampleStyleSheet()
    styles.add(
        ParagraphStyle(
            name='Justify', alignment=TA_JUSTIFY, fontSize=16, leading=22
        )
    )
    elements = []
    certificate_txt = render(TEXT_PATH, context)
    paragraphs = certificate_txt.split(os.linesep)
    elements.append(Spacer(1, 50))
    for p in paragraphs:
        elements.append(Paragraph(p, styles['Justify']))
        elements.append(Spacer(1, 16))

    certificate = tempfile.NamedTemporaryFile()
    doc = SimpleDocTemplate(certificate, topMargin=3 * cm, bottomMargin=0)
    doc.pagesize = landscape(A4)
    doc.build(elements)

    output = PdfFileWriter()
    template_file = open('template.pdf', 'rb')
    input1 = PdfFileReader(template_file)
    page1 = input1.getPage(0)
    content = PdfFileReader(certificate)
    page1.mergePage(content.getPage(0))
    output.addPage(page1)
    save_file = open(SAVE_AS, 'wb')
    output.write(save_file)
    print('Certificado gerado com sucesso em %s' % SAVE_AS)