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


Python units.mm方法代码示例

本文整理汇总了Python中reportlab.lib.units.mm方法的典型用法代码示例。如果您正苦于以下问题:Python units.mm方法的具体用法?Python units.mm怎么用?Python units.mm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.lib.units的用法示例。


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

示例1: _num

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def _num(s, unit=1, allowRelative=True):
    """Convert a string like '10cm' to an int or float (in points).
       The default unit is point, but optionally you can use other
       default units like mm.
    """
    if s.endswith('cm'):
        unit=cm
        s = s[:-2]
    if s.endswith('in'):
        unit=inch
        s = s[:-2]
    if s.endswith('pt'):
        unit=1
        s = s[:-2]
    if s.endswith('i'):
        unit=inch
        s = s[:-1]
    if s.endswith('mm'):
        unit=mm
        s = s[:-2]
    if s.endswith('pica'):
        unit=pica
        s = s[:-4]
    return _convnum(s,unit,allowRelative) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:26,代码来源:paraparser.py

示例2: makeBarcodeFile

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def makeBarcodeFile (brc, width, height):
	brc = str(brc)
	width = float(width) * mm
	height = float(height) * mm
	# generate a canvas (A4 in this case, size doesn"t really matter)
	c=canvas.Canvas(brc+".pdf",pagesize=A4)
	# create a barcode object
	# (is not displayed yet)
	# The encode text is "123456789"
	# barHeight encodes how high the bars will be
	# barWidth encodes how wide the "narrowest" barcode unit is
	barcode=code39.Extended39(brc, barWidth=width*mm, barHeight=height*mm)
	# drawOn puts the barcode on the canvas at the specified coordinates
	
	x, y = (10*mm, 10*mm)
	while y + barcode.height < 290*mm:
		while x + barcode.width < 200*mm:
			barcode.drawOn(c, x, y)
			x = x + (1 + barcode.width)
		x = 10*mm
		y = y + (1 + barcode.height)*mm 

	# now create the actual PDF
	c.showPage()
	c.save() 
开发者ID:104H,项目名称:HH---POS-Accounting-and-ERP-Software,代码行数:27,代码来源:barcodeMaker.py

示例3: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def __init__(
        self, shipping_label: ShippingLabel, label_width, label_height, hmargin=5 * mm, vmargin=5 * mm
    ) -> None:
        super().__init__()
        self.shipping_label = shipping_label

        self.label_width = label_width
        self.hmargin = hmargin
        self.width = self.label_width - (2 * hmargin)

        self.label_height = label_height
        self.vmargin = vmargin
        self.height = self.label_height - (2 * vmargin)

        self.x1 = self.hmargin
        self.y1 = self.vmargin
        self.x2 = self.hmargin + self.width
        self.y2 = self.vmargin + self.height 
开发者ID:olist,项目名称:correios,代码行数:20,代码来源:pdf.py

示例4: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def __init__(self, pdf_components):
        self.style = getSampleStyleSheet()
        self.style['Normal'].leading = 16
        self.style.add(ParagraphStyle(name='centered', alignment=TA_CENTER))
        self.style.add(ParagraphStyle(name='centered_wide', alignment=TA_CENTER,
                                      leading=18))
        self.style.add(ParagraphStyle(name='section_body',
                                      parent=self.style['Normal'],
                                      spaceAfter=inch * .05,
                                      fontSize=11))
        self.style.add(ParagraphStyle(name='bullet_list',
                                      parent=self.style['Normal'],
                                      fontSize=11))
        if six.PY3:
            self.buffer = six.BytesIO()
        else:
            self.buffer = six.StringIO()
        self.firstPage = True
        self.document = SimpleDocTemplate(self.buffer, pagesize=letter,
                                          rightMargin=12.7 * mm, leftMargin=12.7 * mm,
                                          topMargin=120, bottomMargin=80)

        self.tlp_color = pdf_components.get('tlp_color', '')
        self.pdf_components = pdf_components
        self.pdf_list = [] 
开发者ID:mitre,项目名称:multiscanner,代码行数:27,代码来源:generic_pdf.py

示例5: header_footer

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def header_footer(self, canvas, doc):
        canvas.saveState()
        height_adjust = self.add_banner(canvas, doc)

        # Document Header
        if self.pdf_components.get('hdr_image', None) and self.firstPage:
            header = Image(self.pdf_components.get('hdr_image'), height=25 * mm, width=191 * mm)
            header.drawOn(canvas, doc.rightMargin, doc.height + doc.topMargin - 15 * mm)
            self.firstPage = False
        elif self.firstPage:
            header = Paragraph(self.pdf_components.get('hdr_html', ''), self.style['centered'])
            w, h = header.wrap(doc.width, doc.topMargin)
            header.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin - height_adjust * h)

        # Document Footer
        if self.pdf_components.get('ftr_image', None):
            footer = Image(self.pdf_components.get('ftr_image'), 8.5 * inch, 1.8 * inch)
            footer.drawOn(canvas, 0, 0)
        else:
            footer = Paragraph(self.pdf_components.get('ftr_html', ''), self.style['centered'])
            w, h = footer.wrap(doc.width, doc.bottomMargin)
            footer.drawOn(canvas, doc.leftMargin, height_adjust * h)

        # Release the Canvas
        canvas.restoreState() 
开发者ID:mitre,项目名称:multiscanner,代码行数:27,代码来源:generic_pdf.py

示例6: vertical_table

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def vertical_table(self, data, table_style=None, col_widths=None):
        '''A table where the first column is bold. A label followed by values.'''
        self.style['BodyText'].wordWrap = 'LTR'
        self.style['BodyText'].spaceBefore = 2

        if table_style:
            style = table_style
        else:
            style = TableStyle([
                ('LINEABOVE', (0, 0), (-1, 0), 0.75, blue),
                ('BOX', (1, 0), (0, -1), 0.25, black),
                ('ALIGN', (1, 1), (-1, -1), 'RIGHT')
            ])

        if col_widths:
            cols = col_widths
        else:
            cols = (35 * mm, 140 * mm)

        data2 = [[Paragraph(self.bold_text(cell), self.style['BodyText']) if idx == 0
                  else Paragraph(cell, self.style['BodyText'])
                  for idx, cell in enumerate(row)] for row in data]

        table = Table(data2, style=style, colWidths=cols)
        self.pdf_list.append(table) 
开发者ID:mitre,项目名称:multiscanner,代码行数:27,代码来源:generic_pdf.py

示例7: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
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:fpsw,项目名称:Servo,代码行数:9,代码来源:note.py

示例8: _checkbox

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def _checkbox(self, x, y, text="", filled=0, leading=0):
        self.c.circle(x+1.5*mm, y+1.5*mm, 1.5*mm, stroke=1, fill=filled)
        self.c.setFont("Helvetica", 7)
        self.c.drawString(x+5*mm, y+0.5*mm+leading, text) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:6,代码来源:letters.py

示例9: _box_entry

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def _box_entry(self, x, y, width, height, content=None):
        self.c.setLineWidth(1)
        self.c.rect(x, y, width, height)
        if content:
            self.c.setFont(self.ENTRY_FONT, 12)
            self.c.drawString(x+3*mm, y+height-4.5*mm, content) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:8,代码来源:letters.py

示例10: check_label

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def check_label(self, x, y, label, fill=0):
        self.label_font()
        self.c.rect(x, y, 3*mm, 3*mm, fill=0)
        if fill:
            self.c.line(x, y, x+3*mm, y+3*mm)
            self.c.line(x+3*mm, y, x, y+3*mm)
        self.c.drawString(x+5*mm, y, label) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:9,代码来源:letters.py

示例11: _header_line

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def _header_line(self, y, text):
        self.c.setFillColor(black)
        self.c.rect(0, y, self.main_width, 3.5*mm, fill=1)
        self.c.setFillColor(white)
        self.c.setFont("Helvetica-Bold", 9)
        self.c.drawCentredString(self.main_width/2, y + 0.5*mm, text)
        self.c.setFillColor(black) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:9,代码来源:letters.py

示例12: _line_entry

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def _line_entry(self, x, y, text, line_offset, line_length, entry_text=''):
        self.c.setFont(*self.LABEL_FONT)
        self.c.setLineWidth(1)
        self.c.drawString(x, y+1*mm, text)
        self.c.line(x+line_offset, y, x+line_offset+line_length, y)
        self.c.setFont(*self.ENTRY_FONT)
        self.c.drawString(x+line_offset+2*mm, y+1*mm, entry_text) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:9,代码来源:letters.py

示例13: label_blank

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def label_blank(self, x, y, label, value='', labelwidth=40*mm, linelength=70*mm, fill=False):
        self.label_font()
        self.c.drawString(x, y, label+":")
        self.c.setLineWidth(0.4)
        self.c.line(x+labelwidth, y-1*mm, x+labelwidth+linelength, y-1*mm)
        self.entry_font()
        self.c.drawString(x+labelwidth+2*mm, y, value) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:9,代码来源:letters.py

示例14: checkbox

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def checkbox(self, x, y, filled=0):
        self.c.rect(x*mm, y*mm, 3.1*mm, 3.8*mm, fill=filled) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:4,代码来源:letters.py

示例15: rect

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import mm [as 别名]
def rect(self, x, y, width, height, filled=0):
        self.c.rect(x*mm, y*mm, width*mm, height*mm, fill=filled) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:4,代码来源:letters.py


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