def draw(self): canvas = self.canv img = Image(self.barcode) width, height = img.wrapOn(canvas, 0, 0) width = width * 72. / 300 height = height * 72. / 300 canvas.drawImage( self.barcode, self.x * mm, (self.y * mm * -1) - height, width, height, )
def _draw_image(self, img_path, width=None, height=None, **kwargs): """Draw an image""" canvas = self.canv img = Image(img_path) _width, _height = img.wrapOn(canvas, 0, 0) _width = _width * 72. / 300 _height = _height * 72. / 300 if width is not None: _width = width if height is not None: _height = height canvas.drawImage( img_path, self.cursor.x * self.unit, self.cursor.y * self.unit - _height, _width, _height, )