本文整理汇总了Python中reportlab.lib.styles.getSampleStyleSheet函数的典型用法代码示例。如果您正苦于以下问题:Python getSampleStyleSheet函数的具体用法?Python getSampleStyleSheet怎么用?Python getSampleStyleSheet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSampleStyleSheet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: fillReport
def fillReport(self, data):
buffer = self.buffer
doc = SimpleDocTemplate(buffer,
rightMargin=72,
leftMargin=72,
topMargin=72,
bottomMargin=72,
headertext=self.headertext,
footertext=self.footertext,
pagesize=self.pagesize)
# Our container for 'Flowable' objects
elements = []
# A large collection of style sheets pre-made for us
styles = getSampleStyleSheet()
#styles.add(ParagraphStyle(name='centered', alignment=TA_CENTER))
#Configure style and word wrap
s = getSampleStyleSheet()
s = s["BodyText"]
s.wordWrap = 'CJK'
#format the data table
data2 = [[Paragraph(cell, s) for cell in row] for row in data]
t=Table(data2, repeatRows=1)
#Send the data and build the file
elements.append(Paragraph('Report', styles['Heading2']))
elements.append(t)
doc.build(elements, onFirstPage=self._header_footer, onLaterPages=self._header_footer)
# Get the value of the BytesIO buffer and write it to the response.
pdf = buffer.getvalue()
buffer.close()
return pdf
开发者ID:YousufNejati,项目名称:cspace_django_project,代码行数:35,代码来源:table.py
示例2: _createStyles
def _createStyles(self):
"""Método que cria um dicionário de estilos que serão utilizados para imprimir as informações"""
stylesDict = {}
styles = getSampleStyleSheet()
style = styles["Normal"]
style.fontName = "Helvetica"
style.leftIndent = 30
style.spaceAfter = 2
stylesDict.__setitem__("normal", style)
styles = getSampleStyleSheet()
stylesub = styles["Normal"]
stylesub.fontName = "Helvetica"
stylesub.leftIndent = 45
stylesub.spaceAfter = 2
stylesDict.__setitem__("subitem", stylesub)
styleh2 = styles["Heading2"]
styleh2.fontName = "Helvetica-Bold"
styleh2.textColor = "grey"
styleh2.spaceAfter = 2
stylesDict.__setitem__("category", styleh2)
styleh3 = styles["Heading3"]
styleh3.leftIndent = 15
styleh3.fontName = "Helvetica-Bold"
styleh3.spaceAfter = 2
stylesDict.__setitem__("device", styleh3)
return stylesDict
开发者ID:adrianomelo,项目名称:ldc-desktop,代码行数:31,代码来源:pdf_report.py
示例3: renderPDF
def renderPDF(self, data):
buff = StringIO.StringIO()
doc = SimpleDocTemplate(buff, pagesize=letter,
rightMargin=72, leftMargin=72,
topMargin=72, bottomMargin=18)
finished = data['finished']
running = data['running']
ready = data['ready']
Report = []
styles = getSampleStyleSheet()
style = getSampleStyleSheet()['Normal']
style.leading = 24
Report.append(Paragraph('Report on Campaign: ' + "MC16a", styles["Heading1"]))
Report.append(Paragraph('Build on ' + time.ctime() + " by BigPanDA", styles["Bullet"]))
Report.append(Paragraph('Progress and loads', styles["Heading2"]))
Report.append(Paragraph('Done events: ' + humanize.intcomma(int(finished/1000000)) +' M', styles["Normal"]))
Report.append(Paragraph('Running events: ' + humanize.intcomma(int(running)/1000000) +' M', styles["Normal"]))
Report.append(Paragraph('Ready for processing events: ' + humanize.intcomma(int(ready)/1000000) +' M', styles["Normal"]))
doc.build(Report)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="report.pdf"'
response.write(buff.getvalue())
buff.close()
return response
开发者ID:PanDAWMS,项目名称:panda-bigmon-core,代码行数:27,代码来源:MC16aCPReport.py
示例4: __addTable
def __addTable( self ):
tt = list()
if self.tipo == "ganancia":
data = self.DBM.getCuentas(self.data[0], self.data[1])
total = 0
tt.append( ['Fecha', 'Descripción', 'Cantidad', 'Precio'] )
for producto in data:
tt.append( [producto[0], producto[1], producto[2], "$ %.2f" % float( producto[4] ) ] )
total += float( producto[4] )
tt.append( ["TOTAL" , "", "", "$ %.2f" % total] )
elif self.tipo == "stock":
total = 0
tt.append( ['Código', 'Descripción', 'Marca', 'Precio', 'Punto Pedido', 'Stock'] )
for producto in self.data:
if producto[1] != '1000':
tt.append( [ producto[1], producto[2], producto[3], "$ %.2f" % float( producto[4] ), producto[5], producto[6] ] )
total += float( producto[4] * producto[6] )
tabla = Table(tt)
if self.tipo == "ganancia":
tabla.setStyle( TableStyle([
('ALIGN', (1,1), (-2, -2), 'RIGHT'),
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
('BOX', (0,0), (-1,-1), 0.55, colors.black),
('TEXTCOLOR',(0,-1),(-1,-1),colors.yellow),
('BACKGROUND',(0,-1),(-1,-1),colors.red),
('BACKGROUND',(0,0),(-1,0),colors.gray)
]))
elif self.tipo == "stock":
tabla.setStyle( TableStyle([
('ALIGN', (1,1), (-1, -1), 'RIGHT'),
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
('BOX', (0,0), (-1,-1), 0.55, colors.black),
('BACKGROUND',(0,0),(-1,0),colors.gray)
]))
self.elements.append( tabla )
if self.tipo == "ganancia":
styles = getSampleStyleSheet()
ptext = '<font size=10>Total de ventas: %s </font>' % len( data )
self.elements.append(Spacer(1, 12))
styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
self.elements.append( Paragraph(ptext, styles["Normal"]) )
elif self.tipo == "stock":
styles = getSampleStyleSheet()
ptext = '<font size=10>Productos en Stock: %s </font>' % len( self.data )
self.elements.append(Spacer(1, 12))
styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
self.elements.append( Paragraph(ptext, styles["Normal"]) )
styles = getSampleStyleSheet()
ptext = '<font size=10>Dinero en Stock: $ %.2f </font>' % total
styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
self.elements.append( Paragraph(ptext, styles["Normal"]) )
开发者ID:gaccardo,项目名称:canchas,代码行数:60,代码来源:Reporter.py
示例5: libro_memos
def libro_memos(request, memos):
''' Función para descarga de memorándums en PDF '''
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = u'attachment; filename=Memorándum.pdf; pagesize=A4'
elementos = []
doc = SimpleDocTemplate(response)
style = getSampleStyleSheet()
style2 = getSampleStyleSheet()
styleFecha = getSampleStyleSheet()
styleEncabezado = getSampleStyleSheet()
fechas = datetime.datetime.today()
mes = fecha.NormalDate().monthName()
dia = fecha.NormalDate().dayOfWeekName()
salto = '<br />'
txtFecha = '%s, %s DE %s DE %s'%(dia.upper(), fechas.day, mes.upper(), fechas.year)
styleF = styleFecha['Normal']
styleF.fontSize = 8
styleF.fontName = 'Helvetica'
styleF.alignment = TA_RIGHT
fechaV = Paragraph(txtFecha, styleF)
elementos.append(fechaV)
elementos.append(Spacer(1,5))
#-- Espacio para poner el encabezado con la clase Canvas
elementos.append(Spacer(1,75))
from django_messages.models import Message
# memo = Message.objects.filter(id=memos)
txtTitulo = u'MEMORÁNDUM%s' %(salto)
titulo = style['Heading1']
titulo.fontSize = 12
titulo.fontName = 'Helvetica-Bold'
titulo.alignment = TA_CENTER
tituloV = Paragraph(txtTitulo, titulo)
elementos.append(tituloV)
elementos.append(Spacer(1,5))
x = [
('BOX', (0,0), (-1,-1), 0.50, colors.black),
('ALIGN', (0,0), (-1,-1), 'LEFT'),
#('TOPPADDING', (0,0), (-1,-1), 1),
#('BOTTOMPADDING', (0,0), (-1,-1), 2),
('GRID', (0,0), (-1,-1), 0.50, colors.black),
#('FONT', (0,0), (-1,-1), "Helvetica", 8),
('FONT', (0,0), (-1,-1), "Helvetica", 6),
]
# Fin código de barras
#doc.build(elementos, canvasmaker=NumeroDePagina, onFirstPage=encabezado_constancia)
doc.build(elementos, canvasmaker=pieDePaginaConstancias, onFirstPage=encabezado_constancia)
return response
开发者ID:Axelio,项目名称:Umail,代码行数:56,代码来源:views.py
示例6: seatingChartByStudent
def seatingChartByStudent(request, id):
mealTime = models.MealTime.objects.get(pk=id)
allStudents = set(mealTime.allStudents())
seenStudents = set()
data = []
for tableAssignment in mealTime.tableassignment_set.all():
table = tableAssignment.table
student = tableAssignment.student
data.append((student.first_name, student.last_name, table.description))
seenStudents.add(student)
leftovers = [(s.first_name, s.last_name) for s in (allStudents - seenStudents)]
leftovers.sort(key=lambda s: (s[1], s[0]))
data.sort(key=lambda s: (s[1], s[0]))
normal = getSampleStyleSheet()["Normal"]
heading = getSampleStyleSheet()["Title"]
heading.fontSize = 40
story=[]
story.append(Paragraph(mealTime.name, heading))
story.append(FrameBreak())
story.append(NextPageTemplate("twoCol"))
for first, last, table in data:
story.append(Paragraph("%s %s: %s" % (first, last, table), normal))
out = BytesIO()
doc = BaseDocTemplate(out, pagesize=letter, author="Rectory School Seating Chart Generator", title=mealTime.name)
top = Frame(doc.leftMargin, doc.height, doc.width, 100)
frame1 = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height-75, id='col1')
frame2 = Frame(doc.leftMargin+doc.width/2+6, doc.bottomMargin, doc.width/2-6, doc.height-75, id='col2')
doc.addPageTemplates([PageTemplate(id='topColHeader',frames=[top, frame1,frame2]), ])
frame1 = Frame(doc.leftMargin, doc.bottomMargin, doc.width/2-6, doc.height, id='col1')
frame2 = Frame(doc.leftMargin+doc.width/2+6, doc.bottomMargin, doc.width/2-6, doc.height, id='col2')
doc.addPageTemplates([PageTemplate(id='twoCol',frames=[frame1,frame2]), ])
#start the construction of the pdf
doc.build(story)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'filename="{mealTime:} by student.pdf"'.format(mealTime=mealTime.name)
response.write(out.getvalue())
return response
开发者ID:rectory-school,项目名称:rectory-apps,代码行数:53,代码来源:display.py
示例7: generarPDFGrid
def generarPDFGrid(filename):
fondo = settings.STATIC_ROOT + '/img/plantillas_img_cuentas/'+filename
def myFirstPage(canvas, doc):
PAGE_HEIGHT,PAGE_WIDTH = letter
canvas.saveState()
canvas.drawImage(fondo, 0,0, PAGE_HEIGHT, PAGE_WIDTH )
canvas.setStrokeColorRGB(1,0,1,alpha=0.1)
#canvas.setPageSize(landscape(letter))
canvas.setFont('Arial', 10)
canvas.drawString(150, 579, "-")
SHOW_GRID = True
if SHOW_GRID:
n = 5
s = 200
#canvas.setStrokeGray(0.90)
#canvas.setFillGray(0.90)
canvas.setStrokeColorRGB(0,1,1,alpha=0.1)
canvas.setFillColorRGB(1,0,1)
canvas.setFont('Arial',1)
for x in range(s):
for y in range(s):
canvas.rect(x*n,y*n, width=n, height=n, stroke=1)
canvas.drawString(x*n,y*n,"%s,%s" % ((x*n),(y*n)) )
canvas.restoreState()
filename = "pdf_gen.pdf"
buff = StringIO()
styleSheet = getSampleStyleSheet()
doc = SimpleDocTemplate(buff, pagesize=letter,
rightMargin=40,leftMargin=40,
topMargin=72,bottomMargin=50)
Story = []
styles = getSampleStyleSheet()
styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
ptext = '''<font size=12>
</font>'''
Story.append(Paragraph(ptext, styles["Justify"]))
doc.build(Story, onFirstPage=myFirstPage) #, onLaterPages=myLaterPages)
fo = open(filename, "wb")
fo.write(buff.getvalue())
fo.close()
buff.close()
return filename
开发者ID:luissalamanca22,项目名称:dubs_django,代码行数:52,代码来源:services.py
示例8: __addHead
def __addHead( self ):
if self.tipo == "stock":
styles = getSampleStyleSheet()
ptext = '<font size=14>Reporte estado de Stock</font>'
styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
self.elements.append( Paragraph(ptext, styles["Normal"]) )
self.elements.append(Spacer(1, 12))
elif self.tipo == "ganancia":
styles = getSampleStyleSheet()
ptext = '<font size=14>Reporte de ganancias de Tifosi (%s, %s)</font>' % ( self.data[0], self.data[1] )
styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
self.elements.append( Paragraph(ptext, styles["Normal"]) )
self.elements.append(Spacer(1, 12))
开发者ID:gaccardo,项目名称:canchas,代码行数:14,代码来源:Reporter.py
示例9: estilos
def estilos(self, nombre):
if nombre == 'Estilo1':
estilo1 = getSampleStyleSheet()
estilo1.add(ParagraphStyle(name= 'Estilo1', fontName= "Helvetica", fontSize= 10, leading= 10, alignment= TA_CENTER))
estilo1 = estilo1['Estilo1']
estilo1.wordWrap = 'CJK'
elif nombre == 'Estilo2':
estilo1 = getSampleStyleSheet()
estilo1.add(ParagraphStyle(name= 'Estilo2', fontName= "Helvetica", fontSize= 10, leading= 10, wordWrap= 'CJK', alignment= TA_LEFT))
estilo1 = estilo1['Estilo2']
estilo1.wordWrap = 'CJK'
return estilo1
开发者ID:formijor,项目名称:Gestion-de-Altas,代码行数:14,代码来源:Impresion.py
示例10: setup_styles
def setup_styles(self):
# Build style sheets
s1, s2, s3 = getSampleStyleSheet(), getSampleStyleSheet(), getSampleStyleSheet()
self.sessionStyle, self.dateStyle = s1['Normal'], s2['Normal']
self.titleStyle = s3['Heading2']
self.titleStyle.alignment = TA_CENTER
self.dateStyle.backColor = colors.grey
self.dateStyle.textColor = colors.white
self.dateStyle.alignment = TA_CENTER
# Base table style
self.tableStyle = [
# Grid around the table
('GRID', (0,0), (-1,-1), 0.5, colors.black),
]
开发者ID:simongareste,项目名称:coach,代码行数:15,代码来源:pdf.py
示例11: make_suggested_starts
def make_suggested_starts(phage_genes, phage_name, file_path):
"""
Creates a PDF page of the suggested starts of a phage
Genes are list in order
{Gene Name} is a member of Pham {Number}: {Suggested Start Coordinates}
"""
file_name = os.path.join(file_path, "%sSuggestedStarts.pdf" % (phage_name))
if check_file(file_name):
return
doc = SimpleDocTemplate(file_name, pagesize=letter)
story = []
print "making suggested starts page"
styles = getSampleStyleSheet()
styles.add(ParagraphStyle(name="paragraph"))
styles.add(ParagraphStyle(name='Center', alignment=TA_CENTER))
text = '<font size=14> Suggested Start Coordinates</font>'
story.append(Paragraph(text, styles['Center']))
story.append(Spacer(1, 12))
for gene_id in sorted(phage_genes.iterkeys()):
phage_gene = phage_genes[gene_id]
pham = phage_gene["pham_no"]
gene = phage_gene["gene"]
suggested_start = phage_gene["suggested_start"]
if pham == None:
text = '<font size=12> %s is not a member of an existing Pham </font>' % (gene.gene_id)
else:
text = '<font size=12> %s is a member of Pham %s: %s </font>' % (gene.gene_id, pham, suggested_start)
story.append(Paragraph(text, styles['Normal']))
doc.build(story)
开发者ID:eddis,项目名称:starterator,代码行数:29,代码来源:making_files.py
示例12: generar_pdf_Producto
def generar_pdf_Producto(request):
response = HttpResponse(content_type='application/pdf')
pdf_name = "productos.pdf"
buff = BytesIO()
doc = SimpleDocTemplate(buff,
pagesize=letter,
rightMargin=40,
leftMargin=40,
topMargin=60,
bottomMargin=18,
)
productos = []
styles = getSampleStyleSheet()
header = Paragraph("Listado de Productos", styles['Heading1'])
productos.append(header)
headings = ('Proveedor','Nombre', 'Descripcion', 'Marca', 'Precio','Stock Actual')
allproductos = [(p.prov_id, p.pro_nom, p.pro_des, p.pro_mar, p.pro_pre, p.pro_sto_act) for p in Producto.objects.all()]
t = Table([headings] + allproductos)
t.setStyle(TableStyle(
[
('GRID', (0, 0), (6, -1), 1, colors.dodgerblue),
('LINEBELOW', (0, 0), (-1, 0), 2, colors.darkblue),
('BACKGROUND', (0, 0), (-1, 0), colors.dodgerblue)
]
))
productos.append(t)
doc.build(productos)
response.write(buff.getvalue())
buff.close()
return response
开发者ID:luis0794,项目名称:SIGIF,代码行数:32,代码来源:views.py
示例13: buildTable
def buildTable(data):
doc = SimpleDocTemplate("MOOSE_requirements_tracability.pdf", pagesize=A4, rightMargin=30,leftMargin=30, topMargin=30,bottomMargin=18)
doc.pagesize = landscape(A4)
elements = []
#Configure style and word wrap
s = getSampleStyleSheet()
s = s["BodyText"]
s.wordWrap = 'CJK'
pdf_data = [["Requirement", "Description", "Test Case(s)"]]
#TODO: Need a numerical sort here
keys = sorted(data.keys())
for key in keys:
data[key][2] = '\n'.join(data[key][2])
pdf_data.append([Paragraph(cell, s) for cell in data[key]])
# Build the Table and Style Information
tableThatSplitsOverPages = Table(pdf_data, repeatRows=1)
tableThatSplitsOverPages.hAlign = 'LEFT'
tblStyle = TableStyle([('TEXTCOLOR',(0,0),(-1,-1),colors.black),
('VALIGN',(0,0),(-1,-1),'TOP'),
('LINEBELOW',(0,0),(-1,-1),1,colors.black),
('INNERGRID', (0,0), (-1,-1),1,colors.black),
('BOX',(0,0),(-1,-1),1,colors.black),
('BOX',(0,0),(0,-1),1,colors.black)])
tblStyle.add('BACKGROUND',(0,0),(-1,-1),colors.lightblue)
tblStyle.add('BACKGROUND',(0,1),(-1,-1),colors.white)
tableThatSplitsOverPages.setStyle(tblStyle)
elements.append(tableThatSplitsOverPages)
doc.build(elements)
开发者ID:bggaston,项目名称:moose,代码行数:35,代码来源:tracability_matrix.py
示例14: outputtopdf
def outputtopdf(outputfile,title,labels,db,resdb):
import logging
log = logging.getLogger('outputtopdf')
try:
from reportlab.platypus import TableStyle, Table, SimpleDocTemplate, Paragraph
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.pdfgen import canvas
except ImportError:
log.error('Reportlab was not found. To export to pdf you need to have reportlab installed. Check out www.reportlab.org')
return
log.debug('ok reportlab library found')
styles = getSampleStyleSheet()
rows=list()
rows.append(labels)
for k in db.keys():
cols = [k,db[k]]
if resdb is not None:
if resdb.has_key(k):
cols.append(resdb[k])
else:
cols.append('N/A')
rows.append(cols)
t=Table(rows)
mytable = TableStyle([('BACKGROUND',(0,0),(-1,0),colors.black),
('TEXTCOLOR',(0,0),(-1,0),colors.white)])
t.setStyle(mytable)
doc = SimpleDocTemplate(outputfile)
elements = []
style = styles["Heading1"]
Title = Paragraph(title,style)
elements.append(Title)
elements.append(t)
doc.build(elements)
开发者ID:dohmatob,项目名称:organik,代码行数:34,代码来源:helper.py
示例15: subtitle_style
def subtitle_style(self):
styles = getSampleStyleSheet()
subtitle_style = styles["Heading2"]
subtitle_style.fontSize = 24
subtitle_style.leading = 26
subtitle_style.alignment = TA_CENTER
return subtitle_style
开发者ID:SexualHealthInnovations,项目名称:callisto-core,代码行数:7,代码来源:report_delivery.py
示例16: generar_pdf
def generar_pdf(request):
print ("Genero el PDF");
response = HttpResponse(content_type='application/pdf')
pdf_name = "proveedores.pdf" # llamado clientes
# la linea 26 es por si deseas descargar el pdf a tu computadora
# response['Content-Disposition'] = 'attachment; filename=%s' % pdf_name
buff = BytesIO()
doc = SimpleDocTemplate(buff,
pagesize=letter,
rightMargin=40,
leftMargin=40,
topMargin=60,
bottomMargin=18,
)
proveedores = []
styles = getSampleStyleSheet()
header = Paragraph("Listado de Proveedores", styles['Heading1'])
proveedores.append(header)
headings = ('No. Proveedor','Nombre','RFC','Giro','Direccion','Ciudad','Estado','Pais','Telefono','Correo','Comentario')
allproveedores = [(p.num_proveedor, p.nombre, p.RFC ,p.giro ,p.direccion ,p.ciudad ,p.estado ,p.pais ,p.telefono ,p.correo ,p.comentario) for p in Proveedor.objects.all()]
print (allproveedores);
t = Table([headings] + allproveedores)
t.setStyle(TableStyle(
[
('GRID', (0, 0), (12, -1), 1, colors.dodgerblue),
('LINEBELOW', (0, 0), (-1, 0), 2, colors.darkblue),
('BACKGROUND', (0, 0), (-1, 0), colors.dodgerblue)
]
))
proveedores.append(t)
doc.build(proveedores)
response.write(buff.getvalue())
buff.close()
return response
开发者ID:luis16k,项目名称:ticserp,代码行数:35,代码来源:views.py
示例17: getSampleStory
def getSampleStory(depth=3):
"""Makes a story with lots of paragraphs. Uses the random
TOC data and makes paragraphs to correspond to each."""
from reportlab.platypus.doctemplate import randomText
from random import randint
styles = getSampleStyleSheet()
TOCData = getSampleTOCData(depth)
story = [Paragraph("This is a demo of the table of contents object",
styles['Heading1'])]
toc = TableOfContents0() # empty on first pass
#toc.addEntries(TOCData) # init with random page numbers
story.append(toc)
# the next full page should switch to internal page style
story.append(NextPageTemplate("Body"))
# now make some paragraphs to correspond to it
for (level, text, pageNum) in TOCData:
if level == 0:
#page break before chapter
story.append(PageBreak())
headingStyle = (styles['Heading1'], styles['Heading2'], styles['Heading3'])[level]
headingPara = Paragraph(text, headingStyle)
story.append(headingPara)
# now make some body text
for i in range(randint(1,6)):
bodyPara = Paragraph(randomText(),
styles['Normal'])
story.append(bodyPara)
return story
开发者ID:BackupTheBerlios,项目名称:pixies-svn,代码行数:35,代码来源:tocindex.py
示例18: convertSourceFiles
def convertSourceFiles(filenames):
"Helper function - makes minimal PDF document"
from reportlab.platypus import Paragraph, SimpleDocTemplate, Spacer, XPreformatted
from reportlab.lib.styles import getSampleStyleSheet
styT=getSampleStyleSheet()["Title"]
styC=getSampleStyleSheet()["Code"]
doc = SimpleDocTemplate("pygments2xpre.pdf")
S = [].append
for filename in filenames:
S(Paragraph(filename,style=styT))
src = open(filename, 'r').read()
fmt = pygments2xpre(src)
S(XPreformatted(fmt, style=styC))
doc.build(S.__self__)
print('saved pygments2xpre.pdf')
开发者ID:AlexLai1990,项目名称:PythonExternalProgramTestFramework,代码行数:16,代码来源:pygments2xpre.py
示例19: print_rep
def print_rep(uid):
registerFont(TTFont('DroidSans', 'DroidSans.ttf'))
pdf = StringIO()
doc = SimpleDocTemplate(pdf, pagesize=A4)
elements = []
style = getSampleStyleSheet()
style.add(ParagraphStyle(name='Header', alignment=TA_LEFT,
fontName='DroidSans',
fontSize=14, leading=16))
style.add(ParagraphStyle(name='Left', alignment=TA_LEFT,
fontName='DroidSans',
fontSize=12))
style.add(ParagraphStyle(name='Right', alignment=TA_RIGHT,
fontName='DroidSans',
fontSize=12))
if uid == 0:
elements.append(Paragraph(u'<u>Users List</u>', style['Header']))
u = User.query.all()
for i, o in enumerate(u):
elements.append(Paragraph(u'%s. %s %s %s' % (i+1, o.name, o.email, o.progress), style['Left']))
else:
u = User.query.get(uid)
elements.append(Paragraph(u'%s %s %s' % (u.name, u.email, u.progress), style['Header']))
doc.build(elements)
pdf_file = pdf.getvalue()
pdf.close()
response = make_response(pdf_file)
response.headers['Content-Disposition'] = "attachment; filename='pdf_user.pdf"
response.mimetype = 'application/pdf'
return response
开发者ID:nisiotis,项目名称:flask_app_2,代码行数:34,代码来源:__init__.py
示例20: get_style
def get_style(self):
from reportlab.lib.styles import getSampleStyleSheet
styles = getSampleStyleSheet()
style = styles["Normal"]
style.fontName = 'OpenSans'
return style
开发者ID:JRodDynamite,项目名称:pretix,代码行数:7,代码来源:exporters.py
注:本文中的reportlab.lib.styles.getSampleStyleSheet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论