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


Python units.inch方法代码示例

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


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

示例1: _draw_box_left

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def _draw_box_left(self, x, y, label, content, width=MAIN_WIDTH-BOX_OFFSET, tick=False):
        """
        Draw one text entry box with the above parameters.

        "width" parameter should include one BOX_OFFSET
        """
        # box/tickmark
        self.c.setLineWidth(2)
        if not tick:
            self.c.rect(x + self.BOX_OFFSET, y - self.BOX_OFFSET - self.ENTRY_SIZE, width - self.BOX_OFFSET, self.ENTRY_SIZE)
        else:
            self.c.line(x + self.BOX_OFFSET, y - self.BOX_OFFSET - self.ENTRY_SIZE, x + self.BOX_OFFSET, y - self.BOX_OFFSET - self.ENTRY_SIZE + 0.2*inch)

        # label
        self.c.setFont("Helvetica", 6)
        self.c.drawString(x + self.BOX_OFFSET + self.LABEL_OFFSET, y - self.BOX_OFFSET - self.LABEL_HEIGHT, label)

        # content
        self.c.setFont("Helvetica-Bold", 12)
        self.c.drawString(x + self.BOX_OFFSET + 2*self.LABEL_OFFSET, y - self.BOX_OFFSET - self.ENTRY_SIZE + self.DATA_BUMP, content) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:22,代码来源:letters.py

示例2: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def __init__(self, text=[], target='your website', pdfName='Report.pdf'):
        self.__target = target
        self.__pdfName = self.__path + pdfName
        self.__text = text
        if not os.path.exists('result/'):
            os.mkdir(r'result/')
        time = datetime.datetime.today()
        date = time.strftime("%h-%d-%Y %H:%M:%S")
        c = canvas.Canvas(self.__pdfName)
        c.setPageSize((16 * inch,22 * inch))
        textobj = c.beginText()
        textobj.setTextOrigin(inch, 20 * inch)
        textobj.textLines('''
            This is the scanning report of %s.
            ''' %self.__target)
        textobj.textLines('''
            Date: %s
            ''' % date)
        for line in self.__text:
            textobj.textLine(line.strip())
        c.drawText(textobj)
        c.showPage()
        c.save() 
开发者ID:lewang2333,项目名称:anti-XSS,代码行数:25,代码来源:pdfgenerator.py

示例3: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def __init__(self, value='', **args):

        if type(value) is type(1):
            value = asNative(value)
            
        for (k, v) in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        MultiWidthBarcode.__init__(self, value) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:code93.py

示例4: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def __init__(self, value='', **args):

        if type(value) == type(1):
            value = str(value)

        for k, v in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = min(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = min(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        Barcode.__init__(self, value) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:common.py

示例5: test2

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def test2(canv,testpara):
    #print test_program; return
    from reportlab.lib.units import inch
    from reportlab.lib.styles import ParagraphStyle
    from reportlab.lib import rparsexml
    parsedpara = rparsexml.parsexmlSimple(testpara,entityReplacer=None)
    S = ParagraphStyle("Normal", None)
    P = Para(S, parsedpara)
    (w, h) = P.wrap(5*inch, 10*inch)
    print("wrapped as", (h,w))
    canv.saveState()
    canv.translate(1*inch, 1*inch)
    canv.rect(0,0,5*inch,10*inch, fill=0, stroke=1)
    P.canv = canv
    canv.saveState()
    P.draw()
    canv.restoreState()
    canv.setStrokeColorRGB(1, 0, 0)
    #canv.translate(0, 3*inch)
    canv.rect(0,0,w,h, fill=0, stroke=1)
    canv.restoreState()
    canv.showPage() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:para.py

示例6: run

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def run():
        objects_to_draw = []
        from reportlab.lib.styles import ParagraphStyle
        #from paragraph import Paragraph
        from reportlab.platypus.doctemplate import SimpleDocTemplate

        #need a style
        normal = ParagraphStyle('normal')
        normal.firstLineIndent = 18
        normal.spaceBefore = 6
        from reportlab.lib.randomtext import randomText
        import random
        for i in range(15):
            height = 0.5 + (2*random.random())
            box = XBox(6 * inch, height * inch, 'Box Number %d' % i)
            objects_to_draw.append(box)
            para = Paragraph(randomText(), normal)
            objects_to_draw.append(para)

        SimpleDocTemplate('doctemplate.pdf').build(objects_to_draw,
            onFirstPage=myFirstPage,onLaterPages=myLaterPages) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:doctemplate.py

示例7: test_0

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def test_0(self):
        "Test length attribute conversion."

        mapping = (
            ("0", 0),
            ("316", 316),
            ("-316", -316),
            ("-3.16", -3.16),
            ("-1e-2", -0.01),
            ("1e-5", 1e-5),
            ("1e1cm", 10*cm),
            ("1e1in", 10*inch),
            ("-8e-2cm", (-8e-2)*cm),
            ("20px", 20),
            ("20pt", 20 * 1.25),
            ("1.5em", 12 * 1.5),
            ("10.5mm", 10.5*(cm*0.1)),
            ("3, 5 -7", [3, 5, -7]),
            ("2pt  12pt", [2 * 1.25, 12 * 1.25]),
        )
        ac = svglib.Svg2RlgAttributeConverter()
        failed = _testit(ac.convertLength, mapping)
        assert len(failed) == 0
        assert ac.convertLength("1.5em", em_base=16.5) == 24.75 
开发者ID:deeplook,项目名称:svglib,代码行数:26,代码来源:test_basic.py

示例8: get_cover_page

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def get_cover_page(self, report_id, recipient):
        # title = f"{self.report_title} No.: {report_id}"

        styles = getSampleStyleSheet()
        headline_style = styles["Heading1"]
        headline_style.alignment = TA_CENTER
        headline_style.fontSize = 48
        subtitle_style = styles["Heading2"]
        subtitle_style.fontSize = 24
        subtitle_style.leading = 26
        subtitle_style.alignment = TA_CENTER

        CoverPage = []
        logo = os.path.join(settings.BASE_DIR, self.logo_path)

        image = Image(logo, 3 * inch, 3 * inch)
        CoverPage.append(image)
        CoverPage.append(Spacer(1, 18))
        CoverPage.append(Paragraph("CONFIDENTIAL", headline_style))
        # paragraph = Paragraph(
        #     f"Intended for: {recipient}, Title IX Coordinator", subtitle_style)
        # CoverPage.append(paragraph)
        CoverPage.append(PageBreak())
        return CoverPage

    # entrypoints 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:28,代码来源:api.py

示例9: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def __init__(self, value='', **args):

        if type(value) is type(1):
            value = str(value)
            
        for (k, v) in args.iteritems():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        MultiWidthBarcode.__init__(self, value) 
开发者ID:gltn,项目名称:stdm,代码行数:18,代码来源:code93.py

示例10: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def __init__(self, value='', **args):

        if type(value) is type(1):
            value = str(value)
            
        for (k, v) in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = max(inch * 0.25, self.barWidth * 10.0)
            if self.rquiet is None:
                self.rquiet = max(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        MultiWidthBarcode.__init__(self, value) 
开发者ID:gltn,项目名称:stdm,代码行数:19,代码来源:code128.py

示例11: __init__

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def __init__(self, value='', **args):

        if type(value) == type(1):
            value = str(value)

        for (k, v) in args.items():
            setattr(self, k, v)

        if self.quiet:
            if self.lquiet is None:
                self.lquiet = min(inch * 0.25, self.barWidth * 10.0)
                self.rquiet = min(inch * 0.25, self.barWidth * 10.0)
        else:
            self.lquiet = self.rquiet = 0.0

        Barcode.__init__(self, value) 
开发者ID:gltn,项目名称:stdm,代码行数:18,代码来源:common.py

示例12: test2

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def test2(canv,testpara):
    #print test_program; return
    from reportlab.lib.units import inch
    from reportlab.lib.styles import ParagraphStyle
    from reportlab.lib import rparsexml
    parsedpara = rparsexml.parsexmlSimple(testpara,entityReplacer=None)
    S = ParagraphStyle("Normal", None)
    P = Para(S, parsedpara)
    (w, h) = P.wrap(5*inch, 10*inch)
    print "wrapped as", (h,w)
    canv.saveState()
    canv.translate(1*inch, 1*inch)
    canv.rect(0,0,5*inch,10*inch, fill=0, stroke=1)
    P.canv = canv
    canv.saveState()
    P.draw()
    canv.restoreState()
    canv.setStrokeColorRGB(1, 0, 0)
    #canv.translate(0, 3*inch)
    canv.rect(0,0,w,h, fill=0, stroke=1)
    canv.restoreState()
    canv.showPage() 
开发者ID:gltn,项目名称:stdm,代码行数:24,代码来源:para.py

示例13: run

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def run():
        objects_to_draw = []
        from reportlab.lib.styles import ParagraphStyle
        #from paragraph import Paragraph
        from doctemplate import SimpleDocTemplate

        #need a style
        normal = ParagraphStyle('normal')
        normal.firstLineIndent = 18
        normal.spaceBefore = 6
        from reportlab.lib.randomtext import randomText
        import random
        for i in range(15):
            height = 0.5 + (2*random.random())
            box = XBox(6 * inch, height * inch, 'Box Number %d' % i)
            objects_to_draw.append(box)
            para = Paragraph(randomText(), normal)
            objects_to_draw.append(para)

        SimpleDocTemplate('doctemplate.pdf').build(objects_to_draw,
            onFirstPage=myFirstPage,onLaterPages=myLaterPages) 
开发者ID:gltn,项目名称:stdm,代码行数:23,代码来源:doctemplate.py

示例14: fill_pdf_pages

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def fill_pdf_pages(self):
        """
        Fill one or more pages with labels.

        :return:
        """
        # # draw lines around the boxes that will be filled with labels
        # self.draw_boxes_on_page()
        # # self.pdf.setFillColorRGB(1, 0, 1)
        # # self.pdf.rect(2*inch, 2*inch, 2*inch, 2*inch, fill=1)
        for label_file, label_name in self.get_next_qr_img():
            debug(f'Got {label_file}')
            if self.next_pos >= len(self.label_locations) - 1:
                self. finish_page()
                self.next_pos = 0
            else:
                self.next_pos += 1
            self.draw_bounding_box(self.next_pos)
            self.place_label(label_file, label_name, self.next_pos)
        self.finish_page()
        return 
开发者ID:w-a-r-m-inventory-system,项目名称:Food-Pantry-Inventory,代码行数:23,代码来源:QRCodePrinter.py

示例15: onPage

# 需要导入模块: from reportlab.lib import units [as 别名]
# 或者: from reportlab.lib.units import inch [as 别名]
def onPage(self, canvas, doc):
        c = canvas
        w, h = c._pagesize
        # The cover page just has some drawing on the canvas.
        c.saveState()
        isletter = (w, h) == letter
        c.setFont(self.font, isletter and 16 or 20)
        imgw, imgh = 2.83 * units.inch, .7 * units.inch

        c.drawString(25, h / 2 - 6, self.title)
        if self.logo_path:
            c.drawImage(self.logo_path, w - imgw - 25,
                        h / 2 - .5 * imgh, width=imgw, height=imgh,
                        preserveAspectRatio=True)
        c.setFillColorRGB(0, 0, 0)
        c.rect(0, h / 2 + .5 * imgh + 5, w, 1, fill=1)
        c.rect(0, h / 2 - .5 * imgh - 5, w, 1, fill=1)
        c.setFontSize(isletter and 12 or 16)
        c.drawString(25, h / 2 - .5 * imgh - 50, self.subtitle)
        if self.subtitle2:
            c.drawString(25, h / 2 - .5 * imgh - 70, self.subtitle2)
        c.restoreState() 
开发者ID:bpsmith,项目名称:tia,代码行数:24,代码来源:builder.py


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