コード例 #1
0
ファイル: story.py プロジェクト: alecordev/reportlab-examples
def go():
    doc = SimpleDocTemplate("phello.pdf")
    doc.pagesize = (6 * inch, 4 * inch)
    doc.leftMargin = 0.25 * inch
    doc.bottommargin = 0.25 * inch
    # doc.height=3.75*inch
    # doc.width=5.75*inch
    doc.height = 4 * inch
    doc.width = 6 * inch
    Story = []
    style = styles["Normal"]
    for i in range(3):
        bogustext = ("This is Paragraph number %s. " % i) * 2
        p = Paragraph(bogustext, style)
        # p = Paragraph(bogustext)
        Story.append(p)
        # Story.append(Spacer(1,0.2*inch))
    l = []
    for x in range(3):
        l.append(["row%i col1" % x, "row%i col2" % i])
    Story.append(Table(l))
    Story.append(Paragraph("Hello", styles["Title"]))
    # Story.append(Paragraph("Hello"))
    #doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)
    doc.build(Story)
コード例 #2
0
ファイル: run.py プロジェクト: HiddenBeginner/images2pdf
def get_document(args, rightMargin=2.5*mm, leftMargin = 2.5*mm, topMargin = 2.5*mm, bottomMargin = 2.5*mm):
    save_path = f'{args.title}.pdf'
    doc = SimpleDocTemplate(save_path)
    doc.title = args.title

    doc.rightMargin = rightMargin
    doc.leftMargin = leftMargin
    doc.topMargin = topMargin
    doc.bottomMargin = bottomMargin
    doc.width = A4[0] - (doc.rightMargin + doc.leftMargin)
    doc.height = A4[1] - (doc.topMargin + doc.bottomMargin)

    return doc
コード例 #3
0
def go():
    doc = SimpleDocTemplate("phello.pdf")
    doc.pagesize=(6*inch,4*inch)
    doc.leftMargin=0.25*inch
    doc.bottommargin=0.25*inch
    #doc.height=3.75*inch
    #doc.width=5.75*inch
    doc.height=4*inch
    doc.width=6*inch
    Story = []
    style = styles["Normal"]
    for i in range(3):
        bogustext = ("This is Paragraph number %s. " % i) *2
        p = Paragraph(bogustext, style)
        Story.append(p)
        #Story.append(Spacer(1,0.2*inch))
    l=[]
    for x in range(3):
        l.append(["row%i col1" % x, "row%i col2" % i])
    Story.append(Table(l))
    Story.append(Paragraph("Hello", styles["Title"]))
    #doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)
    doc.build(Story)