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


Python platypus.BaseDocTemplate类代码示例

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


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

示例1: build

 def build(self, printfile, style=1):
     template = SimpleDocTemplate(printfile, showBoundary=0)
     tFirst = PageTemplate(id='First', frames=self.getStyle(1, style), onPage=self.myPages, pagesize=defaultPageSize)
     tNext = PageTemplate(id='Later', frames=self.getStyle(2, style), onPage=self.myPages, pagesize=defaultPageSize)
     template.addPageTemplates([tFirst, tNext])
     template.allowSplitting = 1
     BaseDocTemplate.build(template, self.data)
开发者ID:mediatum,项目名称:mediatum,代码行数:7,代码来源:printview.py

示例2: _create_application

def _create_application(application_buffer, application):
    every_page_frame = Frame(PAGE_MARGIN, PAGE_MARGIN, PAGE_WIDTH - 2 * PAGE_MARGIN, PAGE_HEIGHT - 2 * PAGE_MARGIN,
                             id='EveryPagesFrame')
    every_page_template = PageTemplate(id='EveryPages', frames=[every_page_frame])

    doc = BaseDocTemplate(application_buffer, pageTemplates=[every_page_template], pagesize=A4)

    elements = []

    elements.append(Paragraph(application.licence_type.name.encode('UTF-8'), styles['ApplicationTitle']))

    # cannot use licence get_title_with_variants because licence isn't saved yet so can't get variants
    if application.variants.exists():
        variants = '({})'.format(' / '.join(application.variants.all().values_list('name', flat=True)))
        elements.append(Paragraph(variants, styles['ApplicationVariantsTitle']))

    elements.append(Spacer(1, SECTION_BUFFER_HEIGHT))

    elements.append(_create_application_metadata(application))

    elements.append(Spacer(1, SECTION_BUFFER_HEIGHT))

    for field, datum in zip(application.licence_type.application_schema, application.data):
        _create_application_questionaire(field, datum, elements, 0)

    doc.build(elements)

    return application_buffer
开发者ID:wilsonc86,项目名称:ledger,代码行数:28,代码来源:pdf.py

示例3: __init__

 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)
开发者ID:ingob,项目名称:mwlib.ext,代码行数:7,代码来源:test_platypus_xref.py

示例4: create_pdf

def create_pdf(togen, template_page, pos, dat):
    "Create the pdf, stream api"
    document = BaseDocTemplate(togen)
    page = MyPage(template_page, name='background') 
    document.addPageTemplates([page])
    elements = [NextPageTemplate('background')]
    # may add flowables to element here
    
    # add absolute content
    for posname in dat:
        if posname.startswith("_"): # ignore extra info
            continue
        if posname not in pos:
            raise Exception("%s does not have a position" % posname)
        tup = pos[posname]
        x, y = tup[0], tup[1]
        width = tup[2] if len(tup)>2 else PAGE_WIDTH
        style = tup[3] if len(tup)>3 else DEFAULT_STYLE
        data = dat[posname]
        if type(data) in (str, unicode):
            page.addAbsParagraph(data, x, y, width, style)
        else:
            page.addAbsPrimitive(data, x, y, width) # don't need no style
    # create page
    document.multiBuild(elements)
开发者ID:hesrerem,项目名称:pdffill,代码行数:25,代码来源:pdffill.py

示例5: handle_flowable

    def handle_flowable(self, flowables):
        f = flowables[0]
        BaseDocTemplate.handle_flowable(self, flowables)

        if hasattr(f, "link_object"):
            (obj, text) = f.link_object

            if type(obj).__name__ == "Club":
                if obj.departement != self.club_seen:
                    key = "Departement{}".format(obj.departement)
                    self.canv.bookmarkPage(key)
                    self.canv.addOutlineEntry("Département {}".format(obj.departement), key, level=0, closed=1)
                    self.club_seen = obj.departement
                level = 1

            elif type(obj).__name__ == "Competition":
                if not self.competition_seen:
                    key = "Competition"
                    self.canv.bookmarkPage(key)
                    self.canv.addOutlineEntry("Détail des compétitions", key, level=0, closed=1)
                    self.competition_seen = True
                level = 1

            else:
                level = 2

            key = obj.link()
            self.canv.bookmarkPage(key)
            self.canv.addOutlineEntry(text, key, level=level, closed=1)
开发者ID:dricair,项目名称:officiels,代码行数:29,代码来源:gen_pdf.py

示例6: build

    def build(self, flowables, onFirstPage=_doNothing, onLaterPages=_doNothing, canvasmaker=Canvas):
        #Override the build method
        self._calc()    #in case we changed margins sizes etc
        self.canvas = canvasmaker
        firstFrame = Frame(10,        # X
                       0,            # Y
                       A4[0]-20,     # width
                       A4[1]-106,     # height
                       id='normal')

        secondFrame = Frame(10,          # X
                       0,            # Y
                       A4[0]-20,     # width
                       A4[1]-46,     # height
                       #showBoundary=True,
                       id='normal')        
        
        self.addPageTemplates([PageTemplate(id='First',
                                            frames=[firstFrame],
                                            pagesize=self.pagesize,
                                            onPage=onFirstPage),
                                PageTemplate(id='Later',
                                            frames=[secondFrame],
                                            pagesize=self.pagesize,
                                            onPage=onLaterPages),
                                ]
        )
        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:alberto-sanchez,项目名称:PHEDEX,代码行数:32,代码来源:__init__.py

示例7: ReporteVertical

class ReporteVertical(object):
	"""docstring for ReporteVertical"""
	def __init__(self, nombreReporteP, directorioArchivoP, operadorP):
		super(ReporteVertical, self).__init__()
		self.PAGE_HEIGHT = letter[1]
		self.PAGE_WIDTH = letter[0]
		self.story = []
		self.styles = getSampleStyleSheet()
		self.nombreReporte = str(nombreReporteP)
		self.dirArchivo = str(directorioArchivoP)
		self.tipoArchivo = ".pdf"
		global operador
		global imagenes
		operador = str(operadorP)
		imagenes = ['static/image/universidad.jpg', 'static/image/alcaldia.png']

	def inicializarReporte(self, nombreReporteP):
		self.doc = BaseDocTemplate(nombreReporteP, pagesize=letter)

	def contenidoFrame(self):
		self.contenidoFrame = Frame(self.doc.leftMargin, (self.doc.height - self.doc.topMargin), self.doc.width, self.doc.height / 6, showBoundary=1)

	def constructorPaginas(self):
		self.doc.addPageTemplates([PageTemplate(id='reporte', frames=self.contenidoFrame, onPage =encabezado, onPageEnd=piePagina)])

	def crearReporteVertical(self):
		try:
			self.inicializarReporte(os.path.join(self.dirArchivo, self.nombreReporte + self.tipoArchivo))
			self.contenidoFrame()
			self.constructorPaginas()
			self.story.append(Paragraph("El viaje del navegante. Blog de Python", self.styles['Normal']))
			self.doc.build(self.story)
			os.system(os.path.join(self.dirArchivo, self.nombreReporte + self.tipoArchivo))
		except Exception, e:
			print e
开发者ID:mfreyeso,项目名称:SIPREM,代码行数:35,代码来源:reporteVertical.py

示例8: build_pdf

def build_pdf(filename):
    doc = BaseDocTemplate(filename)
    
    column_gap = 1 * cm
    
    doc.addPageTemplates(
        [
            PageTemplate(
                frames=[
                    Frame(
                        doc.leftMargin,
                        doc.bottomMargin,
                        doc.width / 2,
                        doc.height,
                        id='left',
                        rightPadding=column_gap / 2,
                        showBoundary=0  # set to 1 for debugging
                    ),
                    Frame(
                        doc.leftMargin + doc.width / 2,
                        doc.bottomMargin,
                        doc.width / 2,
                        doc.height,
                        id='right',
                        leftPadding=column_gap / 2,
                        showBoundary=0
                    ),
                ]
            ),
        ]
    )
    flowables = [
        Paragraph('word ' * 700, ParagraphStyle('default')),
    ]
    doc.build(flowables)
开发者ID:pythonpatterns,项目名称:patterns,代码行数:35,代码来源:p0149.py

示例9: __init__

 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)
开发者ID:cynyr,项目名称:recipe-management-system,代码行数:25,代码来源:PrintOut.py

示例10: fill

    def fill(self, fname, pagesize, events, topspace, bottomspace, margins):
        tf = tempfile.NamedTemporaryFile(delete=False)
        pagesize = (pagesize[0] / 2 - 6, pagesize[1])
        doc = BaseDocTemplate(tf.name, pagesize=pagesize, leftMargin=margins, bottomMargin=bottomspace, rightMargin=margins, topMargin=topspace)
        column = Frame(doc.leftMargin+6, doc.bottomMargin+0.5*inch, doc.width-6, 3.3*inch)
        rsvp = Frame(doc.leftMargin+6, doc.bottomMargin, doc.width-6, 0.5*inch)
        doc.addPageTemplates(PageTemplate(frames=[rsvp, column]))

        # render one side
        story = []
        story.append(Paragraph("Please RSVP at map.berniesanders.com", styles["default"]))
        story.append(FrameBreak())
        for e in events:
            story.append(Event(e).render())
        doc.build(story)

        # now duplicate for 2-up
        src = PdfFileReader(open(tf.name, "rb"))
        out = PdfFileWriter()
        lhs = src.getPage(0)
        lhs.mergeTranslatedPage(lhs, lhs.mediaBox.getUpperRight_x(), 0, True)
        out.addPage(lhs)
        with open(fname.name, "wb") as outfile:
            out.write(outfile)
        os.remove(tf.name)
开发者ID:12foo,项目名称:event-flyer-factory,代码行数:25,代码来源:layouts.py

示例11: create_pdf

def create_pdf(data):
	report_header='./static/images/report-header.jpg'
	other_header='./static/images/report-header2.jpg'
	today=data[0]
	pname=data[1]
	orgname=data[2]
	mission=data[3]
	product=data[4]
	puser=data[5]
	inputs=data[6]
	outputs=data[7]
	controls=data[8]
	plots=data[9]
	regs=data[10]
	reporttext = []
	#File Name
	pdfname="hello"+pname+"_"+today
	doc=BaseDocTemplate(pdfname,pagesize=letter)
	frame=Frame(doc.leftMargin,doc.bottomMargin,doc.width,doc.height,id='normal')
	template=PageTemplate(id='test',frames=frame,onPage=footer)
	doc.addPageTemplates([template])
	styles = getSampleStyleSheet()
	methods="In keeping with the ReadyMade tenet to keep the analysis simple, we look for one key outcome variable that is highly correlated with the other available outcome variables "
	reporttext.append(Paragraph(methods,styles['Normal']))
	doc.build(metext)
	return pdfname
开发者ID:priya-I,项目名称:ReadyMade,代码行数:26,代码来源:test.py

示例12: makeForm

def makeForm():
    ''' Make PDF of MyPidge app form. '''
    posts = []
    pageWidth, pageHeight = A4
    formPages = (
    FormFront(None),
    FormFront(None),
    FormFront(None),
    FormFront(None),
    FormBack(None),
    FormBack(None),
    FormBack(None),
    FormBack(None),
    )
    for (offset, frame) in enumerate(formPages):
        posts.append(frame.makeFrame())
        if len(formPages)==(offset+1):
            # Break page at end of a PocketPidge
            # But need to do this twice if on an odd page
            posts.append(PageBreak())
        else:
            posts.append(FrameBreak())
        
    # Build File
    document = BaseDocTemplate("form.pdf", pagesize=A4)
    template = PageTemplate(frames=createFrames(pageWidth, pageHeight, 2, 2))
    document.addPageTemplates(template)
    document.build(posts)
开发者ID:fergusrossferrier,项目名称:mypidge.com,代码行数:28,代码来源:PocketPidge.py

示例13: build

    def build(self,
              header_flowable,
              body_flowable,
              footer_flowable,
              canvasmaker=canvas.Canvas):
        """
            Build the document using the flowables.

            Set up the page templates that the document can use

        """
        self.header_flowable = header_flowable
        self.body_flowable = body_flowable
        self.footer_flowable = footer_flowable
        self.calc_body_size(header_flowable,
                            footer_flowable,
                           )
        showBoundary = 0 # for debugging set to 1, otherwise 0

        body_frame = Frame(self.leftMargin,
                           self.bottomMargin + self.footer_height,
                           self.printable_width,
                           self.body_height,
                           leftPadding = 0,
                           bottomPadding = 0,
                           rightPadding = 0,
                           topPadding = 0,
                           id = "body",
                           showBoundary = showBoundary
                          )

        self.body_frame = body_frame
        self.normalPage = PageTemplate (id = 'Normal',
                                        frames = [body_frame,],
                                        onPage = self.add_page_decorators,
                                        pagesize = self.pagesize
                                       )
        # @todo set these page templates up
#        self.evenPage = PageTemplate (id='even',
#                                      frames=frame_list,
#                                      onPage=self.onEvenPage,
#                                      pagesize=self.pagesize
#                                     )
#        self.oddPage = PageTemplate (id='odd',
#                                     frames=frame_list,
#                                     onPage=self.onOddPage,
#                                     pagesize=self.pagesize
#                                    )
        self.landscapePage = PageTemplate (id='Landscape',
                                           frames = [body_frame,],
                                           onPage=self.add_page_decorators,
                                           pagesize=landscape(self.pagesize)
                                          )
        if self.defaultPage == "Landscape":
            self.addPageTemplates(self.landscapePage)
        else:
            self.addPageTemplates(self.normalPage)

        BaseDocTemplate.build(self, self.body_flowable, canvasmaker=canvasmaker)
开发者ID:hooari,项目名称:eden,代码行数:59,代码来源:pdf.py

示例14: __init__

 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
开发者ID:epcoullery,项目名称:ase,代码行数:8,代码来源:models.py

示例15: handle_frameBegin

 def handle_frameBegin(self, resume=0):
     BaseDocTemplate.handle_frameBegin(self, resume=resume)
     self.frame.add(Paragraph(self.__headerLeft, header_left_style), self.canv)
     self.frame.add(Paragraph(self.__headerRight, header_right_style), self.canv)
     self.frame.add(Paragraph(" ".join(list(self.__section)), header_style), self.canv)
     self.frame.add(Rule(lineWidth=0.5, spaceBefore=2, spaceAfter=1), self.canv)
     if self.__entryTitle:
         self.frame.add(self.__entryTitle, self.canv)
开发者ID:quixotique,项目名称:six,代码行数:8,代码来源:book.py


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