コード例 #1
0
 def __init__(self, **kw):
     self.pisaStaticList = []
     self.pisaBackgroundList = []
     self.pisaBackground = None
     PageTemplate.__init__(self, **kw)
     self._page_count = 0
     self._first_flow = True
コード例 #2
0
    def __init__(
            self,
            title=None,
            id=None,
            onPage=_doNothing,
            onPageEnd=_doNothing,
            pagesize=(page_width, page_height),
            rtl=False,
    ):
        """
        @type title: unicode
        """

        id = title.encode('utf-8')
        frames = Frame(page_margin_left, page_margin_bottom, print_width,
                       print_height)

        PageTemplate.__init__(self,
                              id=id,
                              frames=frames,
                              onPage=onPage,
                              onPageEnd=onPageEnd,
                              pagesize=pagesize)

        self.title = title
        self.rtl = rtl
コード例 #3
0
 def __init__(self, **kw):
     self.pisaStaticList = []
     self.pisaBackgroundList = []
     self.pisaBackground = None
     PageTemplate.__init__(self, **kw)
     self._page_count = 0
     self._first_flow = True
コード例 #4
0
    def build(self, onFirstPage=_doNothing, onLaterPages=_doNothing):
        """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
コード例 #5
0
ファイル: template.py プロジェクト: benrshep/friarwood
    def __init__(self, filename, **kw):

        self.allowSplitting = 0
        BaseDocTemplate.__init__(self, filename, **kw)

        self.pagesize = A4
        self.topMargin = 0.5 * cm
        self.bottomMargin = 2 * cm
        self.leftMargin = 1 * cm
        self.rightMargin = 1 * cm
        self._calc()

        frameT = Frame(self.leftMargin,
                       self.bottomMargin,
                       self.width,
                       self.height,
                       id='normal',
                       showBoundary=0)
        # Table of contents padding
        tocP = 3 * cm
        frameTOC = Frame(self.leftMargin,
                         self.bottomMargin,
                         self.width,
                         self.height,
                         leftPadding=tocP,
                         rightPadding=tocP,
                         id='toc',
                         showBoundary=0)

        titleTemplate = PageTemplate('title', frames=frameT, onPage=titlePage)
        tocTemplate = PageTemplate('toc', frames=frameTOC, onPage=tocPage)
        template = PageTemplate('normal', frames=frameT, onPage=defaultPage)

        self.addPageTemplates([titleTemplate, tocTemplate, template])
コード例 #6
0
ファイル: pagetemplates.py プロジェクト: ingob/mwlib.rl
    def __init__(self, cover=None, id=None,
        onPage=_doNothing, onPageEnd=_doNothing, pagesize=(page_width, page_height)):

        id = 'TitlePage'
        frames = Frame(page_margin_left, page_margin_bottom, print_width, print_height)
        PageTemplate.__init__(self,id=id, frames=frames,onPage=onPage,onPageEnd=onPageEnd,pagesize=pagesize)
        self.cover = cover
コード例 #7
0
def make_doc(filename, title='Generic Title', title_page=None, content_page=None, font='Helvetica'):
    """Return MyDocTemplate instance with PageTemplates"""
    doc = MyDocTemplate(filename, pageSize=letter)

    if not title_page:
        def title_page(canvas, doc):
            """Create generic title page."""
            canvas.saveState()
            canvas.setFont(FONT, 36)
            canvas.drawCentredString(306, 600, title)
            canvas.restoreState()

    if not content_page:
        def content_page(canvas, doc):
            canvas.saveState()
            canvas.setFont(font, 12)
            #         canvas.drawRightString(7.5 * inch, .8 * inch, "Page %d | %s   %s" % (doc.page, model, footer_test_date))
            canvas.restoreState()

    frameT = Frame(
        doc.leftMargin,
        doc.bottomMargin,
        doc.width,
        doc.height,
        id='normal',
        #         showBoundary=1,
    )
    doc.addPageTemplates([
        PageTemplate(id='TitlePage', frames=frameT, onPage=title_page),
        PageTemplate(id='ContentPage', frames=frameT, onPage=content_page)
    ])
    return doc
コード例 #8
0
    def add_page_template(self, doc):
        """Adds song page template to the document."""

        from reportlab.lib.units import cm
        from reportlab.platypus.frames import Frame
        from reportlab.platypus.doctemplate import PageTemplate

        doc._calc()  #taken from reportlab source code (magic)

        # The switch between one or two columns PDF output reflects on having one
        # or two frames. If we have two frames, the width and the start position
        # of each frame has to be computed slightly differently.
        #
        # Special attention to the right frame or its start will meet the picture
        # of the artist. So, we start about 2 cm down.

        if self.song.two_columns:

            padding = 0.5 * cm
            frame_width = (doc.width - padding) / 2
            frames = [
                Frame(doc.leftMargin,
                      doc.bottomMargin,
                      frame_width,
                      doc.height,
                      id='column-1',
                      leftPadding=0,
                      rightPadding=0),
                Frame(doc.leftMargin + frame_width + padding,
                      doc.bottomMargin,
                      frame_width,
                      doc.height - 2 * cm,
                      id='column-2',
                      leftPadding=0,
                      rightPadding=0),
            ]
        else:
            frames = Frame(doc.leftMargin,
                           doc.bottomMargin,
                           doc.width,
                           doc.height,
                           id='normal',
                           leftPadding=0,
                           rightPadding=0)

        template = [
            PageTemplate(id='FirstPageSongTemplate',
                         frames=frames,
                         onPage=self.page_template_first,
                         pagesize=doc.pagesize)
        ]
        doc.addPageTemplates(template)
        template = [
            PageTemplate(id=self.template_id(),
                         frames=frames,
                         onPage=self.page_template,
                         pagesize=doc.pagesize)
        ]
        doc.addPageTemplates(template)
コード例 #9
0
    def __init__(self):
        #allow a bigger margin on the right for the staples
        frame = Frame(3.5*cm, 2.5*cm, 16*cm, 25*cm, id='F1')

        PageTemplate.__init__(self,
                              id='right',
                              frames=[frame],
                              pagesize=A4)
コード例 #10
0
ファイル: pagetemplates.py プロジェクト: ingob/mwlib.rl
    def __init__(self, pageSize=A3):
        id = 'simplepage'
        #frames = Frame(0, 0, pageSize[0], pageSize[1])
        pw = pageSize[0]
        ph = pageSize[1]
        frames = Frame(page_margin_left, page_margin_bottom, pw-page_margin_left-page_margin_right, ph-page_margin_top-page_margin_bottom)

        PageTemplate.__init__(self, id=id, frames=frames, pagesize=pageSize)
コード例 #11
0
 def __init__(self, filename, **kw):
     frame1 = Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')
     frame2 = Frame(2.5*cm, 2.5*cm, 310, 25*cm, id='F2')
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     template = PageTemplate('normal', [frame1], myMainPageFrame)
     template1 = PageTemplate('special', [frame2], myMainPageFrame)
     self.addPageTemplates([template,template1])
コード例 #12
0
    def __init__(self):
        #allow a bigger margin on the right for the staples
        frame = Frame(3.5*cm, 2.5*cm, 16*cm, 25*cm, id='F1')

        PageTemplate.__init__(self,
                              id='right',
                              frames=[frame],
                              pagesize=A4)
コード例 #13
0
    def __init__(self, pageSize=A3):
        id = 'simplepage'
        #frames = Frame(0, 0, pageSize[0], pageSize[1])
        pw = pageSize[0]
        ph = pageSize[1]
        frames = Frame(page_margin_left, page_margin_bottom,
                       pw - page_margin_left - page_margin_right,
                       ph - page_margin_top - page_margin_bottom)

        PageTemplate.__init__(self, id=id, frames=frames, pagesize=pageSize)
コード例 #14
0
 def __init__(self, id=-1, pageSize=TAILLE_PAGE, doc=None):
     self.pageWidth = pageSize[0]
     self.pageHeight = pageSize[1]
     
     # Récupère les coordonnées du cadre principal
     cadre_principal = doc.modeleDoc.FindObjet("cadre_principal")
     x, y, l, h = doc.modeleDoc.GetCoordsObjet(cadre_principal)
     global CADRE_CONTENU
     CADRE_CONTENU = (x, y, l, h)
     frame1 = Frame(x, y, l, h, id='F1', leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0)
     PageTemplate.__init__(self, id, [frame1], Template) 
コード例 #15
0
ファイル: pagetemplates.py プロジェクト: ingob/mwlib.rl
    def __init__(self,title=None, id=None, onPage=_doNothing, onPageEnd=_doNothing, pagesize=(page_width, page_height)):
        """
        @type title: unicode
        """
        
        id = title.encode('utf-8')
        frames = Frame(page_margin_left,page_margin_bottom, print_width, print_height)
        
        PageTemplate.__init__(self,id=id, frames=frames,onPage=onPage,onPageEnd=onPageEnd,pagesize=pagesize)

        self.title = title
コード例 #16
0
 def __init__(self, filename, **kw):
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     self.addPageTemplates([
         PageTemplate(
             'normal',
             [
                 Frame(inch,
                       inch,
                       6.27 * inch,
                       9.69 * inch,
                       id='first',
                       topPadding=0,
                       rightPadding=0,
                       leftPadding=0,
                       bottomPadding=0,
                       showBoundary=ShowBoundaryValue(color="red"))
             ],
             onPage=onPage('normal'),
         ),
         PageTemplate(
             'auto',
             [
                 Frame(inch,
                       inch,
                       6.27 * inch,
                       9.69 * inch,
                       id='first',
                       topPadding=0,
                       rightPadding=0,
                       leftPadding=0,
                       bottomPadding=0,
                       showBoundary=ShowBoundaryValue(color="red"))
             ],
             onPage=onPage('auto'),
             autoNextPageTemplate='autoFollow',
         ),
         PageTemplate(
             'autoFollow',
             [
                 Frame(inch,
                       inch,
                       6.27 * inch,
                       9.69 * inch,
                       id='first',
                       topPadding=0,
                       rightPadding=0,
                       leftPadding=0,
                       bottomPadding=0,
                       showBoundary=ShowBoundaryValue(color="red"))
             ],
             onPage=onPage('autoFollow'),
         ),
     ])
コード例 #17
0
    def __init__(self, filename, **kw):
        frame1 = Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')
        self.allowSplitting = 0
        BaseDocTemplate.__init__(self, filename, **kw)
        template1 = PageTemplate('normal', [frame1], myMainPageFrame)

        frame2 = Frame(2.5*cm, 16*cm, 15*cm, 10*cm, id='F2', showBoundary=1)
        frame3 = Frame(2.5*cm, 2.5*cm, 15*cm, 10*cm, id='F3', showBoundary=1)

        template2 = PageTemplate('updown', [frame2, frame3])
        self.addPageTemplates([template1, template2])
コード例 #18
0
ファイル: pagetemplates.py プロジェクト: WikiToLearn/mwlib.rl
    def __init__(self, cover=None, id=None,
        onPage=_doNothing, onPageEnd=_doNothing, pagesize=(page_width, page_height)):

        id = 'TitlePage'
        p = pdfstyles
        frames = Frame(p.title_margin_left,
                       p.title_margin_bottom,
                       p.page_width-p.title_margin_left-p.title_margin_right,
                       p.page_height-p.title_margin_top-p.title_margin_bottom)

        PageTemplate.__init__(self,id=id, frames=frames,onPage=onPage,onPageEnd=onPageEnd,pagesize=pagesize)
        self.cover = cover
コード例 #19
0
    def __init__(self, id=-1, pageSize=TAILLE_PAGE, doc=None):
        self.pageWidth = pageSize[0]
        self.pageHeight = pageSize[1]
        
##        # Récupère les coordonnées du cadre principal
##        cadre_principal = doc.modeleDoc.FindObjet("cadre_principal")
##        x, y, l, h = doc.modeleDoc.GetCoordsObjet(cadre_principal)
##        global CADRE_CONTENU
##        CADRE_CONTENU = (x, y, l, h)
        
        x, y, l, h = 0, 0, self.pageWidth, self.pageHeight
        frame1 = Frame(x, y, l, h, id='F1', leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0)
        PageTemplate.__init__(self, id, [frame1], Template) 
コード例 #20
0
    def __init__(self, **kw):
        self.pisaStaticList = []
        self.pisaBackgroundList = []
        self.pisaBackground = None
        PageTemplate.__init__(self, **kw)
        self._page_count = 0
        self._first_flow = True

        ### Background Image ###
        self.img = None
        self.ph = 0
        self.h = 0
        self.w = 0
コード例 #21
0
    def __init__(self, **kw):
        self.pisaStaticList = []
        self.pisaBackgroundList = []
        self.pisaBackground = None
        PageTemplate.__init__(self, **kw)
        self._page_count = 0
        self._first_flow = True

        ### Background Image ###
        self.img = None
        self.ph = 0
        self.h = 0
        self.w = 0
コード例 #22
0
    def __init__(self, filename, plugin_dir, growing_year, cur_date, **kw):
        """Generate a basic A4 pdf document

        Parameters
        ----------
        filename: str
            The file name to store the PDF document
        tr: translation
            The Translation function from GeoDataFarm
        plugin_dir: str
            path to the plugin dir in order to find the icon
        growing_year: int
             What growing year
        cur_date: str
            Current date, to write on the report
        kw
        """
        BaseDocTemplate.__init__(self, filename, **kw)
        self.allowSplitting = 1
        translate = TR('MyDocTemplate')
        self.tr = translate.tr
        self.plugin_dir = plugin_dir
        frame = Frame(self.leftMargin,
                      self.bottomMargin,
                      self.width,
                      self.height - 2 * cm,
                      id='normal')
        template = PageTemplate(id='test',
                                frames=frame,
                                onPage=partial(self.header,
                                               growing_year=growing_year,
                                               cur_date=cur_date))
        self.addPageTemplates(template)
コード例 #23
0
    def __init__(self, filename, **kw):
        self.allowSplitting = 0

        self.pagesize = kw.get('pagesize', landscape(A5))
        kw['pagesize'] = self.pagesize

        BaseDocTemplate.__init__(self, filename, **kw)

        w, h = self.pagesize

        # self.actualWidth, self.actualHeight = landscape(A5)
        self.topMargin = 2.85 * cm
        self.leftMargin = 0.15 * cm
        self.bottomMargin = 0.15 * cm

        fh = h - self.topMargin - self.bottomMargin
        fw = w - (2 * self.leftMargin)

        frame = Frame(self.leftMargin,
                      self.bottomMargin,
                      fw,
                      fh,
                      id='ContentFrame',
                      showBoundary=False)

        template = PageTemplate('normal',
                                frames=[
                                    frame,
                                ],
                                pagesize=self.pagesize)
        self.loadFonts()
        self.addPageTemplates(template)
コード例 #24
0
 def __init__(self, filename, **kw):
     m = 2 * cm
     from reportlab.lib import pagesizes
     PAGESIZE = pagesizes.landscape(pagesizes.A4)
     cw, ch = (PAGESIZE[0] - 2 * m) / 2., (PAGESIZE[1] - 2 * m)
     ch -= 14 * cm
     f1 = Frame(m,
                m + 0.5 * cm,
                cw - 0.75 * cm,
                ch - 1 * cm,
                id='F1',
                leftPadding=0,
                topPadding=0,
                rightPadding=0,
                bottomPadding=0,
                showBoundary=True)
     f2 = Frame(cw + 2.7 * cm,
                m + 0.5 * cm,
                cw - 0.75 * cm,
                ch - 1 * cm,
                id='F2',
                leftPadding=0,
                topPadding=0,
                rightPadding=0,
                bottomPadding=0,
                showBoundary=True)
     BaseDocTemplate.__init__(self, filename, **kw)
     template = PageTemplate('template', [f1, f2])
     self.addPageTemplates(template)
コード例 #25
0
ファイル: pdfbuilder.py プロジェクト: intel/cve-bin-tool
 def __init__(self, filename, **kw):
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     template = PageTemplate(
         "normal", [Frame(2.5 * cm, 2.5 * cm, 15 * cm, 25 * cm, id="F1")]
     )
     self.addPageTemplates(template)
コード例 #26
0
 def __init__(self, filename, **kw):
     self.figCount = 0
     self.allowSplitting = 0
     #TODO fix appy for python3
     apply(BaseDocTemplate.__init__, (self, filename), kw)
     template = PageTemplate('normal', [Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')])
     self.addPageTemplates(template)
コード例 #27
0
ファイル: doctemplate.py プロジェクト: pombredanne/itools
    def __init__(self, filename, context, **kw):
        BaseDocTemplate.__init__(self, filename, **kw)
        self.toc_index = 0
        body_attrs = (self.leftMargin, self.bottomMargin, self.width,
                      self.height)
        self.main_frame_attr = {'x1': self.leftMargin,
                                'y1': self.bottomMargin,
                                'width': self.width,
                                'height': self.height,
                                'id':'normal',
                                'showBoundary': self.showBoundary}

        # We keep the main frame reference to resize it during the build
        self.main_frame = Frame(**self.main_frame_attr)
        self.main_frame_change = False
        template_attrs = {'id': 'now', 'frames': [self.main_frame],
                          'pagesize': kw['pagesize']}
        page_template = PageTemplate(**template_attrs)
        self.platypus_header_calculate = False
        self.platypus_header_height = None
        self.platypus_footer = None
        self.context = context
        self.addPageTemplates([page_template])
        self.toc_high_level = self.context.toc_high_level

        self.frame_attr = {'leftPadding': 0, 'bottomPadding': 6,
                           'rightPadding': 0, 'topPadding': 6,
                           'showBoundary': 0}
        self.context = context
        # calculate width available
        self.width_available = self.width
        self.width_available -= self.frame_attr['leftPadding']
        self.width_available -= self.frame_attr['rightPadding']
コード例 #28
0
 def __init__(self, filename, **kw):
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     frameT = Frame(self.leftMargin,
                    self.bottomMargin,
                    self.width,
                    self.height,
                    id='F1')
     template_title_page = PageTemplate('title_page',
                                        frames=frameT,
                                        onPage=title_page)
     template_later_pages = PageTemplate('later_pages',
                                         frames=frameT,
                                         onPage=later_pages)
     self.addPageTemplates(template_title_page)
     self.addPageTemplates(template_later_pages)
コード例 #29
0
ファイル: utils.py プロジェクト: guobot-code/django-invoices
 def __init__(self, filename, **kw):
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     self.page_width, self.page_height = self.pagesize
     first_page_tpl = PageTemplate(
         'normal', [Frame(0, 0, 21 * cm, 29.7 * cm, id='F1')],
         onPage=self._draw_static_elements)
     self.addPageTemplates(first_page_tpl)
コード例 #30
0
ファイル: pagetemplates.py プロジェクト: iwoj/mwlib.rl
    def __init__(self,
                 cover=None,
                 id=None,
                 onPage=_doNothing,
                 onPageEnd=_doNothing,
                 pagesize=(page_width, page_height)):

        id = 'TitlePage'
        frames = Frame(page_margin_left, page_margin_bottom, print_width,
                       print_height)
        PageTemplate.__init__(self,
                              id=id,
                              frames=frames,
                              onPage=onPage,
                              onPageEnd=onPageEnd,
                              pagesize=pagesize)
        self.cover = cover
コード例 #31
0
 def __init__(self, writer):
     MyTemplates._AbstractTemplate.__init__(self, writer)
     (x, y, width, height) = (2.0 * cm, 2.0 * cm, 15.0 * cm, 25.0 * cm)
     mainFrame = Frame(x, y, width, height, id='MainFrame')
     page = PageTemplate('normal', [
         mainFrame,
     ], self.onPage, self.onPageEnd)
     self.addPageTemplates(page)
コード例 #32
0
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
コード例 #33
0
    def __init__(self, id=-1, pageSize=None, rect=None):
        self.pageWidth = pageSize[0]
        self.pageHeight = pageSize[1]

        self.hauteurColonne = 700
        self.margeBord = 40
        self.margeInter = 20

        x, y, l, h = (self.margeBord, self.margeBord, LARGEUR_COLONNE,
                      self.hauteurColonne)
        frame1 = Frame(x,
                       y,
                       l,
                       h,
                       id='F1',
                       leftPadding=0,
                       topPadding=0,
                       rightPadding=0,
                       bottomPadding=0)

        x, y, l, h = (self.margeBord + LARGEUR_COLONNE + self.margeInter,
                      self.margeBord, LARGEUR_COLONNE, self.hauteurColonne)
        frame2 = Frame(x,
                       y,
                       l,
                       h,
                       id='F2',
                       leftPadding=0,
                       topPadding=0,
                       rightPadding=0,
                       bottomPadding=0)

        x, y, l, h = (self.margeBord + (LARGEUR_COLONNE + self.margeInter) * 2,
                      self.margeBord, LARGEUR_COLONNE, self.hauteurColonne)
        frame3 = Frame(x,
                       y,
                       l,
                       h,
                       id='F2',
                       leftPadding=0,
                       topPadding=0,
                       rightPadding=0,
                       bottomPadding=0)

        PageTemplate.__init__(self, id, [frame1, frame2, frame3], Template)
コード例 #34
0
ファイル: libReport.py プロジェクト: ajmal017/stock-study
 def initLandScape(cls,filename, **kw):
     params = deepcopy(cls.default_init)
     params.update(kw)
     ret = cls(filename,**params)
     width, height = landscape(letter)
     frame = cls.initFrame(width, height)
     template = PageTemplate(id='landscape',frames =[frame], onPage=make_landscape)
     ret.addPageTemplates(template)
     return ret
コード例 #35
0
ファイル: libReport.py プロジェクト: ajmal017/stock-study
 def initPortrait(cls,filename, **kw):
     params = deepcopy(cls.default_init)
     params.update(kw)
     ret = cls(filename,**params)
     width, height = letter
     frame = cls.initFrame(width, height)
     template = PageTemplate(id='portrait',frames =[frame], onPage=make_portrait)
     ret.addPageTemplates(template)
     return ret
コード例 #36
0
 def __init__(self, id=-1, pageSize=None, rect=None):
     self.pageWidth = pageSize[0]
     self.pageHeight = pageSize[1]
     
     self.hauteurColonne = 700
     self.margeBord = 40
     self.margeInter = 20
     
     x, y, l, h = (self.margeBord, self.margeBord, LARGEUR_COLONNE, self.hauteurColonne)
     frame1 = Frame(x, y, l, h, id='F1', leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0)
     
     x, y, l, h = (self.margeBord+LARGEUR_COLONNE+self.margeInter, self.margeBord, LARGEUR_COLONNE, self.hauteurColonne)
     frame2 = Frame(x, y, l, h, id='F2', leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0)
     
     x, y, l, h = (self.margeBord+(LARGEUR_COLONNE+self.margeInter)*2, self.margeBord, LARGEUR_COLONNE, self.hauteurColonne)
     frame3 = Frame(x, y, l, h, id='F2', leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0)
     
     PageTemplate.__init__(self, id, [frame1, frame2, frame3], Template) 
コード例 #37
0
 def __init__(self, filename, **kw):
     BaseDocTemplate.__init__(self, filename, **kw)
     self.addPageTemplates([
         PageTemplate(
             id='plain',
             frames=[Frame(2.5 * cm, 2.5 * cm, 16 * cm, 25 * cm, id='F1')]),
         LeftPageTemplate(),
         RightPageTemplate()
     ])
コード例 #38
0
 def __init__(self, filename, **kw):
     frame1 = Frame(1 * cm,
                    1 * cm,
                    18.5 * cm,
                    27 * cm,
                    id='F1',
                    showBoundary=False)
     self.allowSplitting = 0
     apply(BaseDocTemplate.__init__, (self, filename), kw)
     self.addPageTemplates(PageTemplate('normal', [frame1]))
コード例 #39
0
 def __init__(self, filename, **kw):
     self.allowSplitting = 0
     kw['showBoundary']=1
     BaseDocTemplate.__init__(self, filename, **kw)
     self.addPageTemplates(
             [
             PageTemplate('normal',
                     [Frame(inch, inch, 6.27*inch, 9.69*inch, id='first',topPadding=0,rightPadding=0,leftPadding=0,bottomPadding=0,showBoundary=ShowBoundaryValue(color="red"))],
                     ),
             ])
コード例 #40
0
ファイル: pdf.py プロジェクト: nyuhuhuu/trachacks
    def __init__(self, id, pagesize, stickysize, cols, rows, show_boundary):
        margin_h = (pagesize[0] - stickysize[0] * cols) / (cols + 1)
        margin_v = (pagesize[1] - stickysize[1] * rows) / (rows + 1)

        if show_boundary:
            boundary = ShowBoundaryValue((0, 0, 0), 0.3)
        else:
            boundary = ShowBoundaryValue((0.75, 0.75, 0.75), 0.05)

        frames = []
        for ridx in xrange(rows):
            for cidx in xrange(cols):
                frame_type = Frame(
                    x1=cidx * (margin_h + stickysize[0]) + margin_h,
                    y1=pagesize[1] - (ridx + 1) * (margin_v + stickysize[1]),
                    width=stickysize[0],
                    height=stickysize[1],
                    leftPadding=12,
                    bottomPadding=12,
                    rightPadding=8,
                    topPadding=8,
                    showBoundary=0,
                )
                frame_main = Frame(
                    x1=cidx * (margin_h + stickysize[0]) + margin_h,
                    y1=pagesize[1] - (ridx + 1) * (margin_v + stickysize[1]),
                    width=stickysize[0],
                    height=stickysize[1],
                    leftPadding=12,
                    bottomPadding=12,
                    rightPadding=16,
                    topPadding=8,
                    showBoundary=boundary,
                )
                frames.append(frame_type)
                frames.append(frame_main)

        PageTemplate.__init__(self, id=id, frames=frames, pagesize=pagesize)
コード例 #41
0
ファイル: sco_pdf.py プロジェクト: denys-duchier/Scolar
 def __init__(self, document, pagesbookmarks={},
              author=None, title=None, subject=None,
              margins = (0,0,0,0), # additional margins in mm (left,top,right, bottom)
              server_name = '',
              footer_template = DEFAULT_PDF_FOOTER_TEMPLATE,
              filigranne=None,
              preferences=None # dictionnary with preferences, required
              ):
     """Initialise our page template."""
     self.preferences = preferences
     self.pagesbookmarks = pagesbookmarks
     self.pdfmeta_author = author
     self.pdfmeta_title = title
     self.pdfmeta_subject = subject
     self.server_name = server_name
     self.filigranne = filigranne
     self.footer_template = footer_template
     # Our doc is made of a single frame
     left, top, right, bottom = [ float(x) for x in margins ]
     content = Frame(10.*mm + left*mm, 13.*mm + bottom*mm,
                     document.pagesize[0] - 20.*mm - left*mm - right*mm,
                     document.pagesize[1] - 18.*mm - top*mm - bottom*mm)
     PageTemplate.__init__(self, "ScolarsPageTemplate", [content])
     self.logo = None
コード例 #42
0
ファイル: xhtml2pdf_reportlab.py プロジェクト: frol/xhtml2pdf
 def __init__(self, **kw):
     self.pisaStaticList = []
     self.pisaBackgroundList = []
     self.pisaBackground = None
     PageTemplate.__init__(self, **kw)
コード例 #43
0
    def __init__(self):
        # allow a bigger margin on the right for the staples
        frame = Frame(1.5 * cm, 2.5 * cm, 16 * cm, 25 * cm, id="F1")

        PageTemplate.__init__(self, id="left", frames=[frame], pagesize=A4)