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


Python pagesizes.letter方法代码示例

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


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

示例1: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def __init__(self, display_form, letter_display=None, canvas=None):
        self.file = io.BytesIO()
        self.width, self.height = letter
        self.canvas = canvas
        if not canvas:
            self.canvas = Canvas(
                self.file,
                pagesize=letter)
            self.canvas.setAuthor('Clear My Record, Code for America')
        self.frame = Margin(
            u('1in'),
            u('.75in'),
            u('1in'),
            u('.75in'))
        self.form = display_form
        self.letter = letter_display
        self.cursor = Position(
            self.frame.left,
            self.height - self.frame.top
        )
        self.nice_date = \
            self.form.date_received.get_current_value().strftime("%B %-d, %Y") 
开发者ID:codeforamerica,项目名称:intake,代码行数:24,代码来源:pdf_form_display.py

示例2: draw_letter

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def draw_letter(self):
        max_width = u('6.5in')
        max_height = self.height - (
            self.frame.top + self.frame.bottom)
        self.set_cursor(u('1in'), self.height - self.frame.top)
        dx, dy = self.draw_paragraph(
            self.nice_date, max_width, max_height, BODY_STYLE)
        self.move_cursor(0, -(dy + self.field_bottom_margin))
        dx, dy = self.draw_paragraph(
            "To Whom It May Concern,", max_width, max_height, BODY_STYLE)
        self.move_cursor(0, -(dy + self.field_bottom_margin))
        for field in self.keys_to_fields(self.letter_display_fields, 'letter'):
            dx, dy = self.draw_paragraph(
                field.get_display_value(), max_width, max_height, BODY_STYLE)
            self.move_cursor(0, -(dy + self.field_bottom_margin))
        dx, dy = self.draw_paragraph(
            "Sincerely,", max_width, max_height, BODY_STYLE)
        self.move_cursor(0, -(dy + self.field_bottom_margin))
        full_name = " ".join([
            self.form.first_name.get_display_value(),
            self.form.last_name.get_display_value()
        ])
        dx, dy = self.draw_paragraph(
            full_name, max_width, max_height, BODY_STYLE) 
开发者ID:codeforamerica,项目名称:intake,代码行数:26,代码来源:pdf_form_display.py

示例3: gen_decomposition

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def gen_decomposition(denovo_name, basis_names, weights, output_path, project, reconstruction, statistics):

	c = canvas.Canvas(output_path+"/"+denovo_name+"_decomposition_"+project+".pdf", pagesize=letter)
	c.setPageSize(landscape(letter))
	c.setFont("Arial-Bold", 7.19)

	basis_plots = []
	for i in range(0,len(basis_names)):
		basis_plots.append([basis_names[i], weights[i]])


	# create for loop to iterate through list, then change second value in list of lists
	# Otherwise sorts strings and then 5.14% > 48.54%
	for j in range(0, len(basis_names)):
		basis_plots[j][1] = float(basis_plots[j][1].strip("%"))
	sorted_list = sorted(basis_plots, key=lambda tup: tup[1], reverse=True)

	gen_plot(denovo_name, sorted_list, output_path, project, c, reconstruction, statistics)

	c.save() 
开发者ID:AlexandrovLab,项目名称:SigProfilerExtractor,代码行数:22,代码来源:PlotDecomposition_SBS96.py

示例4: gen_decomposition

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def gen_decomposition(denovo_name, basis_names, weights, output_path, project, reconstruction, statistics):
	# Note: 0th index contains the title of the column
	c = canvas.Canvas(output_path+"/"+denovo_name+"_decomposition_"+project+".pdf", pagesize=letter)
	c.setPageSize(landscape(letter))
	c.setFont("Arial-Bold", 7.19)

	basis_plots = []
	for i in range(0,len(basis_names)):
		basis_plots.append([basis_names[i], weights[i]])


	# create for loop to iterate through list, then change second value in list of lists
	# Otherwise sorts strings and then 5.14% > 48.54%
	for j in range(0, len(basis_names)):
		basis_plots[j][1] = float(basis_plots[j][1].strip("%"))
	sorted_list = sorted(basis_plots, key=lambda tup: tup[1], reverse=True)

	gen_plot(denovo_name, sorted_list, output_path, project, c, reconstruction, statistics)

	c.save() 
开发者ID:AlexandrovLab,项目名称:SigProfilerExtractor,代码行数:22,代码来源:PlotDecomposition_ID83.py

示例5: gen_decomposition

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def gen_decomposition(denovo_name, basis_names, weights, output_path, project, reconstruction, statistics):
	# Note: 0th index contains the title of the column
	c = canvas.Canvas(output_path+"/"+denovo_name+"_decomposition_"+project+".pdf", pagesize=letter)
	c.setPageSize(landscape(letter))
	c.setFont("Arial-Bold", 7.19)

	basis_plots = []
	for i in range(0,len(basis_names)):
		basis_plots.append([basis_names[i], weights[i]])

	# create for loop to iterate through list, then change second value in list of lists
	# Otherwise sorts strings and then 5.14% > 48.54%
	for j in range(0, len(basis_names)):
		basis_plots[j][1] = float(basis_plots[j][1].strip("%"))
	sorted_list = sorted(basis_plots, key=lambda tup: tup[1], reverse=True)

	gen_plot(denovo_name, sorted_list, output_path, project, c, reconstruction, statistics)

	c.save() 
开发者ID:AlexandrovLab,项目名称:SigProfilerExtractor,代码行数:21,代码来源:PlotDecomposition_SBS1536.py

示例6: generate

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def generate(cls, pdf_input_data: dict):
        # setup
        self = cls()
        reports = pdf_input_data.get("reports", [])
        matches = pdf_input_data.get("matches", [])
        report_buffer = BytesIO()
        doc = SimpleDocTemplate(
            report_buffer,
            pagesize=letter,
            rightMargin=72,
            leftMargin=72,
            topMargin=72,
            bottomMargin=72,
        )

        # content fill
        self.pdf_elements.extend(self.cover_page())
        self.pdf_elements.extend(self.report_pages(reports))
        self.pdf_elements.extend(self.match_pages_empty_identifier(matches))

        # teardown
        doc.build(self.pdf_elements, canvasmaker=NumberedCanvas)
        result = report_buffer.getvalue()
        report_buffer.close()
        return result 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:27,代码来源:report_delivery.py

示例7: onPage

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [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

示例8: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [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

示例9: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def __init__(self, invoice_path, pdf_info=None, precision='0.01'):
        if not pdf_info:
            pdf_info = self.default_pdf_info

        SimpleDocTemplate.__init__(
            self,
            invoice_path,
            pagesize=letter,
            rightMargin=inch,
            leftMargin=inch,
            topMargin=inch,
            bottomMargin=inch,
            **pdf_info.__dict__
        )

        self.precision = precision

        self._defined_styles = getSampleStyleSheet()
        self._defined_styles.add(
            ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
        )
        self._defined_styles.add(
            ParagraphStyle('TableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
        )

        self.invoice_info = None
        self.service_provider_info = None
        self.client_info = None
        self.is_paid = False
        self._items = []
        self._item_tax_rate = None
        self._transactions = []
        self._story = []
        self._bottom_tip = None
        self._bottom_tip_align = None 
开发者ID:CiCiApp,项目名称:PyInvoice,代码行数:37,代码来源:templates.py

示例10: __init__

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def __init__(self, invoice_path, pdf_info=None, precision='0.01'):
        if not pdf_info:
            pdf_info = self.default_pdf_info

        SimpleDocTemplate.__init__(
            self,
            invoice_path,
            pagesize=letter,
            rightMargin=inch,
            leftMargin=inch,
            topMargin=inch,
            bottomMargin=inch,
            **pdf_info.__dict__
        )

        self.precision = precision

        self._defined_styles = getSampleStyleSheet()
        self._defined_styles.add(
            ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
        )
        self._defined_styles.add(
            ParagraphStyle('TableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
        )

        self.invoice_info = None
        self.service_provider_info = None
        self.client_info = None
        self.is_paid = False
        self._items = []
        self._item_discount_rate = None
        self._transactions = []
        self._story = []
        self._bottom_tip = None
        self._bottom_tip_align = None
        self._amount_recieved = None 
开发者ID:104H,项目名称:HH---POS-Accounting-and-ERP-Software,代码行数:38,代码来源:templates.py

示例11: makeAccountStatement

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def makeAccountStatement (holder, rows, date=datetime.now()):
	from reportlab.pdfgen import canvas
	date = str(date)

	canvas = canvas.Canvas("accounts/" + holder.replace('/', "") + ".pdf", pagesize=letter)
	canvas.setLineWidth(.3)
	canvas.setFont('Helvetica', 12)
	
	canvas.drawString(30,750, 'Account Statement of ' + holder)
	canvas.drawString(30,735, 'At ACME INDUSTRIES')
	canvas.drawString(420,750, date)

	# heading
	makeHeader(canvas)

	diff = 0
	for r in rows:
		verticalPos = 650-diff
		
		if verticalPos == 50:
			canvas.showPage()
			makeHeader(canvas)
			verticalPos = 650
			diff = 0
			
		
		canvas.drawString(20,verticalPos,r[0])
		canvas.drawString(90,verticalPos,r[1][:-1])
		canvas.drawString(150,verticalPos,r[2])
		canvas.drawString(280,verticalPos,r[3])
		canvas.drawString(360,verticalPos,r[4])
		canvas.drawString(420,verticalPos,r[5])
		canvas.drawString(480,verticalPos,r[6])
		
		diff = diff + 50
	
	canvas.save() 
开发者ID:104H,项目名称:HH---POS-Accounting-and-ERP-Software,代码行数:39,代码来源:accountStatmentMaker.py

示例12: generate_card

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def generate_card(IMG_FILE,IMG_URL,TEXT_FRONT,TEXT_INSIDE):
    """Main function to generate PDF and print to stdout. Designed to be
    run as a CGI application."""
    if not (IMG_FILE or IMG_URL):
        print 'You must upload an image file or provide a URL to one'
        return

    tmp = StringIO()

    #Canvas Setup
    c = canvas.Canvas(tmp, pagesize=letter, pageCompression=0)
    #If output size is important set pageCompression=1, but remember that, compressed documents
    #will be smaller, but slower to generate. Note that images are always compressed, and this option will only
    #save space if you have a very large amount of text and vector graphics on each page.
    #Do I need 'MacRomanEncoding' for Macs?
    #Note: 0,0 coordinate in canvas is bottom left.
    c.setAuthor('Utility Mill - utilitymill.com/utility/greeting_card_generator')
    c.setTitle('Beautiful, expensive greeting card created at utilitymill.com')

    #add_fold_lines(c) #early feedback says lines aren't necessary. Uncomment here to put them in
    put_in_front_picture(c,IMG_FILE,IMG_URL)
    write_text(c,TEXT_FRONT.replace('\r',''),TEXT_INSIDE.replace('\r',''))

    #The showPage method saves the current page of the canvas
    c.showPage()
    #The save method stores the file and closes the canvas.
    c.save()

    tmp.seek(0)
    print 'Content-Type: application/pdf'
    print tmp.read() 
开发者ID:ActiveState,项目名称:code,代码行数:33,代码来源:recipe-535155.py

示例13: render

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def render(self, save=True, title=None):
        self.draw_header()
        self.draw_main_fields()
        self.draw_case_status_fields()
        self.canvas.showPage()
        if self.letter:
            self.draw_letter()
            self.canvas.showPage()
        if title:
            self.canvas.setTitle(title)
        if save:
            self.canvas.save()
        return self.canvas, self.file 
开发者ID:codeforamerica,项目名称:intake,代码行数:15,代码来源:pdf_form_display.py

示例14: draw_page_number

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def draw_page_number(self, page_count):
        width, height = letter
        margin = 0.66 * 72
        self.setFillColor("gray")
        self.drawRightString(
            width - margin, margin, "Page %d of %d" % (self._pageNumber, page_count)
        ) 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:9,代码来源:report_delivery.py

示例15: get_header_footer

# 需要导入模块: from reportlab.lib import pagesizes [as 别名]
# 或者: from reportlab.lib.pagesizes import letter [as 别名]
def get_header_footer(self, recipient):
        def func(canvas, doc):
            width, height = letter
            margin = 0.66 * 72
            canvas.saveState()
            canvas.setFillColor("gray")
            canvas.drawString(margin, height - margin, "CONFIDENTIAL")
            canvas.drawRightString(width - margin, height - margin, str(timezone.now()))
            canvas.restoreState()

        return func 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:13,代码来源:report_delivery.py


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