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


Python canvas.drawCentredString函数代码示例

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


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

示例1: beforePage

 def beforePage(self):
     if self.pageheader is None:
         return
     canvas = self.canv
     canvas.drawCentredString(canvas._pagesize[0] / 2.0,
                              canvas._pagesize[1] - 0.5*inch,
                              self.pageheader)
开发者ID:350dotorg,项目名称:localpower,代码行数:7,代码来源:pdf.py

示例2: myLaterPages

    def myLaterPages(canvas, doc):

        PAGE_HEIGHT,PAGE_WIDTH = letter
        canvas.saveState()
        canvas.setPageSize(landscape(letter))

        canvas.drawImage(frunt_pag2, 0,0, PAGE_WIDTH,PAGE_HEIGHT )

        canvas.setStrokeColorRGB(0,1,1,alpha=0.1)

        ficha_no = doc.page-1
        #canvas.setStrokeColorRGB(0.7,0.7,0.7)
        canvas.setFillColorRGB(0,0,0)

        SHOW_GRID = False

        if SHOW_GRID:
            n = 5
            s = 200
            canvas.setFillColorRGB(0,0,1)
            canvas.setFont('Helvetica',1)
            for x in range(s):
               for y in range(s):
                  canvas.rect(x*n,y*n, width=n, height=n, stroke=1)
                  canvas.drawString(x*n,y*n,"%s,%s" % ((x*n),(y*n)) )

            # for i in range(s):
            #     x= i*n
            #     y=x
            #     canvas.drawString(x,0,"%s" % (x)) #horizontal
            #     canvas.drawString(0,y+1,"%s" % (x)) # vertical
            #     canvas.drawString(x,600,"%s" % (x)) #horizontal
            #     canvas.drawString(990,y,"%s" % (x)) # vertical
            #
            #     canvas.setStrokeColorRGB(0,0,1,alpha=0.7)
            #     canvas.setFont('Helvetica',1)
            #     for i in range(610):
            #         #canvas.rect(35,i*2, width=0.5, height=0.5, stroke=1)
            #         canvas.drawString(35,i,"%s -" % (i,) )

        canvas.setFont('Helvetica',7)
        LINE_1 = 508

        #fecha_elaboracion = doc.fecha_elaboracion
        #if not fecha_elaboracion:
        #    fecha_elaboracion = datetime.today()

        canvas.drawCentredString(137,LINE_1,str(fecha_elaboracion.year))
        canvas.drawCentredString(162,LINE_1,str(fecha_elaboracion.month))
        canvas.drawCentredString(180,LINE_1,str(fecha_elaboracion.day))

        canvas.drawCentredString(290,LINE_1,"VALLE DEL CAUCA")

        canvas.drawCentredString(740,LINE_1,"Ficha No. %s" % (int(ficha_no)+int(no_ficha_inicial)-1))

        canvas.setFont('Helvetica',5)
        canvas.drawString(75,115, "Elaboro: %s" % elaboro)
        canvas.drawString(215,115, "Reviso: %s" % reviso)

        canvas.restoreState()
开发者ID:luissalamanca22,项目名称:dubs_django,代码行数:60,代码来源:test.py

示例3: draw_code128_global_id

def draw_code128_global_id(canvas, survey):
    if survey.global_id is None:
        raise AssertionError

    # Only allow ascii
    barcode_value = survey.global_id.encode('ascii')

    barcode = createBarcodeDrawing("Code128",
                                   value=barcode_value,
                                   barWidth=defs.code128_barwidth / 25.4 * 72.0,
                                   height=defs.code128_height / 25.4 * 72.0,
                                   quiet=False)

    y = survey.defs.paper_height - defs.corner_mark_bottom
    x = (survey.defs.paper_width - defs.corner_mark_right + defs.corner_mark_left) / 2

    barcode_y = y - defs.code128_vpad - defs.code128_height
    barcode_x = x

    # Center
    barcode_x = barcode_x - barcode.width / mm / 2.0

    renderPDF.draw(barcode, canvas, barcode_x * mm, barcode_y * mm)

    # Label
    text_x = barcode_x + barcode.width / mm / 2.0
    text_y = barcode_y + defs.code128_height + 1 + defs.code128_text_font_size / 72.0 * 25.4 / 2.0

    canvas.saveState()
    canvas.setFont(defs.code128_text_font, defs.code128_text_font_size)
    canvas.drawCentredString(text_x * mm, text_y * mm, barcode_value)
    canvas.restoreState()
开发者ID:gabisurita,项目名称:GDAd,代码行数:32,代码来源:generic.py

示例4: _draw_subsection

def _draw_subsection(canvas, yc, title_left, title_middle, title_right, text_tuples):
    if title_left or title_middle or title_right:
        canvas.setFont(SUBSECTION_TITLE_FONT, SUBSECTION_FONT_SIZE)
        title_y = yc - SUBSECTION_FONT_SIZE
        if title_left:
            title_x = H_TEXT_MARGIN
            canvas.drawString(title_x, title_y, title_left)
        if title_middle:
            title_x = RESUME_PAGE_SIZE[0] / 2
            canvas.drawCentredString(title_x, title_y, title_middle)
        if title_right:
            title_x = RESUME_PAGE_SIZE[0] - H_TEXT_MARGIN
            canvas.drawRightString(title_x, title_y, title_right)        
        yc = title_y - V_SEPARATOR
        
    canvas.setFont(SUBSECTION_FONT, SUBSECTION_FONT_SIZE)
    for (draw_bullet, text) in text_tuples:
        if draw_bullet:
            text = u"•  " + unicode(text)
            
        lines = _break_text(text, RESUME_PAGE_SIZE[0] - (2*H_TEXT_MARGIN + SUBSECTION_H_INDENT), SUBSECTION_FONT, SUBSECTION_FONT_SIZE)
        
        line_x = H_TEXT_MARGIN + SUBSECTION_H_INDENT                
        for line in lines:
            line_y = yc - SUBSECTION_FONT_SIZE        
            canvas.drawString(line_x, line_y, line)
            yc = line_y - V_SEPARATOR
    
    return yc - SUBSECTION_V_SPACER
开发者ID:jovanbrakus,项目名称:resumegen,代码行数:29,代码来源:generator.py

示例5: draw_code128_sdaps_info

def draw_code128_sdaps_info(canvas, survey, page):
    # The page number is one based here already
    # The survey_id is a 32bit number, which means we need
    # 10 decimal digits to encode it, then we need to encode the
    # the page with at least 3 digits(just in case someone is insane enough
    # to have a questionnaire with more than 99 pages.
    # So use 10+4 digits

    barcode_value = "%010d%04d" % (survey.survey_id, page)
    barcode = createBarcodeDrawing("Code128",
                                   value=barcode_value,
                                   barWidth=defs.code128_barwidth / 25.4 * 72.0,
                                   height=defs.code128_height / 25.4 * 72.0,
                                   quiet=False)

    y = survey.defs.paper_height - defs.corner_mark_bottom
    x = survey.defs.paper_width - defs.corner_mark_right

    barcode_y = y - defs.code128_vpad - defs.code128_height
    barcode_x = x - defs.code128_hpad

    # The barcode should be flush left.
    barcode_x = barcode_x - barcode.width / mm

    renderPDF.draw(barcode, canvas, barcode_x * mm, barcode_y * mm)

    # Label
    text_x = barcode_x + barcode.width / mm / 2.0
    text_y = barcode_y + defs.code128_height + 1 + defs.code128_text_font_size / 72.0 * 25.4 / 2.0

    canvas.saveState()
    canvas.setFont(defs.code128_text_font, defs.code128_text_font_size)
    canvas.drawCentredString(text_x * mm, text_y * mm, barcode_value)
    canvas.restoreState()
开发者ID:gabisurita,项目名称:GDAd,代码行数:34,代码来源:generic.py

示例6: _build_header_canvas

        def _build_header_canvas(canvas, doc):
            """
            Draw the document header.

            Local function to be passed later to output_doc.build().
            Reportlab automatically passes args when called.
            """
            # The header function to be passed later to output_doc.build()
            # Set up positions
            header_y_position = (11 * units.inch) - 45
            page_number = doc.page
            if page_number % 2 == 0:
                # Left-hand page
                page_number_x_position = 60
            else:
                # Right-hand page
                page_number_x_position = (8.5 * units.inch) - 60
            canvas.saveState()
            canvas.setFont(self.paragraph_style.fontName,
                           self.paragraph_style.fontSize)
            if self.title:
                canvas.drawCentredString((8.5 * units.inch) / 2,
                                         header_y_position,
                                         self.title)
            canvas.drawString(page_number_x_position, header_y_position,
                              str(page_number))
            canvas.restoreState()
开发者ID:ajyoon,项目名称:yoon-toren-installation,代码行数:27,代码来源:document_builder.py

示例7: docPage

 def docPage(canvas,doc):
     canvas.saveState()
     canvas.setFont('Times-Bold', 10)
     canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT - (.25 * inch), Title)
     canvas.setFont('Times-Roman',9)
     canvas.drawString(7 * inch, .75 * inch, "Page %d" % (doc.page,))
     canvas.restoreState()
开发者ID:B-Rich,项目名称:M2M,代码行数:7,代码来源:models.py

示例8: myPage

    def myPage(canvas, doc):
        canvas.saveState()  # save the current state
        canvas.setFont('InconsolataBold', 16)  # set the font for the name
        canvas.drawString(
            .4 * inch,
            HEIGHT - (.4 * inch),
            contact['name'])  # draw the name on top left page 1
        canvas.setFont('Inconsolata', 8)  # sets the font for contact
        canvas.drawRightString(
            WIDTH - (.4 * inch),
            HEIGHT - (.4 * inch),
            contact['website'])  
        canvas.line(.4 * inch, HEIGHT - (.47 * inch), 
            WIDTH - (.4 * inch), HEIGHT - (.47 * inch))
        canvas.drawString(
            .4 * inch,
            HEIGHT - (.6 * inch),
            contact['phone'])
        canvas.drawCentredString(
			WIDTH / 2.0,
			HEIGHT - (.6 * inch),
			contact['address'])
        canvas.drawRightString(
			WIDTH - (.4 * inch),
			HEIGHT - (.6 * inch),
			contact['email'])
        # restore the state to what it was when saved
        canvas.restoreState()
开发者ID:nickdepinet,项目名称:resume,代码行数:28,代码来源:resume.py

示例9: el_encogedor_de_fuentes_de_doraemon

def el_encogedor_de_fuentes_de_doraemon(canvas, fuente, tamannoini, xini, xfin, y, texto, alineacion = -1):
    """
    Comenzando por el tamaño inicial "tamannoini", encoge el texto 
    hasta que quepa en los límites fijados y después lo escribe.
    Convierte el texto por si está en una codificación no soportada.
    Al finalizar, devuelve las propiedades de texto del canvas a 
    su estado original y la fuente a su tamaño inicial.
    NO AVANZA LÍNEA.
    Si alineacion == -1: Alineación a la izquierda. Si 0, centrado y si 1, a la derecha.
    """
    # PLAN: No estaría mal pasar un tamaño mínimo de fuente, y si se alcanza o se supera, cortar la línea con 
    # agregarFila y el último tamaño de fuente válido. Claro que entonces habría que devolver también las líneas 
    # avanzadas, etc...
    canvas.saveState()
    size = tamannoini
    texto = escribe(texto)
    while canvas.stringWidth(texto, fuente, size) > (xfin - xini) and size > 4:
        size -= 1
    canvas.setFont(fuente, size)
    if alineacion == -1:
        canvas.drawString(xini, y, texto)
    elif alineacion == 1:
        canvas.drawRightString(xfin, y, texto)
    elif alineacion == 0:
        canvas.drawCentredString((xfin + xini) / 2.0, y, texto)
    else:
        print "geninformes.py::el_encogedor_de_fuentes_de_doraemon -> Error alineación. Uso alineación a la izquierda por defecto."
        canvas.drawString(xini, y, texto)
    canvas.restoreState()
开发者ID:Virako,项目名称:fpinn,代码行数:29,代码来源:geninformes.py

示例10: ref_ticker

def ref_ticker(canvas, feature, cLen, Y0, nudge, offset):
    """Draw contig separators."""
    # get contig name
    name = feature.qualifiers.get('id')[0]
    # take start and end points
    location = feature.location
    Zs = location.nofuzzy_start
    Ze = location.nofuzzy_end
    # calculate loop offset coordinates
    loop_offZs = offset_coord(Zs, cLen, offset)
    loop_offZe = offset_coord(Ze, cLen, offset)
    # calculate nudge offset coordinates
    offZs = nudge_coord(loop_offZs, nudge)
    offZe = nudge_coord(loop_offZe, nudge)
    xs, xe = offZs*u, offZe*u
    xmid = (xe+xs)/2
    # set Y axis coordinates
    y0 = Y0+dop*3
    # draw
    canvas.setLineWidth(2)
    ttl = canvas.beginPath()
    ttl.moveTo(xs,y0+w)
    ttl.lineTo(xs,y0+w+h*2)
    ttl.lineTo(xe,y0+w+h*2)
    ttl.lineTo(xe,y0+w)
    canvas.drawPath(ttl, stroke=1, fill=0)
    canvas.setFont(bFont, NfSize)
    canvas.drawCentredString(xmid, y0+h*5, name)
    canvas.setFont(rFont, NfSize)
    ttl.close()
开发者ID:TristanOM,项目名称:trappist,代码行数:30,代码来源:drawing.py

示例11: draw_code128_questionnaire_id

def draw_code128_questionnaire_id(canvas, survey, id):
    # Only supports ascii for now (see also defs.py)
    barcode_value = unicode(id).encode('ascii')
    barcode = createBarcodeDrawing("Code128",
                                   value=barcode_value,
                                   barWidth=defs.code128_barwidth / 25.4 * 72.0,
                                   height=defs.code128_height / 25.4 * 72.0,
                                   quiet=False)

    y = survey.defs.paper_height - defs.corner_mark_bottom
    x = defs.corner_mark_left

    barcode_y = y - defs.code128_vpad - defs.code128_height
    barcode_x = x + defs.code128_hpad

    # The barcode should be flush left.
    barcode_x = barcode_x

    renderPDF.draw(barcode, canvas, barcode_x * mm, barcode_y * mm)

    # Label
    text_x = barcode_x + barcode.width / mm / 2.0
    text_y = barcode_y + defs.code128_height + 1 + \
             defs.code128_text_font_size / 72.0 * 25.4 / 2.0

    canvas.saveState()
    canvas.setFont(defs.code128_text_font, defs.code128_text_font_size)
    canvas.drawCentredString(text_x * mm, text_y * mm, barcode_value)
    canvas.restoreState()
开发者ID:gabisurita,项目名称:GDAd,代码行数:29,代码来源:generic.py

示例12: draw_watermark

 def draw_watermark(self, canvas):
     if self._watermark:
         canvas.saveState()
         canvas.rotate(60)
         canvas.setFillColorRGB(0.9, 0.9, 0.9)
         canvas.setFont('%s' % self.style.fontName, 120)
         canvas.drawCentredString(195*mm, -30*mm, self._watermark)
         canvas.restoreState()
开发者ID:chemcnabb,项目名称:django_ultimate_screenwriter,代码行数:8,代码来源:document.py

示例13: create_first_page

def create_first_page(canvas, doc):
    canvas.saveState()
    canvas.setFont('Helvetica', 16)
    canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT-58, TITLE)
    canvas.setFont('Helvetica', 10)
    canvas.drawString(BORDER_HORIZONTAL, BORDER_VERTICAL, TITLE)
    canvas.drawRightString(PAGE_WIDTH-BORDER_HORIZONTAL , BORDER_VERTICAL, "Seite 1")
    canvas.restoreState()
开发者ID:wichmann,项目名称:bbss,代码行数:8,代码来源:pdf.py

示例14: draw_heading

 def draw_heading(self, canvas):
     text = {'de': 'T3P-Konfiguration', 'en': 'T3P-Configuration'}
     canvas.saveState()
     canvas.setFont(self.font_bold, 14)
     canvas.setFillColorRGB(255, 255, 255)
     x = self.dina4[0]/2
     canvas.drawCentredString(x, 800, text[self.lang])
     canvas.restoreState()
开发者ID:elnerdo,项目名称:t3pkonfigurator,代码行数:8,代码来源:pdfgenerator.py

示例15: draw_title_header

 def draw_title_header():
     x = page_size[0] / 2
     y = page_size[1] - page_margin
     title1 = 'Gantt Chart for {}'.format(project.name)
     title2 = '{} to {}'.format(chart.start.date(), chart.end.date())
     canvas.setFont('Helvetica', 14)
     canvas.drawCentredString(x, y - 10, title1)
     canvas.setFont('Helvetica', 10)
     canvas.drawCentredString(x, y - 25, title2)
开发者ID:thomasleese,项目名称:gantt-charts,代码行数:9,代码来源:frontend.py


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