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


Python BaseDocTemplate.build方法代码示例

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


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

示例1: build

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
    def build(self, flowables, onFirstPage=_doNothing, onLaterPages=_doNothing, canvasmaker=canvas.Canvas):
        """build the document using the flowables.  Annotate the first page using the onFirstPage
               function and later pages using the onLaterPages function.  The onXXX pages should follow
               the signature

                  def myOnFirstPage(canvas, document):
                      # do annotations and modify the document
                      ...

               The functions can do things like draw logos, page numbers,
               footers, etcetera. They can use external variables to vary
               the look (for example providing page numbering or section names).
        """
        self._calc()  # in case we changed margins sizes etc
        frameT = Frame(self.leftMargin, self.bottomMargin, self.width, self.height, id="normal")
        self.addPageTemplates(
            [
                PageTemplate(id="First", frames=frameT, onPage=onFirstPage, pagesize=self.pagesize),
                PageTemplate(id="Later", frames=frameT, onPage=onLaterPages, pagesize=self.pagesize),
            ]
        )
        if onFirstPage is _doNothing and hasattr(self, "onFirstPage"):
            self.pageTemplates[0].beforeDrawPage = self.onFirstPage
        if onLaterPages is _doNothing and hasattr(self, "onLaterPages"):
            self.pageTemplates[1].beforeDrawPage = self.onLaterPages
        BaseDocTemplate.build(self, flowables, canvasmaker=canvasmaker)
开发者ID:skidzo,项目名称:mubosym,代码行数:28,代码来源:autoreport.py

示例2: export

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
def export(listino, luogoDiRiferimento):
    response = http.HttpResponse(content_type='application/pdf')
    width, height = portrait(A4)

    pageTemplates = [
        PageTemplate(id='Listino', onPage=onPageListino),
    ]

    doc = BaseDocTemplate(
        response,
        pagesize=(width, height),
        leftMargin=1 * cm,
        rightMargin=1 * cm,
        bottomMargin=1.5 * cm,
        topMargin=1 * cm,
        showBoundary=test,
        pageTemplates=pageTemplates,
    )

    doc.listino = listino  # arricchisco il doc

    righe_prezzo = listino.prezzolistino_set.all()

    story = []

    listinoEsclusivo = getTabellaListino(doc, righe_prezzo, 'T', luogoDiRiferimento)
    if listinoEsclusivo:
        title = Paragraph("SERVIZIO TAXI ESCLUSIVO", normalStyle)
        story.append(title)
        story.append(listinoEsclusivo)

    listinoCollettivo = getTabellaListino(doc, righe_prezzo, 'C', luogoDiRiferimento)
    if listinoEsclusivo and listinoCollettivo:
        story.append(Spacer(1, 1.5 * cm))
    if listinoCollettivo:
        title = Paragraph("SEVIZIO COLLETIVO MINIBUS", normalStyle)
        story.append(KeepTogether([title, listinoCollettivo]))

    if not listinoCollettivo and not listinoEsclusivo:
        story.append(
            Paragraph("Non abbiamo nessuna corsa specificata nel listino.", normal_style)
        )

    # footer
    footer_style = ParagraphStyle(name='Justify', alignment=TA_JUSTIFY, fontSize=8)
    # footer_height = 0
    if LISTINO_FOOTER:
        note_finali_lines = [LISTINO_FOOTER]
        story.append(Spacer(1, 1 * cm))
        note_finali = Paragraph("<br/>".join(note_finali_lines),
                                footer_style)
        # note_finali.wrap(width - doc.rightMargin - doc.leftMargin, 5 * cm)
        # note_finali.drawOn(canvas, doc.leftMargin, doc.bottomMargin)
        # footer_height = note_finali.height
        story.append(note_finali)

    doc.build(story, canvasmaker=NumberedCanvas)
    return response
开发者ID:dariosky,项目名称:tam,代码行数:60,代码来源:pdfListino.py

示例3: build

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
    def build(self, flowables, firstPageTemplate=_doNothing, laterPageTemplate=_doNothing):
        """Custom build method to separate first page and later page templates.

        """
        self._calc() # in case we changed margin sizes

        if firstPageTemplate is _doNothing and hasattr(self, 'firstPageTemplate'):
            self.pageTemplates[0].beforeDrawPage = self.firstPageTemplate
        if laterPageTemplate is _doNothing and hasattr(self, 'laterPageTemplate'):
            self.pageTemplates[1].beforeDrawPage = self.laterPageTemplate

        BaseDocTemplate.build(self, flowables)
开发者ID:CreativeCreationsLLC,项目名称:Python,代码行数:14,代码来源:writer.py

示例4: __init__

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
    def __init__(self, dictValeurs={}, dictOptions={}, IDmodele=None, ouverture=True, nomFichier=None):
        """ Impression """
        global DICT_VALEURS, DICT_OPTIONS
        DICT_VALEURS = dictValeurs
        DICT_OPTIONS = dictOptions
        
        # Initialisation du document
        if nomFichier == None :
            nomDoc = FonctionsPerso.GenerationNomDoc("LOCATIONS", "pdf")
        else :
            nomDoc = nomFichier
        doc = BaseDocTemplate(nomDoc, pagesize=TAILLE_PAGE, showBoundary=False)
        
        # Mémorise le ID du modèle
        modeleDoc = DLG_Noedoc.ModeleDoc(IDmodele=IDmodele)
        doc.modeleDoc = modeleDoc
        
        # Importe le template de la première page
        doc.addPageTemplates(MyPageTemplate(pageSize=TAILLE_PAGE, doc=doc))
        
        story = []
        styleSheet = getSampleStyleSheet()
        h3 = styleSheet['Heading3']
        styleTexte = styleSheet['BodyText'] 
        styleTexte.fontName = "Helvetica"
        styleTexte.fontSize = 9
        styleTexte.borderPadding = 9
        styleTexte.leading = 12
        
        # ----------- Insertion du contenu des frames --------------
        listeLabels = []
        for IDlocation, dictValeur in dictValeurs.iteritems() :
            listeLabels.append((dictValeur["{FAMILLE_NOM}"], IDlocation))
        listeLabels.sort() 
        
        for labelDoc, IDlocation in listeLabels :
            dictValeur = dictValeurs[IDlocation]
            if dictValeur["select"] == True :
                
                story.append(DocAssign("IDlocation", IDlocation))
                nomSansCivilite = dictValeur["{FAMILLE_NOM}"]
                story.append(Bookmark(nomSansCivilite, str(IDlocation)))

                # Saut de page
                story.append(PageBreak())
        
        # Finalisation du PDF
        doc.build(story)
        
        # Ouverture du PDF
        if ouverture == True :
            FonctionsPerso.LanceFichierExterne(nomDoc)
开发者ID:bogucool,项目名称:Noethys,代码行数:54,代码来源:UTILS_Impression_location.py

示例5: build

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
    def build(self, flowables, onFirstPage=_doNothing, canvasmaker=canvas.Canvas):
        self._calc()

        frameT = Frame(letter_left_margin, letter_bottom_margin, letter_frame_width, letter_frame_height,
                       leftPadding=0, bottomPadding=0, rightPadding=0, topPadding=0,
                       id='normal')

        self.addPageTemplates([PageTemplate(id='First',frames=frameT, onPage=onFirstPage, pagesize=self.pagesize)])

        if onFirstPage is _doNothing and hasattr(self,'onFirstPage'):
            self.pageTemplates[0].beforeDrawPage = self.onFirstPage

        BaseDocTemplate.build(self, flowables, canvasmaker=canvasmaker)
开发者ID:sourabhgupta90,项目名称:testing_frame,代码行数:15,代码来源:django_report_lab.py

示例6: renderElements

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
def renderElements(elements, filesuffix=None, tmpdir=None):
    """ takes a list of reportlab flowables and renders them to a test.pdf file"""
    margin = 2 * cm
    if filesuffix:
        fn = 'test_' + filesuffix + '.pdf'
    else:
        fn = 'test.pdf'
    fn = os.path.join(tmpdir, fn)
    doc = BaseDocTemplate(fn, topMargin=margin, leftMargin=margin, rightMargin=margin, bottomMargin=margin)
    pt = WikiPage("Title")
    doc.addPageTemplates(pt)
    elements.insert(0, NextPageTemplate('Title'))   
    doc.build(elements)
开发者ID:EtherGraf,项目名称:mwlib.rl,代码行数:15,代码来源:renderhelper.py

示例7: pdf_basic_page

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
def pdf_basic_page( objects, title='', preferences=None ): # used by gen_table.make_page()
    """Simple convenience fonction: build a page from a list of platypus objects,
    adding a title if specified.
    """
    StyleSheet = styles.getSampleStyleSheet()
    report = cStringIO.StringIO() # in-memory document, no disk file
    document = BaseDocTemplate(report)
    document.addPageTemplates(
        ScolarsPageTemplate(document,
                            title=title,
                            author='%s %s (E. Viennet)' % (SCONAME, SCOVERSION),
                            footer_template="Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s",
                            preferences=preferences
                            ))
    if title:
        head = Paragraph(SU(title), StyleSheet["Heading3"])
        objects = [ head ] + objects
    document.build(objects)
    data = report.getvalue()
    return data
开发者ID:denys-duchier,项目名称:Scolar,代码行数:22,代码来源:sco_pdf.py

示例8: pagecat2

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
def pagecat2(request):
    doc = BaseDocTemplate('test.pdf')
    frame_title = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='title')
    frame_back = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='back')
    frame_1col = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='col12')
    frame1_2col = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='col1')
    frame2_2col = Frame(doc.leftMargin+doc.width/2+6, doc.bottomMargin, doc.width/2-6, doc.height, id='col2')

    doc.addPageTemplates([
        PageTemplate(id='Title', frames=frame_title, onPage=static_title),
        PageTemplate(id='Back', frames=frame_back, onPage=static_back),
        PageTemplate(id='OneCol', frames=frame_1col, onPage=static_1col),
        PageTemplate(id='TwoCol', frames=[frame1_2col, frame2_2col], onPage=static_2col),
    ])
    story = [Paragraph('<b>Table of contents</b>', ParagraphStyle('normal')),
             NextPageTemplate('TwoCol'),
             PageBreak(),
             '<includePdfPages filename="pdf1.pdf" pages="1,2,3"/>',
             NextPageTemplate('TwoCol')]

    doc.build(story)
    return render(request, "test.html")
开发者ID:verpoorten,项目名称:immobilier,代码行数:24,代码来源:pagecat2.py

示例9: save

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
 def save(self, flowables, file_h, canvasmaker=canvas.Canvas):
     BaseDocTemplate.build(self, flowables, filename=file_h, canvasmaker=canvasmaker)
开发者ID:guildenstern70,项目名称:fablegenerator,代码行数:4,代码来源:fabletemplate.py

示例10: __init__

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
    def __init__(self, dictValeurs={}, dictOptions={}, IDmodele=None, ouverture=True, nomFichier=None):
        """ Impression """
        global DICT_VALEURS, DICT_OPTIONS
        DICT_VALEURS = dictValeurs
        DICT_OPTIONS = dictOptions
        
        # Initialisation du document
        if nomFichier == None :
            nomDoc = FonctionsPerso.GenerationNomDoc("COTISATIONS", "pdf")
        else :
            nomDoc = nomFichier
        doc = BaseDocTemplate(nomDoc, pagesize=TAILLE_PAGE, showBoundary=False)
        
        # Mémorise le ID du modèle
        modeleDoc = DLG_Noedoc.ModeleDoc(IDmodele=IDmodele)
        doc.modeleDoc = modeleDoc
        
        # Importe le template de la première page
        doc.addPageTemplates(MyPageTemplate(pageSize=TAILLE_PAGE, doc=doc))
        
        story = []
        styleSheet = getSampleStyleSheet()
        h3 = styleSheet['Heading3']
        styleTexte = styleSheet['BodyText'] 
        styleTexte.fontName = "Helvetica"
        styleTexte.fontSize = 9
        styleTexte.borderPadding = 9
        styleTexte.leading = 12
        
        # ----------- Insertion du contenu des frames --------------
        listeLabels = []
        for IDcotisation, dictValeur in dictValeurs.iteritems() :
            listeLabels.append((dictValeur["{FAMILLE_NOM}"], IDcotisation))
        listeLabels.sort() 
        
        for labelDoc, IDcotisation in listeLabels :
            dictValeur = dictValeurs[IDcotisation]
            if dictValeur["select"] == True :
                
                story.append(DocAssign("IDcotisation", IDcotisation))
                nomSansCivilite = dictValeur["{FAMILLE_NOM}"]
                story.append(Bookmark(nomSansCivilite, str(IDcotisation)))
                
##                # ------------------- TITRE -----------------
##                dataTableau = []
##                largeursColonnes = [ TAILLE_CADRE_CONTENU[2], ]
##                dataTableau.append((dictCompte["titre"],))
##                texteDateReference = UTILS_Dates.DateEngFr(str(datetime.date.today()))
##                dataTableau.append((_(u"Situation au %s") % texteDateReference,))
##                style = TableStyle([
##                        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), 
##                        ('FONT',(0,0),(0,0), "Helvetica-Bold", 19), 
##                        ('FONT',(0,1),(0,1), "Helvetica", 8), 
##                        ('LINEBELOW', (0,0), (0,0), 0.25, colors.black), 
##                        ('ALIGN', (0,0), (-1,-1), 'LEFT'), 
##                        ])
##                tableau = Table(dataTableau, largeursColonnes)
##                tableau.setStyle(style)
##                story.append(tableau)
##                story.append(Spacer(0,30))
##                
##                    
##                couleurFond = (0.8, 0.8, 1)
##                couleurFondActivite = (0.92, 0.92, 1)
##                        
##                # TEXTE CONTENU
##                paraStyle = ParagraphStyle(name="contenu",
##                              fontName="Helvetica",
##                              fontSize=11,
##                              #leading=7,
##                              spaceBefore=0,
##                              spaceafter=0,
##                              leftIndent=6,
##                              rightIndent=6,
##                            )
##                
##                texte = dictCompte["texte"]
##                listeParagraphes = texte.split("</para>")
##                for paragraphe in listeParagraphes :
##                    textePara = Paragraph(u"%s</para>" % paragraphe, paraStyle)
##                    story.append(textePara)
                
                # Saut de page
                story.append(PageBreak())
        
        # Finalisation du PDF
        doc.build(story)
        
        # Ouverture du PDF
        if ouverture == True :
            FonctionsPerso.LanceFichierExterne(nomDoc)
开发者ID:CugeDe,项目名称:Noethys,代码行数:93,代码来源:UTILS_Impression_cotisation.py

示例11: __init__

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]

#.........这里部分代码省略.........
        # ------------------- TABLEAU CONTENU -----------------
        
        dataTableau = []
        largeursColonnes = [ 120, 280]
        
        paraStyle = ParagraphStyle(name="detail",
                                  fontName="Helvetica-Bold",
                                  fontSize=9,
                                )
        dataTableau.append( (_(u"Caractéristiques du règlement"), "") )
        montantEnLettres = UTILS_Conversion.trad(DICT_VALEURS["montant"], MONNAIE_SINGULIER, MONNAIE_DIVISION).strip() 
        dataTableau.append( (_(u"Montant du règlement :"), Paragraph(montantEnLettres.capitalize(), paraStyle) ) )
        dataTableau.append( (_(u"Mode de règlement :"), Paragraph(DICT_VALEURS["nomMode"], paraStyle) ) )
        dataTableau.append( (_(u"Nom du payeur :"), Paragraph(DICT_VALEURS["nomPayeur"], paraStyle) ) )
        if DICT_VALEURS["nomEmetteur"] != None : dataTableau.append( (_(u"Nom de l'émetteur :"), Paragraph(DICT_VALEURS["nomEmetteur"], paraStyle) ) )
        if DICT_VALEURS["numPiece"] not in ("", None) : dataTableau.append( (_(u"Numéro de pièce :"), Paragraph(DICT_VALEURS["numPiece"], paraStyle) ) )
        if DICT_VALEURS["date_differe"] not in ("", None): dataTableau.append((_(u"Encaissement différé :"), Paragraph(_(u"A partir du %s") % DICT_VALEURS["{DATE_DIFFERE}"], paraStyle)))
        
        style = TableStyle([
                ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), 
                ('FONT', (0, 0), (0, -1), "Helvetica", 9), 
                ('FONT', (1, 0), (1, -1), "Helvetica-Bold", 9), 
                ('GRID', (0, 0), (-1, -1), 0.25, colors.black),
                ('ALIGN', (0, 1), (0, -1), 'RIGHT'),
                ('ALIGN', (1, 1), (1, -1), 'LEFT'), 
                
                ('FONT', (0, 0), (0, 0), "Helvetica", 7), 
                ('SPAN', (0, 0), (-1, 0)), 
                ('BACKGROUND', (0, 0), (-1, 0), couleurFond),
                
                ])
        tableau = Table(dataTableau, largeursColonnes)
        tableau.setStyle(style)
        story.append(tableau)
        
        # --------------------- LISTE DES PRESTATIONS ----------------
        listePrestations = dictValeurs["prestations"]
        if len(listePrestations) > 0 :
            
            story.append(Spacer(0,20))
            textePrestations = _(u"En paiement des prestations suivantes :")
            story.append(Paragraph(u"<i>%s</i>" % textePrestations, paraStyleIntro))
            story.append(Spacer(0,20))

            dataTableau = [(_(u"Date"), _(u"Activité"), _(u"Individu"), _(u"Intitulé"), _(u"Part utilisée")),]
            largeursColonnes = [50, 95, 70, 135, 50]

            paraStyle = ParagraphStyle(name="detail",
                                      fontName="Helvetica",
                                      fontSize=7,
                                      leading=7,
                                      spaceBefore=0,
                                      spaceAfter=0,
                                      )

            for dictPrestation in listePrestations :
                date = UTILS_Dates.DateDDEnFr(dictPrestation["date"])
                activite = dictPrestation["nomActivite"]
                individu = dictPrestation["prenomIndividu"]
                label = dictPrestation["label"]
                montant = dictPrestation["montant"]
                ventilation = dictPrestation["ventilation"]
                
                dataTableau.append((
                    Paragraph(u"<para align='center'>%s</para>"% date, paraStyle), 
                    Paragraph(activite, paraStyle),  
                    Paragraph(individu, paraStyle),  
                    Paragraph(label, paraStyle), 
                    Paragraph(u"<para align='right'>%.2f %s</para>" % (ventilation, SYMBOLE), paraStyle), 
                    ))
                        
            style = TableStyle([
                    ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), 
                    ('GRID', (0, 0), (-1, -1), 0.25, colors.black),
                    ('FONT', (0, 0), (-1, -1), "Helvetica", 7), 

                    ('TOPPADDING', (0, 1), (-1, -1), 1), 
                    ('BOTTOMPADDING', (0, 1), (-1, -1), 3), 
        
                    # Ligne Entetes
                    ('FONT', (0, 0), (-1, 0), "Helvetica", 7), 
                    ('BACKGROUND', (0, 0), (-1, 0), couleurFond),
                    ('ALIGN', (0, 0), (-1, 0), 'CENTER'),
                    
                    ])
            tableau = Table(dataTableau, largeursColonnes)
            tableau.setStyle(style)
            story.append(tableau)

        
        # Enregistrement et ouverture du PDF
        try :
            doc.build(story)
        except Exception, err :
            print "Erreur dans ouverture PDF :", err
            if "Permission denied" in err :
                dlg = wx.MessageDialog(None, _(u"Noethys ne peut pas créer le PDF.\n\nVeuillez vérifier qu'un autre PDF n'est pas déjà ouvert en arrière-plan..."), _(u"Erreur d'édition"), wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
                return
开发者ID:bogucool,项目名称:Noethys,代码行数:104,代码来源:UTILS_Impression_recu.py

示例12: render_to_reportlab

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]

#.........这里部分代码省略.........
                qta = 1
                prezzo = netto
                iva = 10

                def val_imponibile(self):
                    return self.prezzo

                def val_iva(self):
                    return totale - netto

                def val_totale(self):
                    return totale

            riga = RigaTotaleIvata()
            # la fattura ha totale pari al totale di tutte le righe
            # l'iva è fissa al 10% e il netto è calcolato di conseguenza
            imponibile = netto
            iva = totale - netto
            righe = [riga]

        else:
            imponibile = fattura.val_imponibile()
            iva = fattura.val_iva()

        for riga in righe:
            descrizione = riga.descrizione
            if riga.note: descrizione += " (%s)" % riga.note
            row_values = (
                (
                    Paragraph(descrizione, normalStyle),
                    Paragraph("%s" % riga.qta, normalStyle)
                ) +
                (
                    (
                        moneyfmt(riga.prezzo),
                        riga.iva,
                    ) if FATTURE_SHOW_VAT_COLUMN else tuple()) +
                (
                    moneyfmt(riga.val_totale()),
                )
            )
            righeFattura.append(row_values)
        righeTotali = []
        if FATTURE_SHOW_VAT_COLUMN:
            righeTotali.append((
                'Imponibile', moneyfmt(imponibile)
            ))
            righeTotali.append((
                'IVA', moneyfmt(iva)
            ))
        righeTotali.append((
            'TOTALE', moneyfmt(fattura.val_totale())
        ))
        righeStyle = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'TOP'),
            ('ALIGN', (0, 0), (-1, -1), 'RIGHT'),  # globalmente allineato a destra...
            ('ALIGN', (0, 0), (1, -1), 'LEFT'),  # tranne la prima colonna (con la descrizione)
            ('GRID', (0, 1), (-1, -1), 0.1, colors.grey),
            ('FACE', (0, 0), (-1, -1), 'Helvetica'),

            ('FACE', (0, 0), (-1, 0), 'Helvetica-Bold'),  # header
            ('SIZE', (0, 0), (-1, -1), 8),

            # ('SPAN', (0, -1), (3, -1)),	# anziché mettere lo span qui aggiungo in coda una tabella diversa
        ])
        totaliStyle = TableStyle([
            ('ALIGN', (0, 0), (-1, -1), 'RIGHT'),
            ('GRID', (-1, 0), (-1, -1), 0.1, colors.grey),

            ('FACE', (0, 0), (-1, -1), 'Helvetica'),  # header
            ('FACE', (0, -1), (-1, -1), 'Helvetica-Bold'),  # Totale
            ('SIZE', (0, 0), (-1, -1), 8),

        ])

        price_columns = 4 if FATTURE_SHOW_VAT_COLUMN else 2
        colWidths = (
            ((width - doc.leftMargin - doc.rightMargin) - (1.6 * cm * price_columns),) +
            (1.6 * cm,) * price_columns
        )
        story_fattura = [Table(righeFattura, style=righeStyle, repeatRows=1, colWidths=colWidths)]
        story_fattura.append(KeepTogether(Table(righeTotali, style=totaliStyle,
                                                colWidths=(
                                                    width - doc.leftMargin - doc.rightMargin - 1.6 * cm,
                                                    1.6 * cm))))

        if ricevutaMultipla:  # le ricevute si raddoppiano con 2 template diversi
            # raddoppio lo story di questa fattura cambiando template
            story_fattura = story_fattura + [NextPageTemplate("ConsorzioConducente"),
                                             PageBreak()] + story_fattura
        fatture_rimanenti -= 1
        if fatture_rimanenti:
            story_fattura += [NextPageTemplate(NormalTemplates[-1]), PageBreak()]

        NormalTemplates.reverse()  # reverse current, next normal template

        story = story + story_fattura

    doc.build(story, canvasmaker=NumberedCanvas)
    return response
开发者ID:dariosky,项目名称:tam,代码行数:104,代码来源:pdf.py

示例13: __init__

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]

#.........这里部分代码省略.........
        
        # ----------- Insertion du contenu des frames --------------
        listeNomsSansCivilite = []
        for IDcompte_payeur, dictCompte in dictComptes.iteritems() :
            listeNomsSansCivilite.append((dictCompte["{FAMILLE_NOM}"], IDcompte_payeur))
        listeNomsSansCivilite.sort() 
        
        for nomSansCivilite, IDcompte_payeur in listeNomsSansCivilite :
            dictCompte = dictComptes[IDcompte_payeur]
                
            story.append(DocAssign("IDcompte_payeur", IDcompte_payeur))
            nomSansCivilite = dictCompte["{FAMILLE_NOM}"]
            story.append(Bookmark(nomSansCivilite, str(IDcompte_payeur)))
            
            # ------------------- TITRE -----------------
            dataTableau = []
            largeursColonnes = [ TAILLE_CADRE_CONTENU[2], ]
            dataTableau.append((dictOptions["titre"],))
            texteDateReference = UTILS_Dates.DateEngFr(str(datetime.date.today()))
            dataTableau.append((_(u"Période du %s au %s") % (UTILS_Dates.DateDDEnFr(dictOptions["date_debut"]), UTILS_Dates.DateDDEnFr(dictOptions["date_fin"])),))
            style = TableStyle([
                    ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), 
                    ('FONT',(0,0),(0,0), "Helvetica-Bold", 19), 
                    ('FONT',(0,1),(0,1), "Helvetica", 8), 
                    ('LINEBELOW', (0,0), (0,0), 0.25, colors.black), 
                    ('ALIGN', (0,0), (-1,-1), 'LEFT'), 
                    ])
            tableau = Table(dataTableau, largeursColonnes)
            tableau.setStyle(style)
            story.append(tableau)
            story.append(Spacer(0, 30))
            
                
            couleurFond = (0.8, 0.8, 1)
            couleurFondActivite = (0.92, 0.92, 1)
                    
            # TEXTE CONTENU
            paraStyle = ParagraphStyle(name="contenu",
                          fontName="Helvetica",
                          fontSize=11,
                          leading=16,
                          spaceBefore=0,
                          spaceafter=0,
                          leftIndent=6,
                          rightIndent=6,
                        )
            
            # INTRO
            texte = dictCompte["{INTRO}"]
            if texte != "" :
                listeParagraphes = texte.split("</para>")
                for paragraphe in listeParagraphes :
                    textePara = Paragraph(u"%s" % paragraphe, paraStyle)
                    story.append(textePara)
                
                story.append(Spacer(0, 25))
            
            # DETAIL par enfant
            dataTableau = [(_(u"Nom et prénom"), _(u"Date de naissance"), _(u"Montant")),]
            largeursColonnes = [ 220, 80, 80]
            
            paraStyle = ParagraphStyle(name="detail",
                                      fontName="Helvetica-Bold",
                                      fontSize=9,
                                    )
            
            for nomCompletIndividu, dictIndividu in dictCompte["individus"] :
                dataTableau.append( (nomCompletIndividu, dictIndividu["date_naiss"],  u"%.2f %s" % (dictIndividu["regle"], SYMBOLE)) )
            
            dataTableau.append( ("", "Total :",  dictCompte["{MONTANT_REGLE}"]) )
            
            style = TableStyle([
                    ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), 
                    ('ALIGN', (0, 0), (-1, -1), 'CENTER'),
                    ('GRID', (0, 0), (-1, -2), 0.25, colors.black),
                    ('FONT', (0, 0), (-1, 0), "Helvetica", 6), 
                    ('FONT', (0, 1), (-1, -1), "Helvetica", 10), 

                    ('TOPPADDING', (0, 1), (-1, -2), 10), 
                    ('BOTTOMPADDING', (0, 1), (-1, -2), 10), 
                    
                    ('GRID', (-1, -1), (-1, -1), 0.25, colors.black),
                    ('FONT', (-1, -1), (-1, -1), "Helvetica-Bold", 10), 
                    
                    ('ALIGN', (-2, -1), (-2, -1), 'RIGHT'),
                    ('FONT', (-2, -1), (-2, -1), "Helvetica", 6), 
                    ])
            tableau = Table(dataTableau, largeursColonnes)
            tableau.setStyle(style)
            story.append(tableau)

            # Saut de page
            story.append(PageBreak())
        
        # Finalisation du PDF
        doc.build(story)
        
        # Ouverture du PDF
        if ouverture == True :
            FonctionsPerso.LanceFichierExterne(nomDoc)
开发者ID:CugeDe,项目名称:Noethys,代码行数:104,代码来源:UTILS_Impression_attestation_fiscale.py

示例14: report

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
def report(fname, shot, versions):
    # pdf properties
    title = "Report"
    author = "Rob Blau"

    # define frames for page layout
    page = PageTemplate(frames=[
        Frame(x1=0.1*inch, y1=8.9*inch, width=3*inch, height=2*inch),  # shot thumbnail
        Frame(x1=0.1*inch, y1=0.1*inch, width=8.3*inch, height=4*inch),  # versions table
    ])

    # create the doc
    doc = BaseDocTemplate(
        fname,
        pagesize=letter,
        pageTemplates=page,
        title=title,
        author=author,
    )

    # styles
    styles = reportlab.lib.styles.getSampleStyleSheet()

    # content
    story = []

    # shot thumbnail
    data = [['Shot Thumbnail'], [get_image(shot['image'], 3*inch, 1.5*inch)]]
    shot_thumbnail = Table(data, colWidths=3*inch)
    shot_thumbnail.setStyle(TableStyle([
        ('BOX', (0,0), (-1,-1), 0.25, colors.black),
        ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
        ('TEXTCOLOR', (0,0), (0,0), colors.white),
        ('BACKGROUND', (0,0), (0,0), colors.black),
        ('ALIGN', (0,1), (0,1), 'CENTER'),
    ]))
    story.append(shot_thumbnail)
    story.append(FrameBreak())

    # versions grid
    data = [
        ['Versions', '', '', ''],
        [Paragraph('<b>%s</b>' % t, styles['BodyText']) for t in ['Status', 'Name', 'Notes', 'Frame Range']],
    ]
    for v in versions:
        data.append([
            Paragraph(v['sg_status_list'] or '', styles['BodyText']),
            Paragraph(v['code'] or '', styles['BodyText']),
            Paragraph(v['description'] or '', styles['BodyText']),
            Paragraph(v['frame_range'] or '', styles['BodyText']),
        ])
    version_table = Table(data)
    version_table.setStyle(TableStyle([
        ('BOX', (0,0), (-1,-1), 0.25, colors.black),
        ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
        ('TEXTCOLOR', (0,0), (0,0), colors.white),
        ('BACKGROUND', (0,0), (0,0), colors.black),
        ('SPAN', (0,0), (-1, 0)),
    ]))
    story.append(version_table)
    story.append(FrameBreak)

    # and save
    doc.build(story)
开发者ID:robblau,项目名称:shotgun-heroku-example,代码行数:66,代码来源:app.py

示例15: ValuationPrint

# 需要导入模块: from reportlab.platypus.doctemplate import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.doctemplate.BaseDocTemplate import build [as 别名]
class ValuationPrint():

    def __init__(self, filename):

        self.width, self.height = pagesizes.A4
        self.lmargin = 1*units.cm
        self.rmargin = self.width - self.lmargin
        #styles = getSampleStyleSheet()
        #self.styleH = styles['Heading1']
        #self.styleN = styles['Normal']
        self.doc = BaseDocTemplate(filename)
        self.val_template = PageTemplate(id='valuation',
                                         frames=[Frame(self.lmargin, 5*units.cm,
                                                       19*units.cm, 15.5*units.cm, id='table',
                                                       showBoundary=0)],
                                         onPage=self.setup_page)
        self.doc.addPageTemplates(self.val_template)

    def setup_page(self, canvas, doc):
        canvas.saveState()
        self.do_title(canvas)
        self.do_client_name(canvas)
        self.do_date(canvas)
        self.do_person_bg(canvas)
        canvas.restoreState()

    def do_person_bg(self, canvas):
        canvas.saveState()
        ref = self.data.person_code + '/' + self.data.business_getter
        canvas.setFont('Times-Roman', 12)
        canvas.drawRightString(self.rmargin, 22*units.cm, ref)
        canvas.restoreState()

    def do_date(self, canvas):
        canvas.saveState()
        canvas.setFont('Times-Roman', 12)
        dt = time.strptime(self.data.valuation_date, '%Y%m%d')
        canvas.drawString(self.lmargin, 22*units.cm, datetime.date(*dt[0: 3]).strftime('%dth %B %Y'))
        canvas.restoreState()

    def do_title(self, canvas):
        canvas.saveState()
        canvas.setFont('Times-Bold', 14)
        canvas.drawString(self.lmargin, 25*units.cm, 'Portfolio Valuation')
        canvas.restoreState()

    def do_client_name(self, canvas):
        canvas.saveState()
        canvas.setFont('Times-Bold', 14)
        canvas.drawString(self.lmargin, 23*units.cm, self.data.name_and_address["client_name"])
        canvas.restoreState()

    def create_pdf(self, data):
        self.data = data
        story = []
        dta = [[ValuationTable.heading_line(['Description', 'Book Cost', 'Holding',
                                            'Price', 'Value', 'Est. Income', 'Yield (%)'])]]
        dta.extend(ValuationTable.format_data(self.data.holdings))
        dta.extend(ValuationTable.format_cash_lines(self.data.valuation_cash, self.data.name_and_address))
        dta.extend(ValuationTable.format_total_lines(self.data.totals))
        story.append(ValuationTable(dta))
        self.doc.build(story)
开发者ID:hamishdickson,项目名称:Figdoc,代码行数:64,代码来源:corefigaro.py


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