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


Python pagesizes.A4属性代码示例

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


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

示例1: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def __init__(self, cwd, output, version=''):
        self.cwd = cwd
        self.tag = os.path.basename(os.path.normpath(self.cwd))
        self.version = version
        self.story = []
        stylesheet = getSampleStyleSheet()
        self.title_style = stylesheet['Title']
        self.heading_style = stylesheet['Heading2']
        self.heading2_style = stylesheet['Heading3']
        self.normal_style = stylesheet['Normal']
        self.body_style = stylesheet['BodyText']
        self.current_section = 0
        self.doc = doc = SimpleDocTemplate(output,
            pagesize=A4,
            leftMargin=2.2*cm, rightMargin=2.2*cm,
            topMargin=1.5*cm,bottomMargin=2.5*cm)
        self.plot_width = self.doc.width * 0.85
        self.plot_scale = 0.4 
开发者ID:giesselmann,项目名称:nanopype,代码行数:20,代码来源:report.py

示例2: makeBarcodeFile

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [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 pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def __init__(self, page_size=pagesizes.A4, shipping_labels_margin=(0, 0), posting_list_margin=(5 * mm, 5 * mm)):
        self.shipping_labels = []  # type: List[ShippingLabel]
        self._tracking_codes = set()

        self.page_size = page_size
        self.page_width = page_size[0]
        self.page_height = page_size[1]

        self.posting_list = None  # type: PostingList
        self.posting_list_margin = posting_list_margin

        self.shipping_labels_margin = shipping_labels_margin
        self.shipping_labels_width = self.page_width - (2 * shipping_labels_margin[0])
        self.shipping_labels_height = self.page_height - (2 * shipping_labels_margin[1])

        self.col_size = self.shipping_labels_width / 2
        self.row_size = self.shipping_labels_height / 2
        self._label_position = (
            (shipping_labels_margin[0], self.page_height / 2),
            (shipping_labels_margin[0] + self.col_size, self.page_height / 2),
            (shipping_labels_margin[0], shipping_labels_margin[1]),
            (shipping_labels_margin[0] + self.col_size, shipping_labels_margin[1]),
        ) 
开发者ID:olist,项目名称:correios,代码行数:25,代码来源:pdf.py

示例4: imgs_to_pdf

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def imgs_to_pdf(img_path_list, target_path):
    """将一组图片合成一个pdf文件
    :param str target_path: 输出pdf文件路径
    :param list img_path_list: 要合成的图片的路径列表
    :return str target_path: 输出pdf文件路径
    """
    a4_w, a4_h = portrait(A4)

    c = canvas.Canvas(target_path, pagesize=portrait(A4))
    for img_path in img_path_list:
        img_w, img_h = ImageReader(img_path).getSize()

        if img_w / img_h > a4_w / a4_h:
            # 横图
            ratio = a4_w / img_w
            left_margin = 0
            top_margin = (a4_h - img_h * ratio) / 2
        else:
            # 竖图
            ratio = a4_h / img_h
            left_margin = (a4_w - img_w * ratio) / 2
            top_margin = 0
        c.drawImage(img_path, left_margin, top_margin, img_w * ratio, img_h * ratio)
        c.showPage()
    os.makedirs(os.path.dirname(target_path), exist_ok=True)
    c.save()
    return target_path 
开发者ID:lossme,项目名称:TencentComicBook,代码行数:29,代码来源:img2pdf.py

示例5: on_first_page

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def on_first_page(self, canvas, doc):
        canvas.saveState()
        canvas.rotate(90)
        canvas.setFont('Helvetica-Bold', 100)
        canvas.setFillGray(0.8)
        canvas.drawString(0, -0.95*A4[0], "Nanopype")
        canvas.restoreState() 
开发者ID:giesselmann,项目名称:nanopype,代码行数:9,代码来源:report.py

示例6: on_later_pages

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def on_later_pages(self, canvas, doc):
        canvas.saveState()
        canvas.setFont('Helvetica', 10)
        canvas.setLineWidth(0.5)
        canvas.line(doc.leftMargin, 1.5*cm, A4[0]-doc.rightMargin, 1.5*cm)
        canvas.drawString(doc.leftMargin, 0.8*cm, "Nanopype report")
        canvas.drawCentredString(A4[0] // 2, 0.8 * cm, "{:d}".format(doc.page))
        canvas.drawRightString(A4[0] - doc.rightMargin, 0.8*cm, "{}".format(self.tag))
        canvas.restoreState() 
开发者ID:giesselmann,项目名称:nanopype,代码行数:11,代码来源:report.py

示例7: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def __init__(self, GATHERING_OPTIONS, CONTAINERS, PROCESS_TREE):
        self.report_date = nicedate.NiceDate.get_now()

        self.timezone = nicedate.CONFIG_TIMEZONE
        self.CONTAINERS = CONTAINERS
        self.GATHERING_OPTIONS = GATHERING_OPTIONS
        self.PROCESS_TREE = PROCESS_TREE
        self.report_filename = self.GATHERING_OPTIONS['report_dir'] + "\\" + "malware_report_" + self.report_date.strftime("%Y-%m-%d %H_%M_%S") + ".pdf"
        self.canvas = canvas.Canvas(self.report_filename, pagesize=A4)

        #PDF
        self.pdf_initalize_styles()
        self.f = []
        self.doc = SimpleDocTemplate(self.report_filename) 
开发者ID:yarox24,项目名称:attack_monitor,代码行数:16,代码来源:reporting.py

示例8: test

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def test() :
    """Test this."""
    from reportlab.pdfgen.canvas import Canvas
    from reportlab.lib import pagesizes

    canvas = Canvas("labels.pdf", pagesize=pagesizes.A4)
    canvas.setFont("Helvetica", 30)
    (width, height) = pagesizes.A4
    canvas.drawCentredString(width/2.0, height-4*cm, "Sample LTO labels")
    xpos = xorig = 2 * cm
    ypos = yorig = 2 * cm
    colwidth = 10 * cm
    lineheight = 3.9 * cm
    count = 1234
    BaseLTOLabel("RL", count, "3").drawOn(canvas, xpos, ypos)
    ypos += lineheight
    count += 1
    BaseLTOLabel("RL", count, "3",
                 border=0.0125).drawOn(canvas, xpos, ypos)
    ypos += lineheight
    count += 1
    VerticalLTOLabel("RL", count, "3").drawOn(canvas, xpos, ypos)
    ypos += lineheight
    count += 1
    VerticalLTOLabel("RL", count, "3",
                    border=0.0125).drawOn(canvas, xpos, ypos)
    ypos += lineheight
    count += 1
    VerticalLTOLabel("RL", count, "3",
                    colored=True).drawOn(canvas, xpos, ypos)
    ypos += lineheight
    count += 1
    VerticalLTOLabel("RL", count, "3",
                    border=0.0125, colored=True).drawOn(canvas, xpos, ypos)
    canvas.showPage()
    canvas.save() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:38,代码来源:lto.py

示例9: write_pdf

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def write_pdf(self, mod):
        file_path = os.path.join(self.write_path if self.write_path != "" else mod.__path__[0], "doc")
        file_name = mod.__package__ + ".pdf"
        
        if not os.path.exists(file_path):
            os.mkdir(file_path)
        
        doc = SimpleDocTemplate(os.path.join(file_path, file_name), 
                                pagesize = A4,
                                leftMargin = 0.25 * inch,
                                rightMargin = 0.25 * inch,
                                topMargin = 0.25 * inch,
                                bottomMargin = 0.25 * inch)      
         
        lib_name = mod.__package__.replace("_", " ") 
        self.create_hdr(lib_name, font_size=24)
        
        print("\n", lib_name, "\n")
        
        dirs = self.read_include_file(os.path.join(mod.__path__[0], "doc"))
        
        if len(dirs) > 0:
            for d in dirs:
                path = os.path.join(mod.__path__[0], d)
                if os.path.exists(path):
                    self.create_hdr(d.title(), font_size=18)
                    self.search_dir(path)
                 
        else:
            products_path = os.path.join(mod.__path__[0], "products")
            if os.path.exists(products_path):
                self.create_hdr("Products", font_size=18)
                self.search_dir(products_path)
             
            inserts_path = os.path.join(mod.__path__[0], "inserts")
            if os.path.exists(inserts_path):
                self.create_hdr("Inserts", font_size=18)
                self.search_dir(inserts_path)              
         
        doc.build(self.elements) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:42,代码来源:fd_api_doc.py

示例10: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def __init__(self, titulo):
        self.c = canvas.Canvas("datasheet.pdf", pagesize=A4)
        self.c.setTitle(titulo) 
开发者ID:jjgomera,项目名称:pychemqt,代码行数:5,代码来源:datasheet.py

示例11: apply

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def apply(self, inPdf):
        """
        @inPdf pdf binary, None for empty page
        """
        if inPdf is None: return self._createMask()
        inPdf = self.pdfNormaliseFormat(inPdf,*self.pagesize) # force A4
        if "wand" in globals():
            return self.pdfWatermark(inPdf, self._createMask, True)
        else: 
            self.maskpdf = self._createMask()
            return self.pdfWatermark(inPdf, lambda *args:self.maskpdf, False) 
开发者ID:dfd-tud,项目名称:deda,代码行数:13,代码来源:privacy.py

示例12: pic_to_pdf

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def pic_to_pdf(page_count,wenku_title):
    filename=wenku_title+'\\'+wenku_title+'.pdf'
    c = canvas.Canvas(filename)
    (w,h) = portrait(A4)
    print('开始写入pdf')
    for i in range(1,page_count+1):
        c.drawImage('{}/第{}页图片.png'.format(wenku_title,i),0,0,w,h)
        c.showPage()
    c.save()
    print('文件保存在{}文件夹下的{}.pdf中'.format(wenku_title,wenku_title)) 
开发者ID:vict-cn,项目名称:crawlBaiduWenku,代码行数:12,代码来源:crawlBaiduWenku.py

示例13: pic_to_pdf

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def pic_to_pdf(filename):
    if '.pdf' not in filename:
        filename=filename+'.pdf'
    c = canvas.Canvas(filename)
    (w,h) = portrait(A4)
    for i in range(2):
        while True :
            try:
                c.drawImage(str(i+1)+'.png',0,0,w,h)
                c.showPage()
                break
            except:
                pass
    c.save()
    print('文件保存为{}.pdf'.format(filename)) 
开发者ID:vict-cn,项目名称:crawlBaiduWenku,代码行数:17,代码来源:pic_to_pdf.py

示例14: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def __init__(self, filename: str, page_title: str, font: str="Helvetica", metadata: dict=None, metadata_location: tuple=(2, 25.5)):
        self.canvas = Canvas(filename, pagesize=A4)
        self._font = font
        self._title = page_title
        self._metadata = metadata
        self._metadata_location = metadata_location
        self._generate_pylinac_template_theme()
        self._add_metadata() 
开发者ID:jrkerns,项目名称:pylinac,代码行数:10,代码来源:pdf.py

示例15: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import A4 [as 别名]
def __init__(self, page_size=A4, font_face='Helvetica'):
        self.page_size = page_size
        self.font_face = font_face
        self.logo = None 
开发者ID:uwdata,项目名称:termite-visualizations,代码行数:6,代码来源:pdfinvoice.py


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