• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python barcode.createBarcodeDrawing函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: barcode

def barcode(request, model_name, coin_id,
            barcode_format='code128', image_format='png'):
    try:
        model = get_model(Coin._meta.app_label,
                          '%s%s'
                          % (model_name[0].upper(), model_name[1:].lower()))
        model = model.objects.get(pk=coin_id)
    except Coin.DoesNotExist:
        raise Http404

    if image_format == 'jpeg':
        image_format = 'jpg'
    elif image_format not in ('png', 'jpg', 'gif'):
        image_format = 'png'

    if barcode_format == 'qr':
        barcode = createBarcodeDrawing(
            'QR',
            value=model.qr_code,
            barHeight=90,
            barWidth=90,
            barBorder=0
        )
    else:
        barcode = createBarcodeDrawing(
            'Code128',
            value=str(model.barcode),
            barWidth=1,
            quiet=False
        )

    return HttpResponse(
        content=barcode.asString(image_format),
        mimetype='image/%s' % image_format
    )
开发者ID:kihamo,项目名称:coins,代码行数:35,代码来源:views.py


示例2: run

def run():
    styles = getSampleStyleSheet()
    styleN = styles['Normal']
    styleH = styles['Heading1']
    story = []

    #for codeNames in code
    story.append(Paragraph('I2of5', styleN))
    story.append(I2of5(1234, barWidth = inch*0.02, checksum=0))
    story.append(Paragraph('MSI', styleN))
    story.append(MSI(1234))
    story.append(Paragraph('Codabar', styleN))
    story.append(Codabar("A012345B", barWidth = inch*0.02))
    story.append(Paragraph('Code 11', styleN))
    story.append(Code11("01234545634563"))
    story.append(Paragraph('Code 39', styleN))
    story.append(Standard39("A012345B%R"))
    story.append(Paragraph('Extended Code 39', styleN))
    story.append(Extended39("A012345B}"))
    story.append(Paragraph('Code93', styleN))
    story.append(Standard93("CODE 93"))
    story.append(Paragraph('Extended Code93', styleN))
    story.append(Extended93("[email protected]@K! Code 93 :-)")) #, barWidth=0.005 * inch))
    story.append(Paragraph('Code 128', styleN))
    c=Code128("AB-12345678") #, barWidth=0.005 * inch)
    #print 'WIDTH =', (c.width / inch), 'barWidth =', (c.barWidth / inch)
    #print 'LQ =', (c.lquiet / inch), 'RQ =', (c.rquiet / inch)
    story.append(c)
    story.append(Paragraph('USPS FIM', styleN))
    story.append(FIM("A"))
    story.append(Paragraph('USPS POSTNET', styleN))
    story.append(POSTNET('78247-1043'))
    story.append(Paragraph('USPS 4 State', styleN))
    story.append(USPS_4State('01234567094987654321','01234567891'))

    from reportlab.graphics.barcode import createBarcodeDrawing
    story.append(Paragraph('EAN13', styleN))
    bcd = createBarcodeDrawing('EAN13', value='123456789012')
    story.append(bcd)
    story.append(Paragraph('EAN8', styleN))
    bcd = createBarcodeDrawing('EAN8', value='1234567')
    story.append(bcd)
    story.append(Paragraph('UPCA', styleN))
    bcd = createBarcodeDrawing('UPCA', value='03600029145')
    story.append(bcd)
    story.append(Paragraph('USPS_4State', styleN))
    bcd = createBarcodeDrawing('USPS_4State', value='01234567094987654321',routing='01234567891')
    story.append(bcd)

    story.append(Paragraph('Label Size', styleN))
    story.append(XBox((2.0 + 5.0/8.0)*inch, 1 * inch, '1x2-5/8"'))
    story.append(Paragraph('Label Size', styleN))
    story.append(XBox((1.75)*inch, .5 * inch, '1/2x1-3/4"'))
    c = Canvas('out.pdf')
    f = Frame(inch, inch, 6*inch, 9*inch, showBoundary=1)
    f.addFromList(story, c)
    c.save()
    print('saved out.pdf')
开发者ID:Aeium,项目名称:dotStudio,代码行数:58,代码来源:test.py


示例3: createbarcode

def createbarcode(ch):
        data = ch.split(';')
        #print "DATA for Barcode", ch,data[1]
        #print "CODICE A BARRE " , data[1]
        if len(data[1]) ==13:
            bcd = createBarcodeDrawing('EAN13', value=data[1], width=float(data[2])*cm,height=float(data[3])*cm)
        elif len(data[1]) == 8:
            bcd = createBarcodeDrawing('EAN8', value=data[1], width=float(data[2])*cm,height=float(data[3])*cm)
        else:
            bcd = createBarcodeDrawing('EAN13', value=data[1], width=float(data[2])*cm,height=float(data[3])*cm)
        #bcd = createBarcodeDrawing('EAN13', value="8002705005009", width=float(data[2])*cm,height=float(data[3])*cm)
        return bcd
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:12,代码来源:Sla2pdfUtils.py


示例4: location_scan_sheet

def location_scan_sheet(request):
    locations = InventoryLocation.objects.all().order_by('location_code')
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'filename="locations.pdf"'
    p = canvas.Canvas(response)
    p.setPageSize((215*mm, 275*mm))
    i = 260
    column_a = [15]
    column_b = [65]
    column_c = [115]
    column_d = [165]
    horizontal = column_a
    for location in locations:
        
        p.setFont("Helvetica", 15)
        #p.drawCentredString(horizontal[0]*mm, (i+3)*mm, location.location_code)
        barcode = createBarcodeDrawing('Code128', value=location.location_code,  barWidth=0.25*mm, barHeight=8*mm, humanReadable=True)
        barcode.drawOn(p, horizontal[0]*mm, (i)*mm)
        
        i -= 16
        if i < 2:
            i = 260
            if horizontal == column_a:
                horizontal = column_b
            elif horizontal == column_b:
                horizontal = column_c
            elif horizontal == column_c:
                horizontal = column_d
            else:
                horizontal = column_a
                p.showPage()
    
    p.save()

    return response
开发者ID:disflux,项目名称:django-mtr,代码行数:35,代码来源:location_scan_sheet.py


示例5: print_barcode_page

def print_barcode_page(request, page_id):
    bcp = get_object_or_404(BarcodePage, id=page_id)
    
    # Create the HttpResponse object with the appropriate PDF headers.
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="%s.pdf"' % slugify(bcp.titre)

    # Create the PDF object, using the response object as its "file."
    p = canvas.Canvas(response)
    width, height = A4
    p.drawCentredString(width/2, height-50, bcp.titre)
    produits = bcp.produits.all()
    for idx, prod in enumerate(produits):
        row = idx%7
        col = idx//7
        h = 110
        w = 180
        v_offset = height-80
        h_offset = 60
        img_offset = 80
        text_offset = 10
        
        d = createBarcodeDrawing("EAN13",value=str(prod.ean))
        p.drawString(h_offset+text_offset+col*w, v_offset-row*h, prod.nom)
        renderPDF.draw(d, p, h_offset+col*w, v_offset-img_offset-row*h)

    # Close the PDF object cleanly, and we're done.
    p.showPage()
    p.save()
    return response
开发者ID:Focus3D,项目名称:django-stock,代码行数:30,代码来源:views.py


示例6: generate_image

 def generate_image(self, street, number, house_id):
     options = {'width': 500, 'height': 500}
     current_url = WEBSITE_URL + (
         street + "-" + number + "-" + str(house_id)).lower()
     ret_val = createBarcodeDrawing('QR', value=str(current_url), **options)
     image = base64.encodestring(ret_val.asString('png'))
     self.write({'image': image})
开发者ID:GlennSmeulders,项目名称:HuizenSofie,代码行数:7,代码来源:house.py


示例7: __init__

 def __init__(self, text_value, *args, **kwargs):
     barcode = createBarcodeDrawing("Code128",
                                    value=text_value.encode("utf-8"),
                                    barHeight=10*mm,
                                    width=80*mm)
     Drawing.__init__(self, barcode.width, barcode.height, *args, **kwargs)
     self.add(barcode, name="barcode")
开发者ID:LetsUnlockiPhone,项目名称:Servo,代码行数:7,代码来源:note.py


示例8: gen_form

def gen_form(code, showCodes):
    value = request.args.get('value', '')
    count = request.args.get('count', '')
    scale = request.args.get('scale', '5')
    action = request.args.get('action', '')
    if len(scale) == 0 or not scale.isdigit():
        scale = 5
    if len(value) == 0:
        return render(scale, showCodes, code)

    try:
        if not (code in getCodeNames()):
            flash("Code "+code+" not supported allowed are : " + str(getCodeNames()))
            return render(scale, True, None, count, value)

        if value.isdigit() and count.isdigit():
            if int(count) > 1000 and action == 'Generate PDF':
                flash("Please enter a lower count - maximum is 1000.")
                return render(scale, showCodes, code, count, value)

        dr = createBarcodeDrawing(code, value=value, humanReadable=True)
        if action == 'Generate PDF':
            if value.isdigit() and count.isdigit():
                return redirect(url_for('pdflist', code=code, scale=scale, start=value, count=count))
            else:
                return redirect(url_for('pdf', code=code, scale=scale, value=value))
        else:
            return render(scale, showCodes, code, count, value, True)
    except:
        flash("Error while generating a " + code + ": " + str(sys.exc_info()[0]))
        return render(scale, showCodes, code, count, value)
开发者ID:gitu,项目名称:furry-barcode,代码行数:31,代码来源:barcode.py


示例9: generate

def generate(request, code, barcode_type='Standard39', auto_print=True):
    """
     Returns a PDF Barcode using ReportLab
    """

    from reportlab.graphics.shapes import String
    from reportlab.graphics import renderPDF
    from reportlab.graphics.barcode import createBarcodeDrawing
    from reportlab.pdfbase import pdfdoc
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont

    response = HttpResponse(mimetype='application/pdf')
    response['Content-Disposition'] = 'inline; filename=%s.pdf' % (code,)

    # Config
    import bcp.settings as bcp_settings
    font_size = bcp_settings.FONT_SIZE
    bar_height = bcp_settings.BAR_HEIGHT
    bar_width = bcp_settings.BAR_WIDTH
    font_name = bcp_settings.FONT_NAME
    font_path = bcp_settings.FONT_PATH
    try:
        # If this is extended to different barcode types, then these options will need to be specified differently, eg not all formats support checksum.
        bc = createBarcodeDrawing(barcode_type, barHeight=bar_height, barWidth=bar_width, value=str(code), isoScale=True, quiet=bcp_settings.BAR_QUIET, checksum=bcp_settings.BAR_CHECKSUM,)
    except KeyError, e:
        return HttpResponseBadRequest('Barcode Generation Failed: %s' % (e))
开发者ID:adlibre,项目名称:django-bcp,代码行数:27,代码来源:views.py


示例10: part_label

def part_label(request, part_number):
    part = get_object_or_404(Part, part_number=part_number)
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'filename="label.pdf"'
    
    buffer = BytesIO()
    p = canvas.Canvas(buffer)
    p.setPageSize((105*mm, 26*mm))
    # Draw Part Number


    p.setFont("Helvetica", 20)
    p.drawCentredString(52*mm, 18*mm, part.part_number)
    barcode = createBarcodeDrawing('Code128', value=part.part_number,  barWidth=0.33*mm, barHeight=13*mm, humanReadable=False)
    barcode.drawOn(p, 1*mm, 2*mm)


    
    p.showPage()
    p.save()
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    #action.send(request.user, verb="generated a label", target=report)
    return response
开发者ID:disflux,项目名称:django-mtr,代码行数:25,代码来源:part_label.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_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


示例13: 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


示例14: pdf

    def pdf(self, id):

        
        buffer = BytesIO()

        # Create the PDF object, using the BytesIO object as its "file."
        p = canvas.Canvas(buffer)

        # Draw things on the PDF. Here's where the PDF generation happens.
        # See the ReportLab documentation for the full list of functionality.
        p.drawString(100, 800, "Hello world.")
        
        
        
        barcode = createBarcodeDrawing('Code128', value=id,  barHeight=10*mm, humanReadable=True)
        barcode.drawOn(p, 100, 700)

        # Close the PDF object cleanly.
        p.showPage()
        p.save()

        # Get the value of the BytesIO buffer and write it to the response.
        pdf_data = buffer.getvalue()
        buffer.close()
        
        return wrap_pdf_response(pdf_data, "boarding_pass.pdf")
开发者ID:SharifulAlamSourav,项目名称:zookeepr,代码行数:26,代码来源:boardingpass.py


示例15: __init__

 def __init__(self, text_value, *args, **kw):
     barcode = createBarcodeDrawing(
         'Code128',
         value=text_value,
         barHeight=10 * mm,
         humanReadable=True)
     Drawing.__init__(self, barcode.width, barcode.height, *args, **kw)
     self.add(barcode, name='barcode')
开发者ID:maellson,项目名称:sapl,代码行数:8,代码来源:barcode.py


示例16: draw_contents

 def draw_contents(self,c,xpos,ypos,width,height):
     # Generate barcode
     bc=barcode.createBarcodeDrawing('Extended93',width=width, height=40, value=self.code,checksum=0,humanReadable=True,fontSize=2*mm,fontName='Helvetica')    
     bc.drawOn(c,xpos,ypos+5*self.units)
     c.setFont("Helvetica", 6)
     c.drawCentredString(xpos+width/2, ypos+23*self.units,self.ref)
     c.setFont("Helvetica", 4)
     c.drawCentredString(xpos+width/2, ypos+20*self.units,self.desc)
开发者ID:olivergs,项目名称:evoreports,代码行数:8,代码来源:printlabels.py


示例17: barcode

 def barcode(self, type, value, width=600, height=100, humanreadable=0):
     width, height = int(width), int(height)
     humanreadable = bool(humanreadable)
     barcode_obj = createBarcodeDrawing(
         type, value=value, format='png', width=width, height=height,
         humanReadable=humanreadable
     )
     return base64.encodestring(barcode_obj.asString('png'))
开发者ID:MickSandoz,项目名称:compassion-modules,代码行数:8,代码来源:dynamic_label.py


示例18: get_image

 def get_image(self, value, width, hight, hr, code='QR'):
     options = {}
     if width:options['width'] = width
     if hight:options['hight'] = hight
     if hr:options['humanReadable'] = hr
     try:
         ret_val = createBarcodeDrawing(code, value=str(value), **options)
     except Exception, e:
         raise osv.except_osv('Error', e)
开发者ID:torresv1,项目名称:odoo,代码行数:9,代码来源:barcode_custom.py


示例19: genBarcode

def genBarcode(code, value, canvas, scale):
    dr = createBarcodeDrawing(code, value=value, humanReadable=True)
    dr.renderScale = scale
    bounds = dr.getBounds()
    width = bounds[2] - bounds[0]
    height = bounds[3] - bounds[1]
    dr.drawOn(canvas, (297*mm)/2-width*scale/2, (210*mm)/2-height*scale/2)
    canvas.drawString(1*mm, 1*mm, "generated at "+str(datetime.now()) + " from "+request.url)
    canvas.showPage()
开发者ID:gitu,项目名称:furry-barcode,代码行数:9,代码来源:barcode.py


示例20: printBarcode

 def printBarcode(self, value, width, height):
     try:
         width, height = int(width), int(height)
         barcode = createBarcodeDrawing(
             'EAN13', value=value, format='png', width=width, height=height)
         barcode = barcode.asString('png')
         barcode = barcode.encode('base64', 'strict')
     except (ValueError, AttributeError):
         raise exceptions.Warning(_('Cannot convert into barcode.'))
     return barcode
开发者ID:Endika,项目名称:odoo-product,代码行数:10,代码来源:parser.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python areas.PlotArea类代码示例发布时间:2022-05-26
下一篇:
Python reporter.Reporter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap