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


Python Table.wrap方法代码示例

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


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

示例1: drawResume

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
	def drawResume(self, canvas, doc):
		# First table
		style = ParagraphStyle(name='Style')
		style.fontName = 'Helvetica-Bold'
		style.fontSize = 10
		style.alignment = TA_CENTER
		data = [
			[Paragraph('INFORME ACADÉMICO DEL %s' % self.time.upper(), style)],
			['SEDE PRINCIPAL BACHILLERATO']
		]
		LIST_STYLE = TableStyle([
			('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
			('BOX', (0,0), (-1,-1), 0.25, colors.black),
			('TEXTCOLOR',(0,0),(-1,-1),colors.black),
			('ALIGN', (0,0), (-1,-1), 'CENTER'),
			('BACKGROUND', (0, 0), (-1, -1), colors.gray),
			('FONTSIZE', (-1, -1), (-1, -1), 8),
			('VALIGN',(0,0),(-1,-1),'MIDDLE')
		])
		table = Table(data, colWidths='*', rowHeights=0.2 * inch, style=LIST_STYLE)
		w, h = table.wrap(doc.width, 0)

		# Second table
		data = [
			[self.getResumeFirstColum(), self.getSecondColum(), self.getThirdColum(), self.getFourthColum()]
		]
		LIST_STYLE = TableStyle([
			('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
			('BOX', (0, 0), (-1, -1), 0.25, colors.black),
			('BACKGROUND', (0, 0), (-1, -1), colors.gray),
			('TOPPADDING', (0, 0), (-1, -1), 0),
			('BOTTOMPADDING', (0, 0), (-1, -1), 0),
			('LEFTPADDING', (0, 0), (-1, -1), 0),
			('RIGHTPADDING', (0, 0), (-1, -1), 0),
			('FONTSIZE', (0, 0), (-1, -1), 8),
			('ALIGN', (0, 0), (-1, -1), 'CENTER'),
			('VALIGN',(0, 0),(-1, -1),'TOP')
		])
		colWidths = [3*inch, 1.2*inch, 1.4*inch, '*']
		table2 = Table(data, colWidths=colWidths, style=LIST_STYLE)
		w, h = table2.wrap(doc.width, 0)

		wrapper_style = TableStyle([
			('ALIGN', (0, 0), (-1, -1), 'CENTER'),
			('VALIGN',(0, 0),(-1, -1),'MIDDLE'),
			('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
			('BOX', (0, 0), (-1, -1), 0.25, colors.black),
			('TOPPADDING', (0, 0), (-1, -1), 0),
			('BOTTOMPADDING', (0, 0), (-1, -1), 0),
			('LEFTPADDING', (0, 0), (-1, -1), 0),
			('RIGHTPADDING', (0, 0), (-1, -1), 0),
		])
		data = [
			[table],
			[table2]
		]
		wrapper = Table(data, colWidths='*', style=wrapper_style)
		w, h = wrapper.wrap(doc.width, 0)
		wrapper.drawOn(canvas, doc.leftMargin, doc.height + 80)
开发者ID:dairdr,项目名称:notes,代码行数:61,代码来源:log.py

示例2: render

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
  def render(self, stream=None):
    '''
    Render the pdf with current lines & style
    '''
    # Use a buffer when no stream is given
    if stream is None:
      stream = StringIO()

    # Build lines
    self.add_days()
    self.build_lines()

    # Canvas is landscape oriented
    pdf = SimpleDocTemplate(stream, pagesize=landscape(letter))

    # Table is in a frame
    table = Table(self.lines, [1.5* inch ] * 7, self.row_heights, style=self.tableStyle, repeatRows=1)
    table.wrap(0,0) # important hacky way to span on full width
    tableFrame = Frame(inch / 2, inch / 2, 10*inch, 7*inch)

    # RunReport logo
    logo = Image('./medias/img/logo_ligne.png')
    logo.drawHeight = 2.2*inch*logo.drawHeight / logo.drawWidth
    logo.drawWidth = 2.2*inch

    # Plan infos are in a frame, in top left corner
    context = {
      'site' : self.site,
      'plan' : self.plan,
    }
    title = Paragraph(render_to_string('plan/export.pdf.title.html', context), self.titleStyle)

    # Add table elements
    pdf.addPageTemplates([
      PageTemplate(id='table', frames=[tableFrame]),
    ])
    story = [
      logo,
      title,
      Spacer(1, 0.4*inch), # make room for header
      table, # the plan
    ]
    pdf.build(story)

    if isinstance(stream, StringIO):
      output = stream.getvalue()
      stream.close()
      return output

    return None
开发者ID:simongareste,项目名称:coach,代码行数:52,代码来源:pdf.py

示例3: _posting_list_table

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
    def _posting_list_table(self, canvas, x1, y1, x2, y2, shipping_labels):
        style = self.table_style[:]
        table = [self.table_header]
        for i, shipping_label in enumerate(shipping_labels, start=1):
            row = (
                str(shipping_label.tracking_code),
                str(shipping_label.receiver.zip_code),
                str(shipping_label.package.posting_weight),
                self.yes if ExtraService.get(EXTRA_SERVICE_AR) in shipping_label else self.no,
                self.yes if ExtraService.get(EXTRA_SERVICE_MP) in shipping_label else self.no,
                self.yes if shipping_label.has_declared_value() else self.no,
                str(shipping_label.value).replace(".", ",") if shipping_label.value is not None else "",
                str(shipping_label.invoice_number),
                shipping_label.get_package_sequence(),
                shipping_label.receiver.name[:self.max_receiver_name_size],
            )

            # noinspection PyTypeChecker
            table.append(row)

            if i % 2:
                style.append(('BACKGROUND', (0, i), (-1, i), colors.lightgrey))

        table_flow = Table(
            table,
            colWidths=self.col_widths,
            style=TableStyle(style),
        )
        w, h = table_flow.wrap(0, 0)
        table_flow.drawOn(canvas, x1, y2 - h - 50 * mm)
开发者ID:solidarium,项目名称:correios,代码行数:32,代码来源:pdf.py

示例4: writeVerdictPDF

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
   def writeVerdictPDF(self,school_name, filename, verdict):
       sorted_verdict = OrderedDict(sorted(verdict.items(), key=lambda t: t[0]))
       
       styles = getSampleStyleSheet()
       styleN = styles["BodyText"]
       styleN.alignment = TA_LEFT
       styleBH = styles["Normal"]
       styleBH.alignment = TA_CENTER
       
       data= [map(lambda (k,v): Paragraph(k, styleBH), sorted_verdict.iteritems()),
              map(lambda (k,v): Paragraph("<br/> ------------- <br/>".join(set(map(lambda (x): x.strip(), v[2]))), styleN), sorted_verdict.iteritems())]

       cwidth = 120
       table = Table(data, colWidths=[cwidth]*len(sorted_verdict))

       table.setStyle(TableStyle([
          ('INNERGRID', (0,0), (-1,-1), 0.25, black),
          ('BOX', (0,0), (-1,-1), 0.25, black),
          ('VALIGN',(0,0),(-1,-1),'TOP')
          ]))
          
       margin = 20
       w, h = table.wrap(0,0)
       pagewidth = w+margin*2
       pageheight = h+margin*3
       c = canvas.Canvas(filename, pagesize=(pagewidth,pageheight))
       
       table.drawOn(c, margin, pageheight - h - 2*margin)

       c.setFillColor(black) #choose your font colour
       c.drawString(margin,pageheight-margin,school_name)
       
       c.save()
开发者ID:schasins,项目名称:school-program-scraping,代码行数:35,代码来源:sfusd_demo.py

示例5: wrap

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
 def wrap(self, availWidth, availHeight):
     w, h = Table.wrap(self, availWidth, availHeight)
     #print h, w, availHeight, availWidth
     h = 3*cm
     w = 0.9 * PAGE_WIDTH
     #return availWidth, availHeight
     return (w, h)
开发者ID:pacoqueen,项目名称:bbinn,代码行数:9,代码来源:factura_multipag.py

示例6: create_doc_details

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
def create_doc_details(c, table_header, table_body, table_footer):
    w, h = A4
    document_details = []

    c.setFont("Helvetica", 8)

    document_details.append(table_header)
    for detail in table_body:
        document_details.append (detail)
    document_details.append(table_footer)

    ts = [
            ('FONT', (0,0), (-1,-1), 'Times-Roman', 8),
            ('ALIGN', (1,1), (-1,-1), 'CENTER'),
            ('LINEABOVE', (0,0), (-1,0), 1, purple),
            ('LINEBELOW', (0,0), (-1,0), 1, purple),
            ('FONT', (0,0), (-1,0), 'Times-Bold', 6),
            ('LINEABOVE', (0,-1), (-1,-1), 1, purple),
            ('LINEBELOW', (0,-1), (-1,-1), 0.5, purple,1, None, None, 4,1),
            ('LINEBELOW', (0,-1), (-1,-1), 1, red),
            ('FONT', (0,-1), (-1,-1), 'Times-Bold'  ),
        ]
    table = Table(document_details, style=ts, colWidths=35)
    aW = w
    aH = h
    w1,h1 = table.wrap(aW, aH)# find required
    if w<=aW and h<=aH:
        table.drawOn(c, inch ,h - h1 - inch*2.5 )
    else:
        raise ValueError, "Not enough room"
开发者ID:mlouro,项目名称:django-viriato,代码行数:32,代码来源:pdf_gen.py

示例7: wrap

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
    def wrap(self, aw, ah):
        style, data = self.style_and_data
        # Apply any column / row sizes requested
        widths = self.tb.resolve_col_widths(aw)
        heights = self.tb.resolve_row_heights(ah)
        tbl = Table(
            data,
            colWidths=widths,
            rowHeights=heights,
            style=style,
            vAlign=self.vAlign,
            hAlign=self.hAlign,
            repeatCols=False,
            repeatRows=True,
        )
        w, h = tbl.wrap(aw, ah)
        pw, ph = w / float(aw), h / float(ah)
        shrink, expand = self.shrink, self.expand
        scale = 0
        if expand and pw < 1.0 and ph < 1.0:
            scale = max("w" in expand and pw or 0, "h" in expand and ph or 0)
        elif shrink and (pw > 1.0 or ph > 1.0):
            scale = max("w" in shrink and pw or 0, "h" in expand and ph or 0)

        if scale:
            self.component = comp = KeepInFrame(aw, ah, content=[tbl], hAlign=self.hAlign, vAlign=self.vAlign)
            w, h = comp.wrapOn(self.canv, aw, ah)
            comp._scale = scale
        else:
            self.component = tbl
        return w, h
开发者ID:vanife,项目名称:tia,代码行数:33,代码来源:table.py

示例8: drawHeader

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
	def drawHeader(self, canvas, doc):
		logo_path = os.path.join(settings.STATIC_ROOT, 'assets/escudo.jpg')
		logo = Image(logo_path, width=0.7*inch, height=0.7*inch)

		title_style = ParagraphStyle(name='Title')
		title_style.fontName = 'Helvetica-Bold'
		title_style.fontSize = 11
		title_style.alignment = TA_CENTER
		
		subtitle_style = ParagraphStyle(name='Subtitle')
		subtitle_style.fontName = 'Helvetica'
		subtitle_style.fontSize = 8
		subtitle_style.alignment = TA_CENTER

		subtitle2_style = ParagraphStyle(name='Subtitle2')
		subtitle2_style.fontName = 'Helvetica'
		subtitle2_style.fontSize = 8
		subtitle2_style.alignment = TA_CENTER

		subtitle3_style = ParagraphStyle(name='Subtitle3')
		subtitle3_style.fontName = 'Helvetica'
		subtitle3_style.fontSize = 8
		subtitle3_style.alignment = TA_CENTER

		subtitle4_style = ParagraphStyle(name='Subtitle4')
		subtitle4_style.fontName = 'Helvetica'
		subtitle4_style.fontSize = 8
		subtitle4_style.alignment = TA_CENTER

		data = [
			[logo, [
					Paragraph('INSTITUCION EDUCATIVA AUGUSTO ESPINOSA VALDERRAMA', title_style),
					Paragraph('Reconocido oficialmente por la Secretaría de Educación Municipal de Montería mediante resolución 0751 de junio 12 de 2009', subtitle_style),
					Paragraph('Corregimiento Santa Clara – Municipio de Montería', subtitle2_style),
					Paragraph('Tel. 7905949 Código DANE 223001005404', subtitle3_style),
					Paragraph('Nit 812007342', subtitle4_style)
				]
			]
		]
		LIST_STYLE = TableStyle([
			# ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
			# ('BOX', (0,0), (-1,-1), 0.25, colors.black),
			('TEXTCOLOR',(0,0),(-1,-1),colors.black),
			('ALIGN', (0,0), (-1,-1), 'CENTER'),
			('FONTSIZE', (-1, -1), (-1, -1), 8),
			('VALIGN',(0,0),(-1,-1),'MIDDLE'),
			('TOPPADDING', (0, 0), (-1, -1), 0),
			('BOTTOMPADDING', (0, 0), (-1, -1), 0),
			('LEFTPADDING', (0, 0), (-1, -1), 0),
			('RIGHTPADDING', (0, 0), (-1, -1), 0),
		])
		colWidths = [0.7*inch, '*']
		table = Table(data, colWidths=colWidths, style=LIST_STYLE)
		w, h = table.wrap(doc.width, 0)
		table.drawOn(canvas, doc.leftMargin + 5, doc.height + 150)
开发者ID:dairdr,项目名称:notes,代码行数:57,代码来源:log.py

示例9: receipt_details

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
def receipt_details(canvas, document):
    import os
    print os.getcwd()
    canvas.bottomUp = 1
    t = Table(receipt_info, repeatRows=1, style=[('GRID', (0, 0), (-1, -1), 0.5, colors.grey), ])
    t.wrap(3.5*inch, 1.5*inch)
    t.drawOn(canvas, 4.5*inch, 8.5*inch)
    canvas.bottomUp = 0
    canvas.saveState()
    canvas.scale(0.10, 0.10)
    canvas.translate(2.5*inch, 85*inch)
    canvas.drawImage(os.path.join('Seller', '05-full-3-colour.png'), 0.5*inch, 8.5*inch, mask=[255, 255, 255, 255, 255, 255])
    canvas.restoreState()
    textObject = canvas.beginText()
    textObject.setTextOrigin(0.5*inch, 9*inch)
    textObject.setFont(styles['Normal'].fontName, styles['Normal'].fontSize, leading=styles['Normal'].leading)

    textObject.textLine('1455 de Maisonneuve Ouest, Suite H-838')
    textObject.textLine('Montreal, QC, Canada')
    textObject.textLine('H3G1M8')
    canvas.drawText(textObject)
开发者ID:ECAConcordia,项目名称:internal-webapp,代码行数:23,代码来源:pdf.py

示例10: drawConventions

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
	def drawConventions(self, canvas, doc):
		column_style = TableStyle([
			('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
			('BOX', (0, 0), (-1, -1), 0.25, colors.black),
			('TOPPADDING', (0, 0), (-1, -1), 6),
			('BACKGROUND', (0, 0), (-1, -1), colors.gray),
			('FONTSIZE', (0, 0), (-1, -1), 8),
			('ALIGN', (0, 0), (-1, -1), 'CENTER'),
			('VALIGN',(0, 0),(-1, -1),'MIDDLE')
		])

		style = ParagraphStyle(name='Style')
		style.fontName = 'Helvetica-Bold'
		style.fontSize = 7
		style.alignment = TA_CENTER
		data = [
			[Paragraph('CONVENCIONES ACERCA DE LA EVALUACIÓN POR DESEMPEÑOS SEGUN DECRETO 1290 DE 2009', style)]
		]
		table = Table(data, colWidths='*', rowHeights=0.15*inch, style=column_style)
		

		column_style = TableStyle([
			('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
			('BOX', (0, 0), (-1, -1), 0.25, colors.black),
			('TOPPADDING', (0, 0), (-1, -1), 5),
			('BACKGROUND', (0, 0), (-1, -1), '#CCCCCC'),
			('FONTSIZE', (0, 0), (-1, -1), 7),
			('ALIGN', (0, 0), (-1, -1), 'CENTER'),
			('VALIGN',(0, 0),(-1, -1),'MIDDLE')
		])
		data = [
			['DESEMPEÑO BAJO: 1.0 a 6.4', 'DESEMPEÑO BASICO: 6.5 a 7.9', 'DESEMPEÑO ALTO: 8.0 a 9.4', 'DESEMPEÑO SUPERIOR: 9.5 a 10']
		]
		table2 = Table(data, colWidths='*', rowHeights=0.15*inch, style=column_style)

		wrapper_style = TableStyle([
			('ALIGN', (0, 0), (-1, -1), 'CENTER'),
			('VALIGN',(0, 0),(-1, -1),'MIDDLE'),
			('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
			('BOX', (0, 0), (-1, -1), 0.25, colors.black),
			('TOPPADDING', (0, 0), (-1, -1), 0),
			('BOTTOMPADDING', (0, 0), (-1, -1), 0),
			('LEFTPADDING', (0, 0), (-1, -1), 0),
			('RIGHTPADDING', (0, 0), (-1, -1), 0),
		])
		data = [
			[table],
			[table2]
		]
		wrapper = Table(data, colWidths='*', style=wrapper_style)
		w, h = wrapper.wrap(doc.width, 0)
		wrapper.drawOn(canvas, doc.leftMargin, doc.height + 50)
开发者ID:dairdr,项目名称:notes,代码行数:54,代码来源:log.py

示例11: header_building

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
def header_building(canvas, doc, styles):
    a = Image(settings.LOGO_INSTITUTION_URL, width=15*mm, height=20*mm)
    p = Paragraph('''<para align=center>
                        <font size=16>%s</font>
                    </para>''' % (_('documents')), styles["Normal"])

    data_header = [[a, '%s' % _('ucl_denom_location'), p], ]

    t_header = Table(data_header, [30*mm, 100*mm, 50*mm])

    t_header.setStyle(TableStyle([]))

    w, h = t_header.wrap(doc.width, doc.topMargin)
    t_header.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin - h)
开发者ID:uclouvain,项目名称:osis-portal,代码行数:16,代码来源:pdf_utils.py

示例12: printEventParticipationDetails

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
def printEventParticipationDetails(pdf, x, y, user, singularEventRegistrations, userTeams):

    lineheight = PDFSetFont(pdf, 'Times-Bold', 16)

    (A4Width, A4Height) = A4

    pdf.drawCentredString(A4Width/2, y, 'PARTICIPATION DETAILS')

    y -= lineheight + cm

    # Construct the table data
    
    sNo = 1
    #!!!!!!!
    tableData = [ ['Serial No', 'Event Name', 'Team Name', 'Team ID'] ]
    #!!!!!!
    """
    for eventRegistration in singularEventRegistrations:
        tableData.append([sNo, eventRegistration.event.title, '', ''])
        sNo += 1
    """  
    for team in userTeams:
        teamname_str = 'Not provided during regn.'
        if team.team_name:
            teamname_str = team.team_name
        if team.get_event():
            tableData.append([sNo, team.get_event().title, teamname_str, team.team_id])
        sNo += 1
        
    t = Table(tableData, repeatRows=1)

    # Set the table style

    tableStyle = TableStyle([ ('FONTNAME', (0, 1), (-1, -1), 'Times-Roman'), # Font style for Table Data
                              ('FONTNAME', (0, 0), (-1, 0), 'Times-Bold'), # Font style for Table Header
                              ('FONTSIZE', (0, 0), (-1, -1), 12),
                              ('ALIGN', (0, 0), (-1, -1), 'CENTRE'),
                              ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
                              ('GRID', (0, 0), (-1, -1), 1, colors.black),
                            ])
    t.setStyle(tableStyle)
    (A4Width, A4Height) = A4
    availableWidth = A4Width - 2 * cm  # Leaving margins of 1 cm on both sides
    availableHeight = y
    (tableWidth, tableHeight) = t.wrap(availableWidth, availableHeight)  # find required space
    
    t.drawOn(pdf, x, y - tableHeight)
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:49,代码来源:participantPDF_2k14.py

示例13: header_building

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
def header_building(canvas, doc,styles):
    a = Image("core"+ settings.STATIC_URL +"/img/logo_institution.jpg")

    P = Paragraph('''
                    <para align=center spaceb=3>
                        <font size=16>%s</font>
                    </para>''' % (_('Scores transcript')), styles["BodyText"])
    data_header=[[a,'%s' % _('University Catholic Louvain\nLouvain-la-Neuve\nBelgium') ,P],]

    t_header=Table(data_header, [30*mm, 100*mm,50*mm])

    t_header.setStyle(TableStyle([
                    #    ('SPAN',(0,0), (0,-1)),
                       ]))

    w, h = t_header.wrap(doc.width, doc.topMargin)
    t_header.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin - h)
开发者ID:fthuin,项目名称:osis,代码行数:19,代码来源:pdf_utils.py

示例14: wrap

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
    def wrap(self, availWidth, availHeight):
        """Reimplementation of Table.wrap().

        It works by mimicking the width calculation on a dummy Table, and if
        the result warrant it, by scaling down the text and padding of each
        cell.

        """

        ## Create a standard Table with the same contents and style as ours.
        ## Use it to determine if it fits inside our available width.

        args, kwargs = self.init_args
        std_table = Table(*args, **kwargs)
        std_table._calc(availWidth, availHeight)

        ## Cache the cell metrics. The Platypus layout algorithm may call this
        ## any number of times, and we only want to compute new metrics based
        ## on the original cell metrics.

        if not self._cached_cell_styles:
            self._cached_cell_styles = copy.deepcopy(self._cellStyles)

        if availWidth < std_table._width and len(self._cellStyles) > 0:

            ## If a standard table wouldn't fit, attempt to resize the current
            ## table's contents.

            ratio = availWidth / float(std_table._width)

            for current_line, cached_line in zip(self._cellStyles, self._cached_cell_styles):
                for current_cell, cached_cell in zip(current_line, cached_line):
                    current_cell.fontsize      = ratio * cached_cell.fontsize
                    current_cell.leftPadding   = ratio * cached_cell.leftPadding
                    current_cell.rightPadding  = ratio * cached_cell.rightPadding
                    current_cell.topPadding    = ratio * cached_cell.topPadding
                    current_cell.bottomPadding = ratio * cached_cell.bottomPadding

        return Table.wrap(self, availWidth, availHeight)
开发者ID:securactive,项目名称:sact.resizabletable,代码行数:41,代码来源:resizabletable.py

示例15: createPDF

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import wrap [as 别名]
    def createPDF(self):
        xml = self.xml_obj
        styles = getSampleStyleSheet()
        styles = styles['BodyText']
        styles.wordWrap = 'CJK'

        # Example user
        users = {'U00000000': 'bogeunchoi'}

        data = []
        data.append(['Channel: ' + channelName])
        data.append(["User", "Time", "Message (top = newest)"])

        for item in xml.data.iterchildren():
            # Creating name column
            row = []
            row.append(item.name)

            # Creating time column
            s = item.time
            date = datetime.datetime.fromtimestamp(s).strftime('%Y-%m-%d %H:%M:%S')
            row.append(date)

            # Creating message column
            if ('&#8217;' in item.message.text):
                item.message.text = item.message.text.replace('&#8217;', '\'')

            text = item.message.text

            # Filtering out the @U0... and replacing with usernames
            for key, value in users.items():
                keyPlus = key + '|'
                if keyPlus in text:
                    text = text.replace(keyPlus, "")
                elif key in text:
                    text = text.replace(key, value)

            text = filter(lambda c: c not in "<>", text)

            message = Paragraph(text, styles)
            row.append(message)

            data.append(row)

        t = Table(data, colWidths=(75, 110, 100*mm), hAlign='CENTER')
        t.setStyle(TableStyle([
            ('INNERGRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('BOX', (0, 0), (-1, -1), 0.5, colors.black),
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('SPAN', (0, 0), (-1, 0))
        ]))
        width, height = t.wrap(0, 0)
        w = width
        h = height

        self.canvas = canvas.Canvas(self.pdf_file, pagesize=(w, h))
        width, self.height = letter

        t.wrapOn(self.canvas, width, self.height)
        t.drawOn(self.canvas, 0, 0)
        t.canvas = self.canvas
开发者ID:TheJPFDude,项目名称:slack-data-grabber,代码行数:63,代码来源:xml_to_pdf.py


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