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


Python doctemplate.SimpleDocTemplate类代码示例

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


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

示例1: prepareDoc

    def prepareDoc(self):
        rightMargin, leftMargin, topMargin, bottomMargin = 72, 72, 72, 18

        doc = SimpleDocTemplate(None, pagesize=A4,
            rightMargin=rightMargin, leftMargin=leftMargin,
            topMargin=topMargin, bottomMargin=bottomMargin)

        frameWidth = doc.width / 2
        headerHeight = 50
        userInfoHeight = 228
        itemsFrameHeight = doc.height - userInfoHeight - headerHeight

        header = Frame(leftMargin, doc.height, doc.width, headerHeight)
        column1 = Frame(leftMargin, doc.height - userInfoHeight,
                        frameWidth, userInfoHeight)
        column2 = Frame(leftMargin + frameWidth, doc.height - userInfoHeight,
                        frameWidth, userInfoHeight)
        items = Frame(leftMargin,
                      doc.height - userInfoHeight - itemsFrameHeight,
                      doc.width, itemsFrameHeight)

        template = PageTemplate(frames=[header, column1, column2, items])
        doc.addPageTemplates(template)

        half = doc.width / 2
        self.columnWidths = (half / 2, half / 2)

        self.itemColumnWidths = (
            (float(2) / 3) * doc.width,
            (float(1) / 3) * doc.width * (float(1) / 3),
            (float(1) / 3) * doc.width * (float(2) / 3)
        )

        return doc
开发者ID:vencax,项目名称:django-invoices,代码行数:34,代码来源:pdfgen.py

示例2: pdf_private_invoice

def pdf_private_invoice(modeladmin, request, queryset):
    # Create the HttpResponse object with the appropriate PDF headers.
    response = HttpResponse(content_type='application/pdf')
    # Append invoice number and invoice date
    if len(queryset) != 1:
        _file_name = '-'.join([a.invoice_number for a in queryset.order_by("invoice_number")])
        response['Content-Disposition'] = 'attachment; filename="invoice%s.pdf"' %(_file_name.replace(" ", "")[:150])
    else:
        response['Content-Disposition'] = 'attachment; filename="invoice-%s-%s-%s-part-personnelle.pdf"' %(queryset[0].patient.name, 
                                                                                          queryset[0].invoice_number, 
                                                                                          queryset[0].invoice_date.strftime('%d-%m-%Y'))
    
    elements = []
    doc = SimpleDocTemplate(response, rightMargin=2*cm, leftMargin=2 * cm, topMargin=1 * cm, bottomMargin=1*cm)
    
    recapitulatif_data = []

    for qs in queryset.order_by("invoice_number"):
        dd = [qs.prestations.all().order_by("date", "carecode__gross_amount")[i:i+20] for i in range(0, len(qs.prestations.all()), 20)]
        for _prestations in dd:
            _inv = qs.invoice_number + (("" + str(dd.index(_prestations) + 1) + qs.invoice_date.strftime('%m%Y')) if len(dd) > 1 else "")
            _result = _build_invoices(_prestations, 
                                      _inv, 
                                      qs.invoice_date,
                                      qs.medical_prescription_date, 
                                      qs.accident_id, 
                                      qs.accident_date )
                                      
            elements.extend(_result["elements"])
            recapitulatif_data.append((_result["invoice_number"], _result["patient_name"], _result["invoice_amount"]))
            elements.append(PageBreak())
    #elements.extend(_build_recap(recapitulatif_data))
    doc.build(elements)
    return response
开发者ID:opefitoo,项目名称:nurse,代码行数:34,代码来源:action_private_participation.py

示例3: make_output

 def make_output( me, filename, pagesize=None, layout =None, view_descr =None):
     from reportlab.platypus.doctemplate import SimpleDocTemplate
     story = me.make_embeddable_output( layout, view_descr)
     doc_args = me.get_doc_args( pagesize)
     doc = SimpleDocTemplate( filename, **doc_args)
     doc.build( story)
     return doc # always True
开发者ID:svilendobrev,项目名称:reporter,代码行数:7,代码来源:pdf.py

示例4: renderToc

    def renderToc(self, tocpath, toc_entries):
        doc = SimpleDocTemplate(tocpath, pagesize=(pdfstyles.page_width, pdfstyles.page_height))
        elements = []
        elements.append(Paragraph(_('Contents'), pdfstyles.heading_style(mode='chapter', text_align='left')))
        toc_table =[]
        styles = []
        col_widths = self._getColWidths()
        for row_idx, (lvl, txt, page_num) in enumerate(toc_entries):
            if lvl == 'article':
                page_num = str(page_num)
            elif lvl == 'chapter':
                page_num = '<b>%d</b>' % page_num
                styles.append(('TOPPADDING', (0, row_idx), (-1, row_idx), 10))
            elif lvl == 'group':
                page_num = ' '
                styles.append(('TOPPADDING', (0, row_idx), (-1, row_idx), 10))

            toc_table.append([
                Paragraph(txt, pdfstyles.text_style(mode='toc_%s' % str(lvl), text_align='left')),
                Paragraph(page_num, pdfstyles.text_style(mode='toc_article', text_align='right'))
                ])
        t = Table(toc_table, colWidths=col_widths)
        t.setStyle(styles)
        elements.append(t)
        doc.build(elements)
开发者ID:ingob,项目名称:mwlib.rl,代码行数:25,代码来源:toc.py

示例5: testRml

def testRml():
    from reportlab.platypus.doctemplate import SimpleDocTemplate
    from reportlab.platypus.flowables import Spacer
    from reportlab.lib.randomtext import randomText

    templ = SimpleDocTemplate('doclet_output.pdf')

    #need a style
    story = []
    normal = ParagraphStyle('normal')
    normal.firstLineIndent = 18
    normal.spaceBefore = 6

    para = Paragraph("Test of doclets.  You should see a little table with a reversed word.", normal)
    story.append(para)

    story.append(Spacer(36,36))
                 
    theDoclet = TestReverseDoclet()
    story.append(theDoclet.asFlowable())
    
    for i in range(5):
        para = Paragraph(randomText(), normal)
        story.append(para)



    templ.build(story)    

    print('saved doclet_output.pdf')
开发者ID:AndyKovv,项目名称:hostel,代码行数:30,代码来源:doclet.py

示例6: test1

 def test1(self):
     """Ilpo Nyyss\xf6nen posted this broken test"""
     normalStyle = ParagraphStyle(name="normal")
     keepStyle = ParagraphStyle(name="keep", keepWithNext=True)
     content = [Paragraph("line 1", keepStyle), Indenter(left=1 * cm), Paragraph("line 2", normalStyle)]
     doc = SimpleDocTemplate(outputfile("test_platypus_breaking1.pdf"))
     doc.build(content)
开发者ID:jameshickey,项目名称:ReportLab,代码行数:7,代码来源:test_platypus_breaking.py

示例7: print_rep

def print_rep(uid):
    registerFont(TTFont("DroidSans", "DroidSans.ttf"))

    pdf = StringIO()

    doc = SimpleDocTemplate(pdf, pagesize=A4)
    elements = []
    style = getSampleStyleSheet()
    style.add(ParagraphStyle(name="Left", alignment=TA_LEFT, fontName="DroidSans", fontSize=12))
    style.add(ParagraphStyle(name="Right", alignment=TA_RIGHT, fontName="DroidSans", fontSize=12))
    if uid == 0:
        u = User.query.all()
        for o in u:
            elements.append(Paragraph(u"%s %s %s" % (o.name, o.email, o.progress), style["Left"]))
    else:
        u = User.query.get(uid)
        elements.append(Paragraph(u"%s %s %s" % (u.name, u.email, u.progress), style["Left"]))

    doc.build(elements)
    pdf_file = pdf.getvalue()
    pdf.close()
    response = make_response(pdf_file)

    response.headers["Content-Disposition"] = "attachment; filename='pdf_user.pdf"
    response.mimetype = "application/pdf"
    return response
开发者ID:nisiotis,项目名称:flask_app,代码行数:26,代码来源:users.py

示例8: func

 def func(val):
     story = [
             DocAssert(val,'this should fail'),
             DocPara('repr(doc._nameSpace)',escape=True),
             ]
     doc = SimpleDocTemplate(outputfile('test_doc_programming_asserts.pdf'))
     doc.build(story)
开发者ID:nickpack,项目名称:reportlab,代码行数:7,代码来源:test_platypus_programming.py

示例9: renderToc

    def renderToc(self, tocpath, toc_entries, rtl):
        doc = SimpleDocTemplate(tocpath, pagesize=(pdfstyles.page_width, pdfstyles.page_height))
        elements = []
        elements.append(
            Paragraph(_("Contents"), pdfstyles.heading_style(mode="chapter", text_align="left" if not rtl else "right"))
        )
        toc_table = []
        styles = []
        col_widths = self._getColWidths()
        for row_idx, (lvl, txt, page_num) in enumerate(toc_entries):
            if lvl == "article":
                page_num = str(page_num)
            elif lvl == "chapter":
                page_num = "<b>%d</b>" % page_num
                styles.append(("TOPPADDING", (0, row_idx), (-1, row_idx), 10))
            elif lvl == "group":
                page_num = " "
                styles.append(("TOPPADDING", (0, row_idx), (-1, row_idx), 10))

            toc_table.append(
                [
                    Paragraph(txt, pdfstyles.text_style(mode="toc_%s" % str(lvl), text_align="left")),
                    Paragraph(page_num, pdfstyles.text_style(mode="toc_article", text_align="right")),
                ]
            )
        t = Table(toc_table, colWidths=col_widths)
        t.setStyle(styles)
        elements.append(t)
        doc.build(elements)
开发者ID:pediapress,项目名称:mwlib.rl,代码行数:29,代码来源:toc.py

示例10: email_admin

def email_admin(self, subject, text, sorted_self):

    site_name = SiteSetting.objects.all().first().site_name

    styleSheet = getSampleStyleSheet()

    # Send the admin a PDF of client details
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="clientDetails.pdf"'

    string_buffer = StringIO()

    new_pdf = []
    header = Paragraph(site_name + " Attendee Details", styleSheet['Heading1'])
    new_pdf.append(header)

    for element in sorted_self:
        new_pdf.append(Paragraph(element[0], styleSheet['Heading3']))
        new_pdf.append(Paragraph(element[1], styleSheet['BodyText']))
        new_pdf.append(Spacer(1, 2))

    doc = SimpleDocTemplate(string_buffer)
    doc.build(new_pdf)
    pdf = string_buffer.getvalue()
    string_buffer.close()

    msg = EmailMultiAlternatives(subject, text, EMAIL_HOST_USER, [EMAIL_HOST_USER])
    msg.attach(self.first_name + self.last_name + site_name + ".pdf", pdf, "application/pdf")
    msg.send(fail_silently=True)
开发者ID:ASRANetOrg,项目名称:NUPP,代码行数:29,代码来源:email_functionality.py

示例11: email_admin

def email_admin(self, subject, text, sorted_self):

    styleSheet = getSampleStyleSheet()

    # Send the admin a PDF of client details
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="clientDetails.pdf"'

    string_buffer = StringIO()

    new_pdf = []
    header = Paragraph("DISS Attendee Details", styleSheet['Heading1'])
    new_pdf.append(header)

    for element in sorted_self:
        new_pdf.append(Paragraph(element[0], styleSheet['Heading3']))
        new_pdf.append(Paragraph(element[1], styleSheet['BodyText']))
        new_pdf.append(Spacer(1, 2))

    doc = SimpleDocTemplate(string_buffer)
    doc.build(new_pdf)
    pdf = string_buffer.getvalue()
    string_buffer.close()

    msg = EmailMultiAlternatives(subject, text, "[email protected]", ["[email protected]"])
    msg.attach(self.first_name + self.last_name + "DISS.pdf", pdf, "application/pdf")
    msg.send()
开发者ID:ASRANetOrg,项目名称:DISS,代码行数:27,代码来源:email_functionality.py

示例12: print_rep

def print_rep(uid):
    registerFont(TTFont('DroidSans', 'DroidSans.ttf'))

    pdf = StringIO()

    doc = SimpleDocTemplate(pdf, pagesize=A4)
    elements = []
    style = getSampleStyleSheet()
    style.add(ParagraphStyle(name='Header', alignment=TA_LEFT,
                             fontName='DroidSans',
                             fontSize=14, leading=16))
    style.add(ParagraphStyle(name='Left', alignment=TA_LEFT,
                             fontName='DroidSans',
                             fontSize=12))
    style.add(ParagraphStyle(name='Right', alignment=TA_RIGHT,
                             fontName='DroidSans',
                             fontSize=12))
    if uid == 0:
        elements.append(Paragraph(u'<u>Users List</u>', style['Header']))
        u = User.query.all()     
        for i, o in enumerate(u):
            elements.append(Paragraph(u'%s. %s %s %s' % (i+1, o.name, o.email, o.progress), style['Left']))
    else:
        u = User.query.get(uid)
        elements.append(Paragraph(u'%s %s %s' % (u.name, u.email, u.progress), style['Header']))

    doc.build(elements)
    pdf_file = pdf.getvalue()
    pdf.close()
    response = make_response(pdf_file)

    response.headers['Content-Disposition'] = "attachment; filename='pdf_user.pdf"
    response.mimetype = 'application/pdf'
    return response
开发者ID:nisiotis,项目名称:flask_app_2,代码行数:34,代码来源:__init__.py

示例13: relatorio_documento_base

def relatorio_documento_base(request):
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="srfa02.pdf"'

    doc = SimpleDocTemplate(response, rightMargin=72,leftMargin=72, topMargin=72,bottomMargin=18)
    
    Story=[]
    magName = "Pythonista"
    issueNum = 12
    subPrice = "99.00"
    limitedDate = "03/05/2010"
    freeGift = "tin foil hat"
     
    formatted_time = time.ctime()
    full_name = "Mike Driscoll"
    address_parts = ["411 State St.", "Marshalltown, IA 50158"]
     
     
    styles=getSampleStyleSheet()
    styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
    ptext = '<font size=12>%s</font>' % formatted_time
     
    Story.append(Paragraph(ptext, styles["Normal"]))
    Story.append(Spacer(1, 12))
     
    # Create return address
    ptext = '<font size=12>%s</font>' % full_name
    Story.append(Paragraph(ptext, styles["Normal"]))       
    for part in address_parts:
        ptext = '<font size=12>%s</font>' % part.strip()
        Story.append(Paragraph(ptext, styles["Normal"]))   
     
    Story.append(Spacer(1, 12))
    ptext = '<font size=12>Dear %s:</font>' % full_name.split()[0].strip()
    Story.append(Paragraph(ptext, styles["Normal"]))
    Story.append(Spacer(1, 12))
     
    ptext = '<font size=12>We would like to welcome you to our subscriber base for %s Magazine! \
            You will receive %s issues at the excellent introductory price of $%s. Please respond by\
            %s to start receiving your subscription and get the following free gift: %s.</font>' % (magName, 
                                                                                                    issueNum,
                                                                                                    subPrice,
                                                                                                    limitedDate,
                                                                                                    freeGift)
    Story.append(Paragraph(ptext, styles["Justify"]))
    Story.append(Spacer(1, 12))
     
     
    ptext = '<font size=12>Thank you very much and we look forward to serving you.</font>'
    Story.append(Paragraph(ptext, styles["Justify"]))
    Story.append(Spacer(1, 12))
    ptext = '<font size=12>Sincerely,</font>'
    Story.append(Paragraph(ptext, styles["Normal"]))
    Story.append(Spacer(1, 48))
    ptext = '<font size=12>Ima Sucker</font>'
    Story.append(Paragraph(ptext, styles["Normal"]))
    Story.append(Spacer(1, 12))
    doc.build(Story)
    
    return response
开发者ID:waldenilson,项目名称:TerraLegal,代码行数:60,代码来源:relatorio_base.py

示例14: Naryad_Zakaz_PrintForm

def Naryad_Zakaz_PrintForm(ul,dom,date,date_str):
	day_task = GetListTaskDom(ul,dom,date)

	data = [['№пп','Наименование\nработ','Подъезд','Квартира','Примечание'],
		]
	
	n = 1
	

	elements = []

	### --- Имя файла для вывода ---
	FILE_NAME = os.getcwd()+'/tmp/'+str(time.time())+'.pdf'

	Font = ttfonts.TTFont('Arial','font/arial.ttf')
	Font2 = ttfonts.TTFont('ArialBD','font/arialbd.ttf')

	pdfmetrics.registerFont(Font)
	pdfmetrics.registerFont(Font2)

	style = getSampleStyleSheet()
	style.add(ParagraphStyle(name='Disp',wordWrap=True,fontName='ArialBD',fontSize=12,spaceAfter=5*mm,spaceBefore=5*mm,alignment=2))
	style.add(ParagraphStyle(name='Naryad_Zakaz',wordWrap=True,fontName='ArialBD',fontSize=14,spaceAfter=5*mm,spaceBefore=5*mm,alignment=1))
	style.add(ParagraphStyle(name='DateDom',wordWrap=True,fontName='ArialBD',fontSize=12,spaceAfter=5*mm,spaceBefore=5*mm,alignment=1))
	style.add(ParagraphStyle(name='Table',wordWrap=True,fontName='Arial',fontSize=11,spaceAfter=1*mm,spaceBefore=1*mm,alignment=0))

	doc = SimpleDocTemplate(FILE_NAME,topMargin=10*mm,bottomMargin=10*mm,leftMargin=10*mm,rightMargin=10*mm)



	for item in day_task:
	    row = [n,Paragraph(item[9],style["Table"]),item[13],item[12],'']
	    n = n + 1
	    data.append(row)




	t=Table(data)
	t.setStyle([('FONTNAME',(0,0),(-1,0),'ArialBD'),
		    ('FONTSIZE',(0,0),(-1,0),11),
		    ('ALIGN',(0,0),(-1,0),'CENTER'),
		    ('VALIGN',(0,0),(-1,0),'MIDDLE'),
		    ('GRID',(0,0),(-1,-1),0.25,colors.black),
		    ('FONTNAME',(0,1),(-1,-1),'Arial'),
		    ('FONTSIZE',(0,1),(-1,-1),11),
		    ('ALIGN',(0,1),(0,-1),'CENTER'),
		    ('ALIGN',(1,1),(-1,-1),'LEFT'),
		    ('VALIGN',(0,1),(-1,-1),'TOP'),
		    ])


	elements.append(Paragraph('Наряд-Заказ',style["Naryad_Zakaz"]))
	elements.append(Paragraph('на выполнение работ по адресу: '+ul+' дом '+dom+' на '+date_str,style["DateDom"]))
	elements.append(t)
	elements.append(Paragraph('Диспетчер ООО "Артэкс"',style["Disp"]))

	doc.build(elements)
	os.system(PDFVIEW+" "+FILE_NAME+" &")
开发者ID:v-komarov,项目名称:psv3,代码行数:59,代码来源:PrintTask.py

示例15: render

 def render(self):
     buffer = cStringIO.StringIO()
     doc_template_args = self.theme.doc_template_args()
     doc = SimpleDocTemplate(buffer, title=self.title, author=self.author,
         **doc_template_args)
     doc.build(self.story)
     pdf = buffer.getvalue()
     buffer.close()
     return pdf
开发者ID:akurex,项目名称:web2py-csv-process-and-pdf-generator,代码行数:9,代码来源:__init__.py


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