當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。