Exemple #1
0
 def __init__(self, output, fname, **kw):
     self.allowSplitting = 0
     filename = fname
     BaseDocTemplate.__init__(self, filename, **kw)
     padding = dict(leftPadding=px(5),
                    bottomPadding=px(5),
                    rightPadding=px(5),
                    topPadding=px(5))
     template2 = PageTemplate('normal', [
         Frame(0, 0, px(100), py(100), **padding, id='F1'),
         Frame(px(95), py(95), px(5), py(5), id='F3')
     ],
                              onPage=self.add_page_number,
                              onPageEnd=self.add_page_number)
     template1 = PageTemplate(
         'cover', [Frame(0, 0, px(100), py(100), **padding, id='F2')],
         onPage=self.add_author,
         onPageEnd=self.add_author,
         autoNextPageTemplate=1)
     self.addPageTemplates([template1, template2])
     self.stories = []
     self.PB = PageBuilder(stories=self.stories)
     self.output = output
     self.header = None
     self.cover()
     self.section()
     self.build(self.stories)
 def __init__(self,title, author, filename=None, size=(4,6), sb=0):
     (height,width,) = size
     if not filename:
         self.filename="%s-%sx%s.pdf" % (title,str(height),str(width))
     else:
         self.filename=filename
     pagesize = (width*inch,height*inch)
     F=Frame(0,0,width*inch,height*inch,
               leftPadding=0.5*inch,
               bottomPadding=0.50*inch,
               rightPadding=0.25*inch,
               topPadding=0.25*inch,
               showBoundary=sb)
     PT = PageTemplate(id="Notecard", frames=[F,])
     BaseDocTemplate.__init__(self, self.filename,
                              pageTemplates=[PT,], 
                              pagesize=pagesize,
                              showBoundary=sb,
                              leftMargin=0,
                              rightMargin=0,
                              topMargin=0,
                              bottomMargin=0,
                              allowSplitting=1,
                              title=title,
                              author=author)
 def __init__(self, filename, **kw):
     frame1 = Frame(2.5 * cm, 2.5 * cm, 16 * cm, 25 * cm, id='Frame1')
     self.allowSplitting = 0
     self.showBoundary = 1
     BaseDocTemplate.__init__(self, filename, **kw)
     template = PageTemplate('normal', [frame1], myMainPageFrame)
     self.addPageTemplates(template)
 def __init__(self, filename, **kw):
     frame1 = Frame(2.5*cm, 2.5*cm, 16*cm, 25*cm, id='Frame1')
     self.allowSplitting = 0
     self.showBoundary = 1
     BaseDocTemplate.__init__(self, filename, **kw)
     template = PageTemplate('normal', [frame1], myMainPageFrame)
     self.addPageTemplates(template)
Exemple #5
0
    def __init__(self, filename, **kw):
        m = 2 * cm
        cw, ch = (PAGESIZE[0] - 2 * m) / 2., (PAGESIZE[1] - 2 * m)

        # if we replace the value 4.9 with 5.0, everything works as expected
        f1 = Frame(m,
                   m + 0.5 * cm,
                   cw + 4.9 * cm,
                   ch - 1 * cm,
                   id='F1',
                   leftPadding=0,
                   topPadding=0,
                   rightPadding=0,
                   bottomPadding=0,
                   showBoundary=True)
        f2 = Frame(cw + 7 * cm,
                   m + 0.5 * cm,
                   cw - 5 * 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)
Exemple #6
0
 def __init__(self, filename, **kw):
     m = 2 * cm
     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.9 * 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)
Exemple #7
0
 def __init__(self, filename="/tmp/rpt001.pdf", **kw):
     """
     constructor of the object
     """
     RptSuperclass.__init__(self)
     self._element_type = "document"
     BaseDocTemplate.__init__(self, filename, **kw)
     self.pagesize = A4
     self.title = u"ict-ok.org Report"
     self.author = u"ict-ok.org"
     self.subject = u"ict-ok.org Report"
     self.leftMargin = 2*cm
     self.rightMargin = 2*cm
     self.topMargin = 2*cm
     self.bottomMargin = 2*cm
     self.showBoundary = False
     #self.allowSplitting = False
     rptFrame01 = RptFrame(2*cm, 25*mm, 165*mm, 24.7*cm) # , showBoundary=True)
     rptPageT01 = RptPageTemplate(u"RptTP1", [rptFrame01], pagesize=A4)
     self.addPageTemplates(rptPageT01)
     registerRptFonts()
     #addMappingRptFonts()
     self.styles = getRptStyleSheet()
     self.seq = Sequencer()
     self.seq.chain('Chapter01', 'Chapter02')
     self.seq.chain('Chapter02', 'Chapter03')
     self.seq.chain('Chapter03', 'Chapter04')
     self.seq.chain('Chapter04', 'Chapter05')
     self.seq.chain('Chapter05', 'Chapter06')
     self.volumeNo = None
     self.authorName = None
     self.versionStr = None
     self.firstPageTitle = None
     self.lastPageTitle = None
     self.firstH1Seen = False
Exemple #8
0
    def __init__(self, *args, **kwargs):
        from reportlab.lib.units import cm

        kwargs.setdefault('leftMargin', 1.5 * cm)
        kwargs.setdefault('rightMargin', 1.5 * cm)
        kwargs.setdefault('bottomMargin', 1.5 * cm)

        BaseDocTemplate.__init__(self, *args, **kwargs)
 def __init__(self, *args, **kwargs):
     BaseDocTemplate.__init__(self, *args, **kwargs)
     self.metadata = {
         "locations": {
             "signatures": list()
         }
     }
     self.sig_counter = 0
Exemple #10
0
 def __init__(self, name, teacher):
     self.PAGE_WIDTH = A4[0]
     self.PAGE_HEIGHT = A4[1]
     self.CENTRE_WIDTH = self.PAGE_WIDTH/2.0
     self.CENTRE_HEIGHT = self.PAGE_HEIGHT/2.0
     BaseDocTemplate.__init__(self,name, pagesize=A4, topMargin=0.5*cm)
     self.fileName = name
     self.teacher = teacher
Exemple #11
0
  def __init__(self, *args, **kwargs):
    from reportlab.lib.units import cm

    if not kwargs.has_key('leftMargin'): kwargs['leftMargin'] = 1.5 * cm
    if not kwargs.has_key('rightMargin'): kwargs['rightMargin'] = 1.5 * cm
    if not kwargs.has_key('bottomMargin'): kwargs['bottomMargin'] = 1.5 * cm

    BaseDocTemplate.__init__(self, *args, **kwargs)
Exemple #12
0
    def __init__(self, *args, **kwargs):
        BaseDocTemplate.__init__(self, *args, **kwargs)
        self.numPages = 0
        self._lastNumPages = 0
        self.setProgressCallBack(self._onProgress_cb)

        # For batch reports with several PDFs concatenated
        self.restartDoc = False
        self.restartDocIndex = 0
        self.restartDocPageNumbers = []
Exemple #13
0
    def __init__(self, *args, **kwargs):
        BaseDocTemplate.__init__(self, *args, **kwargs)
        self.numPages = 0
        self._lastNumPages = 0
        self.setProgressCallBack(self._onProgress_cb)

        # For batch reports with several PDFs concatenated
        self.restartDoc = False
        self.restartDocIndex = 0
        self.restartDocPageNumbers = []
Exemple #14
0
 def __init__(self, *args, **kwargs):
     # letter 21.6 x 27.9
     kwargs['pagesize'] = letter
     kwargs['rightMargin'] = 1 * cm
     kwargs['leftMargin'] = 1 * cm
     kwargs['topMargin'] = 4 * cm
     kwargs['bottomMargin'] = 2 * cm
     BaseDocTemplate.__init__(self, *args, **kwargs)
     self.styles = getSampleStyleSheet()
     self.header = {}
     self.data = []
    def __init__(self, *args, **kw):
        BaseDocTemplate.__init__(self, *args, **kw)

        doc = self
        columns = []
        columns.append(FancyFrame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height))
        
        #doc.showBoundary = True
        doc.addPageTemplates([
                PageTemplate(id='OneColumn', frames=columns),
                ])
Exemple #16
0
 def __init__(self, *args, **kwargs):
     # letter 21.6 x 27.9
     kwargs['pagesize'] = letter
     kwargs['rightMargin'] = 1 * cm
     kwargs['leftMargin'] = 1 * cm
     kwargs['topMargin'] = 4 * cm
     kwargs['bottomMargin'] = 2 * cm
     BaseDocTemplate.__init__(self, *args, **kwargs)
     self.styles = getSampleStyleSheet()
     self.header = {}
     self.data = []
Exemple #17
0
 def __init__(self, filename, org, margin=2*cm, sep=0.2*cm, **kw):
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     self.margin = margin
     self.w, self.h = self.pagesize
     self.sep = sep
     self.org = org
     template = PageTemplate('normal', frames=[Frame(self.leftMargin, self.bottomMargin, self.width, self.height, id='F1')], onPage=self.laterPages)
     self.addPageTemplates(template)
     self.PAGE_FOOTER_LEFT = _("GDPR Registry of Data Processing Activities for %s")
     self.PAGE_FOOTER_RIGHT = _("Page %d")
     self.GENERATED_ON = _("Report generated on {date}")
     self.POWERED_BY = _("Powered by")
Exemple #18
0
    def __init__(self, *args, **kw):
        BaseDocTemplate.__init__(self, *args, **kw)

        doc = self
        columns = []
        columns.append(FancyFrame(doc.leftMargin, doc.bottomMargin, 
                                  doc.width, doc.height))
        
        doc.addPageTemplates([
                PageTemplate(id='OneColumn', frames=columns),
                ])
        doc.pageheader = None
        doc.pagefooter = None
Exemple #19
0
 def __init__(self, filename, org, margin=2*cm, sep=0.2*cm, **kw):
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     self.margin = margin
     self.w, self.h = self.pagesize
     self.sep = sep
     self.org = org
     template = PageTemplate('normal', frames=[Frame(self.leftMargin, self.bottomMargin, self.width, self.height, id='F1')], onPage=self.laterPages)
     self.addPageTemplates(template)
     self.PAGE_FOOTER_LEFT = _("LGPD Web App %s")
     self.PAGE_FOOTER_RIGHT = _("Pagina %d")
     self.GENERATED_ON = _("Relatorio gerado em {date}")
     self.POWERED_BY = _("Powered by")
Exemple #20
0
 def __init__(self, *args, **kwargs):
     self.has_title_page = kwargs.pop('has_title_page', False)
     frame = Frame(
         left_margin, bottom_margin, frame_width, frame_height,
         id='normal',
         leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0
     )
     pageTemplates = [
         PageTemplate(id='standard', frames=[frame])
     ]
     BaseDocTemplate.__init__(
         self, pageTemplates=pageTemplates, *args, **kwargs
     )
Exemple #21
0
 def __init__(self, *args, **kwargs):
     self.has_title_page = kwargs.pop('has_title_page', False)
     frame = Frame(
         left_margin, bottom_margin, frame_width, frame_height,
         id='normal',
         leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0
     )
     pageTemplates = [
         PageTemplate(id='standard', frames=[frame])
     ]
     BaseDocTemplate.__init__(
         self, pageTemplates=pageTemplates, *args, **kwargs
     )
 def __init__(self, filename, **kw):
     frame1 = platypus.Frame(inch,
                             5.6 * inch,
                             6 * inch,
                             5.2 * inch,
                             id='F1')
     frame2 = platypus.Frame(inch,
                             inch,
                             6 * inch,
                             4.5 * inch,
                             showBoundary=1,
                             id='F2')
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     self.addPageTemplates(
         PageTemplate('normal', [frame1, frame2], framePage))
    def __init__(self, *args, **kw):
        BaseDocTemplate.__init__(self, *args, **kw)

        doc = self
        columns = []
        interFrameMargin = 0.2*inch
        frameWidth = doc.width / 3 - interFrameMargin
        columns.append(FancyFrame(doc.leftMargin, doc.bottomMargin, frameWidth, doc.height))
        columns.append(FancyFrame(doc.leftMargin + frameWidth + interFrameMargin, 
                             doc.bottomMargin, frameWidth, doc.height))
        columns.append(FancyFrame(doc.leftMargin + 2 * frameWidth + 2 * interFrameMargin,
                             doc.bottomMargin, frameWidth, doc.height))
        
        #doc.showBoundary = True
        doc.addPageTemplates([
                PageTemplate(id='ThreeColumn', frames=columns),
                ])
Exemple #24
0
    def __init__(
            self,
            title="Sahana Eden",
            margin=(
                0.5 * inch,  # top
                0.3 * inch,  # left
                0.5 * inch,  # bottom
                0.3 * inch),  # right
            margin_inside=0.0 * inch,  # used for odd even pages
            paper_size=None,
            paper_alignment="Portrait"):
        """
            Set up the standard page templates
        """

        self.output = StringIO()
        self.defaultPage = paper_alignment
        if paper_size:
            self.paper_size = paper_size
        else:
            settings = current.deployment_settings
            if settings.get_paper_size() == "Letter":
                self.paper_size = LETTER
            else:
                self.paper_size = A4
        self.topMargin = margin[0]
        self.leftMargin = margin[1]
        self.bottomMargin = margin[2]
        self.rightMargin = margin[3]
        self.insideMargin = margin_inside

        BaseDocTemplate.__init__(
            self,
            self.output,
            title=title,
            leftMargin=self.leftMargin,
            rightMargin=self.rightMargin,
            topMargin=self.topMargin,
            bottomMargin=self.bottomMargin,
        )

        self.MINIMUM_MARGIN_SIZE = 0.2 * inch
        self.body_flowable = None

        self._calc()
Exemple #25
0
    def __init__(self,
                 title = "Sahana Eden",
                 margin = (0.5 * inch,  # top
                           0.3 * inch,  # left
                           0.5 * inch,  # bottom
                           0.3 * inch), # right
                 margin_inside = 0.0 * inch, # used for odd even pages
                 paper_size = None,
                 paper_alignment = "Portrait"):
        """
            Set up the standard page templates
        """

        self.output = StringIO()
        self.defaultPage = paper_alignment
        if paper_size:
            self.paper_size = paper_size
        else:
            settings = current.deployment_settings
            if settings.get_paper_size() == "Letter":
                self.paper_size = LETTER
            else:
                self.paper_size = A4
        self.topMargin = margin[0]
        self.leftMargin = margin[1]
        self.bottomMargin = margin[2]
        self.rightMargin = margin[3]
        self.insideMargin = margin_inside

        BaseDocTemplate.__init__(self,
                                 self.output,
                                 title = title,
                                 leftMargin = self.leftMargin,
                                 rightMargin = self.rightMargin,
                                 topMargin = self.topMargin,
                                 bottomMargin = self.bottomMargin,
                                 )

        self.MINIMUM_MARGIN_SIZE = 0.2 * inch
        self.body_flowable = None

        self._calc()
Exemple #26
0
 def __init__(self, *args, **kwargs):
     x = 2*cm
     w_form1, h_form1 = W/2, 2.7*cm
     w_form2, h_form2 = W/2 - 4*cm, h_form1
     y_form           = H - 5*cm
     w_table, h_table = (W - 3.9*cm)/5, 17.5*cm
     y_table          = H - h_table - 6*cm
     w_logo, h_logo   = 3.4*cm, 2.5*cm
     y_logo           = H - 2*cm
     w_title, h_title = 5 * w_table, 0.6*cm
     w_serial, h_serial = 5*cm, h_title
     x_serial, y_serial = W - w_serial - 2*cm, H - h_serial
     y_title = y_table + h_table 
     x_signature, y_signature = 2*cm, 2*cm
     w_signature, h_signature = 5*cm, 2*cm
     pad = dict(('%sPadding' % d, 0) for d in ['left', 'right', 'top', 'bottom'])
     t1 = PageTemplate(id='p1', frames=[
         Frame(x, y_logo, w_logo, h_logo, id='logo', **pad),
         Frame(x_serial, y_serial, w_serial, h_title, id='serial', **pad),
         Frame(x,           y_form, w_form1, h_form1, id='left',  **pad),
         Frame(x + w_form1, y_form, w_form2, h_form2, id='right', **pad),
         Frame(x, y_title, w_title, h_title, id='title', **pad),
         Frame(x,             y_table, w_table, h_table, id='panel1', **pad),
         Frame(x + 1*w_table, y_table, w_table, h_table, id='panel2', **pad),
         Frame(x + 2*w_table, y_table, w_table, h_table, id='panel3', **pad),
         Frame(x + 3*w_table, y_table, w_table, h_table, id='panel4', **pad),
         Frame(x + 4*w_table, y_table, w_table, h_table, id='panel5', **pad),
     ], onPage=self.printFooter)
     h_table = H - 4*cm
     t2 = PageTemplate(id='p2', frames=[
         Frame(x,             y_table, w_table, h_table, id='panel1', **pad),
         Frame(x + 1*w_table, y_table, w_table, h_table, id='panel2', **pad),
         Frame(x + 2*w_table, y_table, w_table, h_table, id='panel3', **pad),
         Frame(x + 3*w_table, y_table, w_table, h_table, id='panel4', **pad),
         Frame(x + 4*w_table, y_table, w_table, h_table, id='panel5', **pad),
     ], onPage=self.printFooter)
     #kwargs['showBoundary'] = True
     BaseDocTemplate.__init__(self, *args, **kwargs)
     self.addPageTemplates([t1, t2])
    def __init__(self, request, report_name="Test PDF", title="Test PDF", subtitle=None, pagesize=A4, background=None, **kwargs):
        self.request = request
        self.report_name = report_name
        self.title = title
        self.subtitle = subtitle

        self.response = HttpResponse(content_type='application/pdf')
        self.response['Content-Disposition'] = 'attachment; filename=\"%s.pdf\"' % self.report_name

        #ReportLab uses old style classes, so super() doesn't work.
        BaseDocTemplate.__init__(self, self.response, pagesize=pagesize, **kwargs)

        if background != None:
            bg_image = BackgroundImage(background, pagesize)
        else: 
            bg_image = None

        self.addPageTemplates([
          CoverPageTemplate(title, subtitle, background=bg_image)
        , ReportPageTemplate(id='basic', pagesize=pagesize, background=bg_image)
        , ReportPageTemplate(id='2col', columns=2, pagesize=pagesize, background=bg_image)
        ])
 def __init__(self,filename, title, author):
     self.filename = filename
     #          (WIDTH,HEIGHT)
     pageSize = (6*inch,4*inch)
     #Frame(x1, y1, width,height, leftPadding=6, bottomPadding=6,
     #      rightPadding=6, topPadding=6, id=None, showBoundary=0)
     F = Frame(0,0,6*inch,4*inch,
               leftPadding=0.25*inch,
               bottomPadding=0.50*inch,
               rightPadding=0.25*inch,
               topPadding=0.25*inch,
               showBoundary=1)
     PT = PageTemplate(id="Notecard", frames=[F,])
     BaseDocTemplate.__init__(self, self.filename,
                              pageTemplates=[PT,], 
                              pagesize=pageSize,
                              showBoundary=1,
                              leftMargin=0,
                              rightMargin=0,
                              topMargin=0,
                              bottomMargin=0,
                              allowSplitting=1,
                              title=title,
                              author=author)
Exemple #29
0
    def __init__(self, output, doc_type, company_data, _=six.text_type):
        """
        Instanciates a FreshDocTemplate.
        output: string or output flow. name of the PDF output file or
                writable flow where to write the PDF output

        doc_type: string. type of the document that can be "refund"
                  (Refund) or or "expense" (Expense).
        company_data: {'':u"", }. dictionnary containing various data about
                      the company.
        """
        # Initializes the document template with the correct page templates
        templates = [FreshPageTemplate(doc_type, company_data,
                                       template_id="Pages", _=_)]
        BaseDocTemplate.__init__(self, output, pageTemplates=templates,
                                 allowSplitting=1)

        if doc_type == "refund":
            self.title = _(u"Refund Document")
        elif doc_type == "expense":
            self.title = _(u"Expense Document")
        else:
            self.title = u""
        self.author = company_data['company-name']
Exemple #30
0
    def __init__(self, *args, **kwargs):
        BaseDocTemplate.__init__(self, *args, **kwargs)

        self.estilos = getSampleStyleSheet()
        self.contenido = []
Exemple #31
0
    def __init__(
        self,
        pagesize,
        cardsize,
        margins=None,
        spacing=None,
        title=None,
    ):
        """
            Constructor

            @param pagesize: the page size, tuple (w, h)
            @param cardsize: the card size, tuple (w, h)
            @param margins: the page margins, tuple (N, E, S, W)
            @param spacing: the spacing between cards, tuple (H, V)
            @param title: the document title

            - all sizes in points (72 points per inch)
        """

        # Spacing between cards
        if spacing is None:
            spacing = (18, 18)
        elif not isinstance(spacing, (tuple, list)):
            spacing = (spacing, spacing)

        # Page margins
        if margins is None:
            margins = self.compute_margins(pagesize, cardsize, spacing)
        elif not isinstance(margins, (tuple, list)):
            margins = (margins, margins, margins, margins)

        # Cards per row, rows per page and cards per page
        pagewidth, pageheight = pagesize
        cardwidth, cardheight = cardsize

        number_of_cards = self.number_of_cards

        cards_per_row = number_of_cards(
            pagewidth,
            cardwidth,
            (margins[1], margins[3]),
            spacing[0],
        )

        rows_per_page = number_of_cards(
            pageheight,
            cardheight,
            (margins[0], margins[2]),
            spacing[1],
        )

        self.cards_per_row = cards_per_row
        self.rows_per_page = rows_per_page
        self.cards_per_page = rows_per_page * cards_per_row

        # Generate page templates
        pages = self.page_layouts(pagesize, cardsize, margins, spacing)

        if title is None:
            title = current.T("Items")

        # Call super-constructor
        BaseDocTemplate.__init__(
            self,
            None,
            pagesize=pagesize,
            pageTemplates=pages,
            topMargin=margins[0],
            rightMargin=margins[1],
            bottomMargin=margins[2],
            leftMargin=margins[3],
            title=s3_str(title),
        )
Exemple #32
0
 def __init__(self, filename, **kw):
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     template = PageTemplateWithCount(
         "normal", [Frame(2.5 * cm, 2.5 * cm, 15 * cm, 25 * cm, id='F1')])
     self.addPageTemplates(template)
Exemple #33
0
 def __init__(self, file, **kw):
     BaseDocTemplate.__init__(self,file, **kw)
 def __init__(self, *args, **kwargs):
     BaseDocTemplate.__init__(self, *args, **kwargs)
Exemple #35
0
    def __init__(self,
                 pagesize,
                 cardsize,
                 margins = None,
                 spacing = None,
                 title = None,
                 ):
        """
            Constructor

            @param pagesize: the page size, tuple (w, h)
            @param cardsize: the card size, tuple (w, h)
            @param margins: the page margins, tuple (N, E, S, W)
            @param spacing: the spacing between cards, tuple (H, V)
            @param title: the document title

            - all sizes in points (72 points per inch)
        """

        # Spacing between cards
        if spacing is None:
            spacing = (18, 18)
        elif not isinstance(spacing, (tuple, list)):
            spacing = (spacing, spacing)

        # Page margins
        if margins is None:
            margins = self.compute_margins(pagesize, cardsize, spacing)
        elif not isinstance(margins, (tuple, list)):
            margins = (margins, margins, margins, margins)

        # Cards per row, rows per page and cards per page
        pagewidth, pageheight = pagesize
        cardwidth, cardheight = cardsize

        number_of_cards = self.number_of_cards

        cards_per_row = number_of_cards(pagewidth,
                                        cardwidth,
                                        (margins[1], margins[3]),
                                        spacing[0],
                                        )

        rows_per_page = number_of_cards(pageheight,
                                        cardheight,
                                        (margins[0], margins[2]),
                                        spacing[1],
                                        )

        self.cards_per_row = cards_per_row
        self.rows_per_page = rows_per_page
        self.cards_per_page = rows_per_page * cards_per_row

        # Generate page templates
        pages = self.page_layouts(pagesize, cardsize, margins, spacing)

        if title is None:
            title = current.T("Items")

        # Call super-constructor
        BaseDocTemplate.__init__(self,
                                 None,
                                 pagesize = pagesize,
                                 pageTemplates = pages,
                                 topMargin = margins[0],
                                 rightMargin = margins[1],
                                 bottomMargin = margins[2],
                                 leftMargin = margins[3],
                                 title = s3_str(title),
                                 )
 def __init__(self, filename, **kw):
     frame1 = platypus.Frame(inch, 5.6 * inch, 6 * inch, 5.2 * inch, id="F1")
     frame2 = platypus.Frame(inch, inch, 6 * inch, 4.5 * inch, showBoundary=1, id="F2")
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
     self.addPageTemplates(PageTemplate("normal", [frame1, frame2], framePage))
Exemple #37
0
 def __init__(self, filename, initialSection=None, headerLeft="", headerRight="", **kw):
     BaseDocTemplate.__init__(self, filename, **kw)
     self.__section = initialSection
     self.__headerLeft = headerLeft
     self.__headerRight = headerRight
     self.__entryTitle = None
Exemple #38
0
 def __init__(self, *args, **kwargs):
     BaseDocTemplate.__init__(self, *args, **kwargs)
Exemple #39
0
    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)
Exemple #40
0
 def __init__(self, *args, **kwargs):
     ##TODO:        """Couldn 't we just inherit __int__?"""
     BaseDocTemplate.__init__(self, *args, **kwargs)
Exemple #41
0
 def __init__(self, instance):
     # Configuración
     filename = ruta + 'media/kids/guias/%d.pdf' % instance.id
     self.estilos = {
         'texto': ParagraphStyle(name='texto',
             alignment=TA_JUSTIFY,
             fontName='PatrickHand',
             fontSize=12,
             leading=17,
             firstLineIndent=20,
             ),
         'pregunta': ParagraphStyle(name='pregunta',
             alignment=TA_JUSTIFY,
             fontName='PatrickHand',
             fontSize=12,
             leading=20,
             firstLineIndent=30,
             ),
         'puntos': ParagraphStyle(name='puntos',
             alignment=TA_JUSTIFY,
             fontName='PatrickHand',
             fontSize=12,
             leading=25,
             ),
         'cabecera': ParagraphStyle(name='cabecera',
             alignment=TA_RIGHT,
             fontName='GloriaHallelujah',
             fontSize=9,
             leading=14,
             textColor='#444444',
             ),
         'titulo': ParagraphStyle(name='titulo',
             alignment=TA_CENTER,
             fontName='PermanentMarker',
             fontSize=20,
             leading=20,
             textColor='#00338e',
             ),
         'subtitulo': ParagraphStyle(name='subtitulo',
             alignment=TA_JUSTIFY,
             fontName='Julee',
             fontSize=14,
             leading=20,
             textColor='#00338e',
         ),
         'versiculo': ParagraphStyle(name='versiculo',
             alignment=TA_RIGHT,
             fontName='PatrickHand',
             fontSize=12,
             leading=14,
             firstLineIndent=100,
         ),
         'pupiletras': ParagraphStyle(name='pupiletras',
             alignment=TA_CENTER,
             fontName='DroidSansMono',
             fontSize=12,
             leading=15,
         ),
     }
     self.story = []
     self.header = 'Iglesia "La Palabra y El Espíritu"'
     BaseDocTemplate.__init__(self, filename)
     self.mostrar = 0
     self.allowSplitting = 1
     self.showBoundary = self.mostrar
     self.MARGEN = 0.5 * cm
     a4 = A4
     margen = self.MARGEN
     frameDatos = Frame(self.MARGEN * 2, self.MARGEN,
         A4[0] - 4 * self.MARGEN, A4[1] - 4 * self.MARGEN,
         id='datos', showBoundary=self.mostrar)
     height = frameDatos.height
     template = PageTemplate('pagina_normal', [frameDatos],
         self.formato)
     self.addPageTemplates(template)
     self.insertar(instance.nombre, 'titulo')
     self.insertar(u'Versículos de Estudio', 'subtitulo')
     estilo = 'texto'
     for linea in instance.versiculo.splitlines():
         self.insertar(linea, estilo)
         if estilo == 'texto':
             estilo = 'versiculo'
         else:
             estilo = 'texto'
     self.insertar(u'Bosquejo', 'subtitulo')
     estilo = 'texto'
     for linea in instance.bosquejo.splitlines():
         self.insertar(linea, estilo)
     self.insertar('Temas', 'subtitulo')
     for linea in instance.temas.splitlines():
         self.insertar('- ' + linea, 'texto')
     self.story.append(PageBreak())
     alto = 20
     alto += self.insertar(instance.nombre, 'titulo')
     alto += self.insertar(u'Versículo Para Memorizar', 'subtitulo')
     estilo = 'texto'
     for linea in instance.memorizar.splitlines():
         alto += self.insertar(linea, estilo)
         if estilo == 'texto':
             estilo = 'versiculo'
         else:
             estilo = 'texto'
     alto += self.insertar('Ejercicios Espirituales', 'subtitulo')        
     for linea in instance.ejercicios.splitlines():
         alto += self.insertar('- ' + linea, 'texto')
     ej = instance.ejercicios
     ruta_logo = instance.imagen
     url = ruta_logo.path
     img = utils.ImageReader(url)
     iw, ih = img.getSize()
     aspect = ih / float(iw)
     resta = int(height) - alto - 10
     logo = Image(url, width=(resta / aspect), height=resta)
     self.story.append(logo)
     logo.hAlign = 'CENTER'
     logo.vAlign = 'BOTTOM'
     self.insertar('Preguntas', 'subtitulo')
     i = 0
     for linea in instance.preguntas.splitlines():
         i += 1
         self.insertar(str(i) +'.- ' + linea, 'pregunta')
         self.insertar(97 * '. ', 'puntos')
         self.insertar(97 * '. ', 'puntos')
     self.insertar('Completa y Resuelve el Pupiletras', 'subtitulo')
     palabras = []
     for linea in instance.historia.splitlines():
         ps, l = self.parse(linea)
         palabras += ps
         self.insertar(l, 'texto')
     pupiletras = Pupiletras(palabras)
     pupi = unicode(pupiletras)
     self.story.append(Spacer(0, 20))
     for linea in pupi.splitlines():
         self.insertar(linea, 'pupiletras')
     NumberedCanvas(filename)
     self.build(self.story)
 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)
     self.addPageTemplates(PageTemplate('normal', [frame1], mainPageFrame))
Exemple #43
0
 def __init__(self, filename, **kw):
     kw['leftMargin'], kw['rightMargin'], kw['topMargin'], kw[
         'bottomMargin'] = 1.27 * cm, 1.27 * cm, 1.27 * cm, 1.27 * cm
     BaseDocTemplate.__init__(self, filename, **kw)
Exemple #44
0
 def __init__(self,
              filename,
              title,
              subject,
              author,
              pagesize=defaultPageSize,
              top=1,
              bottom=1,
              left=1,
              right=1,
              col=0.25):
     self.nTop, self.nBottom, self.nLeft, self.nRight, self.nCol = top, bottom, left, right, col
     self.pagesize = pagesize
     BaseDocTemplate.__init__(self, filename, pagesize=pagesize)
     if not title: title = u"Pydro Feature Report"
     if not author: author = u"NOAA"
     if not subject: subject = u"NOAA Hydrographic Survey"
     self.title, self.author, self.subject = GetUnicode(
         [title, author, subject])
     styleSheet = getSampleStyleSheet()
     styleSheet.add(ParagraphStyle(name='CenteredHeading1',
                                   parent=styleSheet['Title'],
                                   alignment=TA_CENTER),
                    alias='cenh1')
     styleSheet.add(ParagraphStyle(name='CenteredHeading2',
                                   parent=styleSheet['Heading2'],
                                   alignment=TA_CENTER),
                    alias='cenh2')
     styleSheet.add(ParagraphStyle(name='CenteredLabel2',
                                   parent=styleSheet['Heading2'],
                                   alignment=TA_CENTER),
                    alias='clab2')
     styleSheet.add(ParagraphStyle(name='FigCaption',
                                   parent=styleSheet['Italic'],
                                   alignment=TA_CENTER),
                    alias='figc')
     styleSheet.add(ParagraphStyle(name='CenteredDisc',
                                   parent=styleSheet['BodyText'],
                                   alignment=TA_CENTER),
                    alias='cend')
     self._T1 = styleSheet['Title']  # fontbasesize=18
     self._H2 = styleSheet['Heading2']  # fontbasesize=14
     self._CH1 = styleSheet['CenteredHeading1']  # fontbasesize=18
     self._CH2 = styleSheet['CenteredHeading2']  # fontbasesize=14
     self._CL2 = styleSheet['CenteredLabel2']  # fontbasesize=14
     self._FC = styleSheet['FigCaption']  # fontbasesize=10
     self._PC = copy.copy(styleSheet['FigCaption'])  # fontbasesize=10
     self._PC.name = 'PicCaption'  # not conditioned upon in afterFlowable()--for X.X.n labeling
     self._B = styleSheet['BodyText']  # fontbasesize=10
     self._CB = styleSheet['CenteredDisc']  # fontbasesize=10
     self._BU = styleSheet['Bullet']  # fontbasesize=10
     self.seq = getSequencer()
     self.seq.setFormat('Chapter', '1')  # TODO: change to 'Section'
     self.seq.reset('Chapter')
     self.seqChapter = {}
     self.seq.setFormat('Section', '1')  # TODO: change to 'SubSection'
     self.seq.reset('Section')
     self.seq.setFormat('Figure', '1')
     self.seq.reset('Figure')
     self.seqchainChapterSection = {}
     self.seq.chain('Section', 'Figure')
     self.report = {}
     self.reportOutlineLabels = {}
Exemple #45
0
 def __init__(self, filename, **kw):
     BaseDocTemplate.__init__(self, filename, **kw)
     self.afterFlowableCallbacks = []
Exemple #46
0
 def __init__(self, filename, **kw):
     """
     :rtype: object
     """
     self.allowSplitting = 0
     BaseDocTemplate.__init__(self, filename, **kw)
Exemple #47
0
 def __init__(self, filename):
     BaseDocTemplate.__init__(self, filename)
     self.button_renderer = ButtonRenderer()
     
     page_template = PageTemplate(frames=self._create_frames())
     self.addPageTemplates(page_template)
 def __init__(self, filename, **kw):
     BaseDocTemplate.__init__(self, filename, **kw)
     template = PageTemplate('normal', [Frame(2.5 * cm, 2.5 * cm, 16 * cm, 25 * cm, id='Frame1')])  # 页面模版
     self.addPageTemplates(template)  # 将页面模版加入到文档对象