示例#1
0
    def __init__(self,
                 string,
                 font_name,
                 font_size,
                 color=HexColor('#FFFFFF'),
                 color_space='RGB',
                 x0=0,
                 y0=0,
                 border=False):
        Flowable.__init__(self)

        self.stroke_width = 0.1
        self.border = border
        self.border_width = 2
        self.border_color = HexColor('#FFFFFF')
        self.interline = 0.5 * mm

        self.text = string
        #print self.text
        self.text_font = font_name
        self.text_font_size = font_size
        self.color = color

        self.content_width = utils.text.size.width(self.text, self.text_font,
                                                   self.text_font_size)
        self.content_height = len(
            self.text.split('<br/>')) * self.text_font_size + (
                len(self.text.split('<br/>')) - 1) * self.interline
示例#2
0
 def __init__(self,
              fieldname='',
              value='',
              options=[
                  '',
              ],
              width=120,
              height=36,
              xoffset=0,
              yoffset=0,
              tooltip='',
              fontName=None,
              fontSize=12,
              fieldFlags=''):
     Flowable.__init__(self)
     self.fieldname = fieldname
     self.value = value
     self.options = options
     self.width = width
     self.height = height
     self.xoffset = xoffset
     self.yoffset = yoffset
     self.tooltip = tooltip
     self.fontname = fontName
     self.fontsize = fontSize
     self.fieldflags = fieldFlags
示例#3
0
 def __init__(
     self,
     formName,
     orientation=None,
     iptrans=None,
     callback=None,
     pdf_data=None,
     user_data=None,
     pdfBoxType=None,
     autoCrop=None,
     pageSize=None,
     pageSizeHandler=None,
 ):
     Flowable.__init__(self)
     self.formName = formName
     self._orientation = orientation
     self._iptrans = iptrans
     self._pdfBoxType = pdfBoxType
     self._autoCrop = autoCrop
     self._pageSize = pageSize
     self._pageSizeHandler = pageSizeHandler
     self._pdf_data = pdf_data
     if callback:
         self.callback = lambda key, canv: callback(key, canv, self,
                                                    pdf_data, user_data)
     else:
         self.callback = lambda key, canv: None
示例#4
0
    def __init__(self,
                 library,
                 width,
                 height,
                 data,
                 scale=1,
                 type='datamatrix',
                 align='left'):
        '''
        Creates a Barcode Flowable

        * width and height define the size in ReportLab points (for example 2*cm x 2*cm)
        * data will be encoded as the barcode
        * scale allows you to resize the barcode (default 1)
        * type is the type of the barcode (default 'datamatrix').
          Other types can be found in media/common/pdf_img/barcode.ps
        '''

        Flowable.__init__(self)

        self.width = width
        self.height = height
        self.scale = scale
        self.data = data
        self.resolution_factor = 8
        self.type = type
        self.hAlign = 'CENTER'
        self.library = library
        self.align = align
示例#5
0
文件: reports.py 项目: HCCB/janus
 def __init__(self, master, margin=10):
     Flowable.__init__(self)
     self.master = master
     self.margin = 10
     if master.medical_technologist or master.pathologist:
         self.has_data = True
     else:
         self.has_data = False
 def __init__(self, maxWidth, content=[], style=None, mode=None, scale=None):
     self.maxWidth = maxWidth
     self.content = content
     self.style = style
     self.mode = mode
     self.pad = None
     self.scale = scale
     Flowable.__init__(self)
示例#7
0
 def __init__(self, maxWidth, content=[], style=None, mode=None, scale=None):
     self.maxWidth = maxWidth
     self.content = content
     self.style = style
     self.mode = mode
     self.pad = None
     self.scale = scale
     Flowable.__init__(self)
示例#8
0
 def __init__(self, master, margin=10):
     Flowable.__init__(self)
     self.master = master
     self.margin = 10
     if master.medical_technologist or master.pathologist:
         self.has_data = True
     else:
         self.has_data = False
示例#9
0
    def __init__(self, title, **kw):
        Flowable.__init__(self)

        self.width = 210 * mm
        self.height = 99 * mm  # 1/3 A4 aka A65
        self.title = title

        for k, v in kw.items():
            setattr(self, k, v)
示例#10
0
    def __init__(self, component=None, bounds=None,
                 fixed_scale=None, hAlign='CENTER'):
        self.fixed_scale = fixed_scale
        self.component = component
        if bounds is None:
            bounds = (500, 500)

        self.component.outer_bounds = bounds
        self.component.do_layout(force=True)
        Flowable.__init__(self)
        if hAlign:
            self.hAlign = hAlign
示例#11
0
 def __init__(self,
              width,
              height,
              leftIndent=0,
              spaceBefore=0,
              showBoundary=False):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.leftIndent = leftIndent
     self.spaceBefore = spaceBefore
     self.showBoundary = showBoundary
     self.coords = {}
示例#12
0
    def __init__(self,
                 story,
                 height=None,
                 width=None,
                 pos_x=None,
                 pos_y=None,
                 frame_attrs=freeze({}),
                 attributes=freeze({}),
                 pto_trailer=None,
                 pto_header=None):
        Flowable.__init__(self)
        # get on story
        self.div_story = story
        # set frame style
        self.frame_attrs = {
            'leftPadding': 0,
            'bottomPadding': 0,
            'rightPadding': 0,
            'topPadding': 0,
            'showBoundary': 0
        }
        # PTO initialisation
        self.pto_trailer = pto_trailer
        self.pto_header = pto_header

        if frame_attrs is not None:
            self.frame_attrs.update(frame_attrs)

        for margin in ('topMargin', 'bottomMargin', 'leftMargin',
                       'rightMargin'):
            if margin in self.frame_attrs:
                del self.frame_attrs[margin]

        border = self.frame_attrs['showBoundary']
        if isinstance(border, ShowBoundaryValue):
            border = border.width
        if border:
            for padding_attr in FRAME_PADDINGS_KEYS:
                self.frame_attrs[padding_attr] += border
        self.frame_width = width

        # Overflow
        # TODO to improve
        self.keep_in_frame = None
        style = attribute_style_to_dict(attributes.get((None, 'style'), ''))
        self.overflow = style.get('overflow-y', None)
        if self.overflow == 'hidden':
            self.overflow = 'truncate'
        else:
            self.overflow = None
示例#13
0
 def __init__(self, s, label=None, fontsize=12, color='black'):
     self.s = s
     self.label = label
     self.fontsize = fontsize
     self.color = color
     if HAS_MATPLOTLIB:
         self.parser = mathtext.MathTextParser("Pdf")
     else:
         log.error(
             "Math support not available,"
             " some parts of this document will be rendered incorrectly."
             " Install matplotlib.")
     Flowable.__init__(self)
     self.hAlign = 'CENTER'
示例#14
0
    def __init__(self,
                 component=None,
                 bounds=None,
                 fixed_scale=None,
                 hAlign='CENTER'):
        self.fixed_scale = fixed_scale
        self.component = component
        if bounds is None:
            bounds = (500, 500)

        self.component.outer_bounds = bounds
        self.component.do_layout(force=True)
        Flowable.__init__(self)
        if hAlign:
            self.hAlign = hAlign
示例#15
0
文件: helpers.py 项目: oledm/gmp
 def __init__(self, filename, width=None, height=None, kind='bound',
                                  mask=None, lazy=True, srcinfo=None):
     Flowable.__init__(self)
     self._kind = kind
     page = PdfReader(filename, decompress=False).pages[0]
     self.xobj = pagexobj(page)
     self.imageWidth, self.imageHeight = imageWidth, imageHeight = self.xobj.w, self.xobj.h
     width = width or imageWidth
     height = height or imageHeight
     if kind in ['bound','proportional']:
         factor = min(float(width)/imageWidth,float(height)/imageHeight)
         width = factor * imageWidth
         height = factor * imageHeight
     self.drawWidth = width
     self.drawHeight = height
示例#16
0
 def __init__(self, width, height, number=None, font=None, size=None, align="left"):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.number = number
     
     if not font:
         font = "Helvetica"
         
     if not size:
         size = 8
     
     self.size = size
     self.font = font
     self.align = align
示例#17
0
	def __init__(self,string,font_name,font_size,color=HexColor('#FFFFFF'),color_space = 'RGB',x0=0,y0=0,border=False):
		Flowable.__init__(self)

		self.stroke_width = 0.1
		self.border = border
		self.border_width = 2
		self.border_color = HexColor('#FFFFFF')
		self.interline = 0.5*mm

		self.text = string
		#print self.text
		self.text_font = font_name
		self.text_font_size = font_size
		self.color = color

		self.content_width = utils.text.size.width(self.text,self.text_font,self.text_font_size)
		self.content_height = len(self.text.split('<br/>'))*self.text_font_size + (len(self.text.split('<br/>')) -1)*self.interline
示例#18
0
    def __init__(self, text, style, debug=False, splitted=False, **kwDict):

        Flowable.__init__(self)

        self.text = text
        self.text.calc()
        self.style = style
        self.text.style = style

        self.debug = debug
        self.splitted = splitted

        # More attributes
        for k, v in six.iteritems(kwDict):
            setattr(self, k, v)

        # set later...
        self.splitIndex = None
示例#19
0
 def __init__(self,
              fieldname='',
              value='',
              size=12,
              xoffset=0,
              yoffset=0,
              tooltip='',
              fontName=None,
              fontSize=12):
     Flowable.__init__(self)
     self.fieldname = fieldname
     self.value = value
     self.size = size
     self.xoffset = xoffset
     self.yoffset = yoffset
     self.tooltip = tooltip
     self.fontname = fontName
     self.fontsize = fontSize
示例#20
0
    def __init__(self, text, style, debug=False, splitted=False, **kwDict):

        Flowable.__init__(self)

        self.text = text
        self.text.calc()
        self.style = style
        self.text.style = style

        self.debug = debug
        self.splitted = splitted

        # More attributes
        for k, v in six.iteritems(kwDict):
            setattr(self, k, v)

        # set later...
        self.splitIndex = None
示例#21
0
    def __init__(self, node, styles, value, encoding):
        Flowable.__init__(self)

        self.node = node
        self.styles = styles
        self.value = value
        self.encoding = encoding
        self.xpos = utils.unit_get(node.getAttribute('x'))
        self.ypos = utils.unit_get(node.getAttribute('y'))
        self.width = utils.unit_get(node.getAttribute('width'))
        self.height = utils.unit_get(node.getAttribute('height'))
        self.code_name = node.getAttribute('code')
        self.codes = getCodes()

        from trml2pdf.parser import ParserError
        try:
            self.codes[self.code_name]
        except KeyError, msg:
            raise ParserError("Unknown barcode name '%s'." % self.code_name)
示例#22
0
文件: barcode.py 项目: zbohm/trml2pdf
    def __init__(self, node, styles, value, encoding):
        Flowable.__init__(self)

        self.node = node
        self.styles = styles
        self.value = value
        self.encoding = encoding
        self.xpos = utils.unit_get(node.getAttribute('x'))
        self.ypos = utils.unit_get(node.getAttribute('y'))
        self.width = utils.unit_get(node.getAttribute('width'))
        self.height = utils.unit_get(node.getAttribute('height'))
        self.code_name = node.getAttribute('code')
        self.codes = getCodes()

        from trml2pdf.parser import ParserError
        try:
            self.codes[self.code_name]
        except KeyError, msg:
            raise ParserError("Unknown barcode name '%s'." % self.code_name)
示例#23
0
    def __init__(self, barCodeSymbol):
        Flowable.__init__(self)
        assert hasattr(barCodeSymbol, 'font')
        "name of font to use for printing human-readable text"

        assert hasattr(barCodeSymbol, 'bits')
        """string of 0,1 and L characters. each character stands for one
      "bit" or "module". 0 means white, 1 means black, L means long
      black"""

        assert hasattr(barCodeSymbol, 'moduleHeight')
        "module height in points"
        assert hasattr(barCodeSymbol, 'patternWidth')
        "width in inch"

        self.lightMargin = 9 * barCodeSymbol.moduleWidth * inch
        self.barCodeSymbol = barCodeSymbol
        self.width = self.barCodeSymbol.patternWidth * inch \
                     + self.lightMargin * 2
        self.height = self.barCodeSymbol.moduleHeight * inch
示例#24
0
 def __init__(self, formName, orientation=None,iptrans=None, callback=None,
         pdf_data=None, user_data=None,
         pdfBoxType=None,
         autoCrop=None,
         pageSize=None,
         pageSizeHandler=None,
         ):
     Flowable.__init__(self)
     self.formName = formName
     self._orientation = orientation
     self._iptrans = iptrans
     self._pdfBoxType = pdfBoxType
     self._autoCrop = autoCrop
     self._pageSize = pageSize
     self._pageSizeHandler = pageSizeHandler
     self._pdf_data = pdf_data
     if callback:
         self.callback = lambda key,canv: callback(key,canv,self,pdf_data,user_data)
     else:
         self.callback = lambda key,canv: None
示例#25
0
    def __init__(self, price_rub, price_kop, items=1, scale=1, x0=0, y0=0):
        Flowable.__init__(self)
        self.scale = scale
        self.price_rub = price_rub
        self.price_kop = price_kop
        self.items = str(items) + '.шт'

        self.rub_font = 'HelveticaNeue-BoldCr'
        self.rub_font_size = 28 * scale
        self.rub_width = utils.text.size.width(self.price_rub, self.rub_font,
                                               self.rub_font_size)

        self.kop_font = 'HelveticaNeue-BoldCr'
        self.kop_font_size = 15 * scale
        self.kop_width = utils.text.size.width(self.price_kop, self.kop_font,
                                               self.kop_font_size)

        self.splitter_font = 'HelveticaNeue-BoldCr'
        self.splitter_font_size = 28 * scale
        self.y_splitter = 4

        self.items_font = 'HelveticaNeue_LT_CYR_57_Cond'
        self.items_font_size = 5 * scale
        self.items_width = utils.text.size.width(self.items, self.items_font,
                                                 self.items_font_size)

        self.y_items = 4
        self.x0 = x0
        self.y0 = y0
        self.y0_kop = 10
        self.stroke_width = 2
        self.scale = scale

        self.content_width = self.rub_width + max(
            [self.kop_width, self.items_width]) + 5 * mm
        self.content_height = self.rub_font_size = 28 * scale + 2 * mm

        self.body_color = HexColor('#CE1527')
        self.body_color = HexColor('#204A87')
        self.line_color = HexColor('#FFFFFF')
示例#26
0
    def __init__(self, library, width, height, data, scale=1, type='datamatrix', align='left'):
        '''
        Creates a Barcode Flowable

        * width and height define the size in ReportLab points (for example 2*cm x 2*cm)
        * data will be encoded as the barcode
        * scale allows you to resize the barcode (default 1)
        * type is the type of the barcode (default 'datamatrix').
          Other types can be found in media/common/pdf_img/barcode.ps
        '''

        Flowable.__init__(self)

        self.width = width
        self.height = height
        self.scale = scale
        self.data = data
        self.resolution_factor = 8
        self.type = type
        self.hAlign = 'CENTER'
        self.library = library
        self.align = align
示例#27
0
    def __init__(self, story, height=None, width=None, pos_x=None, pos_y=None,
                 frame_attrs=freeze({}), attributes=freeze({}), pto_trailer=None,
                 pto_header=None):
        Flowable.__init__(self)
        # get on story
        self.div_story = story
        # set frame style
        self.frame_attrs = {'leftPadding': 0, 'bottomPadding': 0,
                           'rightPadding': 0, 'topPadding': 0,
                           'showBoundary': 0}
        # PTO initialisation
        self.pto_trailer = pto_trailer
        self.pto_header = pto_header

        if frame_attrs is not None:
            self.frame_attrs.update(frame_attrs)

        for margin in ('topMargin', 'bottomMargin', 'leftMargin',
                       'rightMargin'):
            if margin in self.frame_attrs:
                del self.frame_attrs[margin]

        border = self.frame_attrs['showBoundary']
        if isinstance(border, ShowBoundaryValue):
            border = border.width
        if border:
            for padding_attr in FRAME_PADDINGS_KEYS:
                self.frame_attrs[padding_attr] += border
        self.frame_width = width

        # Overflow
        # TODO to improve
        self.keep_in_frame = None
        style = attribute_style_to_dict(attributes.get((None, 'style'), ''))
        self.overflow = style.get('overflow-y', None)
        if self.overflow == 'hidden':
            self.overflow = 'truncate'
        else:
            self.overflow = None
示例#28
0
 def __init__(self, barCodeSymbol):
    Flowable.__init__(self)
    assert hasattr(barCodeSymbol,'font')
    "name of font to use for printing human-readable text"
    
    assert hasattr(barCodeSymbol,'bits')
    
    """string of 0,1 and L characters. each character stands for one
    "bit" or "module". 0 means white, 1 means black, L means long
    black"""
    
    
    assert hasattr(barCodeSymbol,'moduleHeight')
    "module height in points"
    assert hasattr(barCodeSymbol,'patternWidth')
    "width in inch"
    
    self.lightMargin = 9 * barCodeSymbol.moduleWidth * inch
    self.barCodeSymbol = barCodeSymbol
    self.width = self.barCodeSymbol.patternWidth * inch \
                 + self.lightMargin * 2
    self.height = self.barCodeSymbol.moduleHeight * inch
示例#29
0
 def __init__(self,
              fieldname='',
              values=['1', '2'],
              selected=None,
              size=20,
              xoffset=0,
              yoffset=0,
              tooltip='',
              fontName=None,
              fontSize=12,
              direction=HORIZONTAL):
     Flowable.__init__(self)
     self.fieldname = fieldname
     self.values = values
     self.selected = selected
     self.size = size
     self.xoffset = xoffset
     self.yoffset = yoffset
     self.tooltip = tooltip
     self.fontname = fontName
     self.fontsize = fontSize
     self.direction = direction
     group = acroform.RadioGroup(self.fieldname)
示例#30
0
    def __init__(self, s, label=None, style=None):
        Flowable.__init__(self)
        self.s = s.strip()
        self.label = label
        self.fontsize = 10
        self.color = (0, 0, 0)
        self.hAlign = 'LEFT'
        if style:
            self.style = style
            self.fontsize = style.fontSize
            self.color = style.textColor.rgb()
            self.hAlign = style.alignment

        if HAS_MATPLOTLIB:
            self.parser = mathtext.MathTextParser("Path")
        else:
            log.error(
                "Math support not available,"
                " some parts of this document will be rendered incorrectly."
                " Install matplotlib.")

        if "\n" in s:
            log.error(
                "rst2pdf's math directive does not support multiple lines'")
示例#31
0
	def __init__(self,price_rub,price_kop,items=1,scale=1,x0=0,y0=0):
		Flowable.__init__(self)
		self.scale = scale
		self.price_rub = price_rub
		self.price_kop = price_kop
		self.items = str(items) + '.шт'
		
		self.rub_font = 'HelveticaNeue-BoldCr'
		self.rub_font_size = 28*scale
		self.rub_width = utils.text.size.width(self.price_rub,self.rub_font,self.rub_font_size)

		self.kop_font = 'HelveticaNeue-BoldCr'
		self.kop_font_size = 15*scale
		self.kop_width = utils.text.size.width(self.price_kop,self.kop_font,self.kop_font_size)

		self.splitter_font = 'HelveticaNeue-BoldCr'
		self.splitter_font_size = 28*scale
		self.y_splitter = 4
		
		self.items_font = 'HelveticaNeue_LT_CYR_57_Cond'
		self.items_font_size = 5*scale
		self.items_width = utils.text.size.width(self.items,self.items_font,self.items_font_size)

		self.y_items = 4
		self.x0 = x0
		self.y0 = y0
		self.y0_kop = 10		
		self.stroke_width = 2
		self.scale = scale	

		self.content_width = self.rub_width + max([self.kop_width,self.items_width]) + 5*mm
		self.content_height = self.rub_font_size = 28*scale + 2*mm

		self.body_color = HexColor('#CE1527')
		self.body_color = HexColor('#204A87')
		self.line_color = HexColor('#FFFFFF') 
 def __init__(self, pickledStuff, isDict=False):
     Flowable.__init__(self)
     self.pickledStuff = pickledStuff
     self._isDict = isDict
示例#33
0
 def __init__(self, refid):
     self.refid = refid
     self.keepWithNext = True
     Flowable.__init__(self)
示例#34
0
	def __init__(self,width,height,color):
		Flowable.__init__(self)
		self.width = width*mm
		self.height = height*mm
		self.color = HexColor(color)
示例#35
0
文件: helpers.py 项目: oledm/gmp
 def __init__(self, width, height=0):
     Flowable.__init__(self)
     self.width = width
     self.height = height
示例#36
0
 def __init__(self):
     Flowable.__init__(self)
 def __init__(self, number=0, style='arabic'):
     self.style = str(style).lower()
     self.number = int(number)
     Flowable.__init__(self)
示例#38
0
 def __init__(self, path, width, height):
     Flowable.__init__(self)
     self.path = path
     self.width = width
     self.height = height
示例#39
0
 def __init__(self, min_widths, max_widths):
     self.min_widths = min_widths
     self.max_widths = max_widths
     Flowable.__init__(self)
示例#40
0
	def __init__(self,path,width,height):
		Flowable.__init__(self)
		self.path = path
		self.width = width
		self.height = height
	def __init__(self,height,thickness = 1):
		Flowable.__init__(self)
		self.height = height
		self.lineWidth = thickness
示例#42
0
 def __init__(self, number=0, style='arabic'):
     self.style = str(style).lower()
     self.number = int(number)
     Flowable.__init__(self)
示例#43
0
 def __init__(self, txt, lvl):
     Flowable.__init__(self)
     self.txt = txt
     self.lvl = lvl
 def __init__(self, size=6.0, value=None, x=0, y=0):
     Flowable.__init__(self)
     self.width = self.height = size
     self.value = value
     self.offset = (x, y)
示例#45
0
 def __init__(self, width, height, slide, pageSize):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.slide = slide
     self.pageSize = pageSize
示例#46
0
 def __init__(self, text, style):
     Flowable.__init__(self)
     self.text = text
     self.height = 4 * cm
     self.style = style
示例#47
0
 def __init__(self, text):
     Flowable.__init__(self)
     self.text = text
示例#48
0
 def __init__(self, templateName=None):
     self.templateName = templateName
     Flowable.__init__(self)
示例#49
0
 def __init__(self, title, key):
     self.title = title
     self.key = key
     Flowable.__init__(self)
示例#50
0
 def __init__(self, width, height, note="", string=""):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.note = note
     self.string = string
示例#51
0
 def __init__(self, refid):
     self.refid = refid
     self.keepWithNext = True
     Flowable.__init__(self)
示例#52
0
 def __init__(self, pickledStuff, isDict=False):
     Flowable.__init__(self)
     self.pickledStuff = pickledStuff
     self._isDict = isDict
示例#53
0
 def __init__(self, height, thickness=1):
     Flowable.__init__(self)
     self.height = height
     self.lineWidth = thickness
示例#54
0
 def __init__(self, xoffset = 0, yoffset = 0):
     Flowable.__init__(self)
     self._xoffset = xoffset
     self._yoffset = yoffset
 def __init__(self, title, key):
     self.title = title
     self.key = key
     Flowable.__init__(self)
示例#56
0
	def __init__(self,path,width,height):
		Flowable.__init__(self)
		self.path = path
		self.width = width
		self.height = height
		self.color = HexColor(color)
示例#57
0
 def __init__(self, width, height, slide, pageSize):
     Flowable.__init__(self)
     self.width = width
     self.height = height
     self.slide = slide
     self.pageSize = pageSize
示例#58
0
文件: listados.py 项目: pkom/gesties
 def __init__(self, value="1234567890", ratio=0.5):
     # init and store rendering value
     Flowable.__init__(self)
     self.value = value
     self.ratio = ratio