Exemple #1
0
 def test801(self):
     '''test for bitbucket issue 105 reported by Johann Du Toit'''
     from reportlab.graphics.charts.doughnut import Doughnut
     from reportlab.graphics import renderSVG
     d = Drawing(500, 500)
     pie = Doughnut()
     pie.data = [5]
     pie.labels = ['Only 1 Value','']
     d.add(pie)
     s = renderSVG.drawToString(d)
 def test801(self):
     '''test for bitbucket issue 105 reported by Johann Du Toit'''
     from reportlab.graphics.charts.doughnut import Doughnut
     from reportlab.graphics import renderSVG
     d = Drawing(500, 500)
     pie = Doughnut()
     pie.data = [5]
     pie.labels = ['Only 1 Value', '']
     d.add(pie)
     s = renderSVG.drawToString(d)
Exemple #3
0
def barcode(value):
    if type(value) == unicode and len(value) == 12 and value.isdigit():
        d = createBarcodeDrawing("EAN13", value=str(value))
        s = renderSVG.drawToString(d)
        lines = s.split('\n')
        outlines = []
        outlines.append(lines[4])
        outlines.extend(lines[7:])
        return mark_safe("\n".join(outlines))
    else:
        return type(value)
Exemple #4
0
def barcode(value):
    if type(value)==unicode and len(value)==12 and value.isdigit():
        d = createBarcodeDrawing("EAN13", value=str(value))
        s = renderSVG.drawToString(d)
        lines = s.split('\n')
        outlines = []
        outlines.append(lines[4])
        outlines.extend(lines[7:])
        return mark_safe("\n".join(outlines))
    else:
        return type(value)
Exemple #5
0
def get_qrcode_as_svg_zipstring(code_value):
  logging.info("get_qrcode_as_svg_string")

  unit = 29*mm

  qrw = QrCodeWidget(code_value)
  b = qrw.getBounds()
  logging.info( b )
  w = b[2]-b[0]
  h = b[3]-b[1]
  qrcode_image = Drawing(unit,unit,transform=[unit/w,0,0,unit/h,0,0])
  qrcode_image.add(qrw)


  rs = renderSVG.drawToString(qrcode_image)
  logging.info("raw size %d" % len(rs))
  #rsz = zlib.compress(rs)
  #logging.info("zip size %d" % len(rsz))
  return rs
Exemple #6
0
def qrtest():
  logging.info("qrtest ================ START =================  qrtest")

  unit = 29*mm

  qrw = QrCodeWidget(EXTRA_LONG_TEST_TEST)


  b = qrw.getBounds()
  logging.info( b )
  w = b[2]-b[0]
  h = b[3]-b[1]
  qrcode_image = Drawing(unit,unit,transform=[unit/w,0,0,unit/h,0,0])
  qrcode_image.add(qrw)


  rs = renderSVG.drawToString(qrcode_image)
  logging.info(len(rs))
  rsz = zlib.compress(rs)
  logging.info(len(rsz))


  logging.info("qrtest ================ END =================  qrtest")
Exemple #7
0
 def test5(self):
     '''tests drawToString inspired by https://bitbucket.org/egillet/ 
     & https://bitbucket.org/johanndt/'''
     d = Drawing(1,1)
     self.assertTrue(isStr(renderSVG.drawToString(d)),msg='renderSVG.draweToString should return bytes')
 def test5(self):
     '''tests drawToString inspired by https://bitbucket.org/egillet/ 
     & https://bitbucket.org/johanndt/'''
     d = Drawing(1, 1)
     self.assertTrue(isStr(renderSVG.drawToString(d)),
                     msg='renderSVG.draweToString should return bytes')