python reportlab调用操作分页报表
来源:互联网 发布:查询数据库密码 编辑:程序博客网 时间:2024/05/29 17:38
#coding=utf-8
def init_config():
import reportlab.rl_config
reportlab.rl_config.warnOnMissingFontGlyphs = 0
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import copy
pdfmetrics.registerFont(TTFont('zhenhei', 'D:/python_workspace/python_pdf_demo/wqy-zenhei.ttc'))
stylesheet= getSampleStyleSheet()
styles= copy.deepcopy(stylesheet['Normal'])
styles.fontName ='zhenhei'
styles.fontSize = 20
return styles
from reportlab.platypus import *
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import *
#from reportlab.lib.utils import *
from reportlab.lib.units import mm
styles=init_config()
PAGE_HEIGHT=defaultPageSize[1]
PAGE_WIDTH=defaultPageSize[0]
Title = "Hello world"
pageinfo = "platypus example"
def myFirstPage(canvas,doc):
canvas.saveState()
canvas.setFont('zhenhei',16)
canvas.drawCentredString(PAGE_HEIGHT/2, PAGE_HEIGHT-108, Title)
canvas.setFont('zhenhei',9)
canvas.drawString((PAGE_WIDTH/2)-20,10,u"首页")
canvas.restoreState()
def myLaterPages(canvas, doc):
canvas.saveState()
canvas.setFont('zhenhei', 9)
canvas.drawString((PAGE_WIDTH/2)-20,10,u"页码:%d 页" % (doc.page))
canvas.restoreState()
def go():
doc = SimpleDocTemplate("phello.pdf",pagesize=A4)
#Story = [Spacer(1,2*inch)]
#style = styles["Normal"]
i=0
I=Image("logo.jpg")
I.drawHeight = 1*inch*I.drawHeight / I.drawWidth
I.drawWidth = 1*inch
print doc.allowSplitting
Story=[]
for i in range(10):
Story.append(I)
Story.append(PageBreak())
#doc.build(Story)
doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)
'''for i in range(100):
I = Image("logo.jpg")
#print dir(I)
#vl=getImageData('logo.jpg')
#print vl
#I.drawWidth=
#I.drawHeight=str(I.imageHeight)+'px'
bogustext=(u"测试数字:%s."%i)
p = Paragraph(bogustext, styles)
Story.append(p)
Story.append(I)
Story.append(Spacer(1,0.2*inch))
doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages)
print i'''
if __name__ == "__main__":
# init_config()
go()
- python reportlab调用操作分页报表
- python reportlab 相对较为可用的正式报表
- python的reportlab安装及调用的问题
- python之reportlab
- Python使用ReportLab画图
- python之reportlab
- Python reportlab教程
- Python reportLab 生成PDF
- Python之ReportLab绘图
- Python--reportlab 下载
- python与reportlab类库技术用例-pdf报表1
- 学习利用ReportLab生成PDF报表 -- 图表
- windows: python 安装 reportlab 工具
- python绘图工具reportlab介绍
- python reportlab 生成pdf (一)
- python绘图工具reportlab介绍
- Python Reportlab 中Flowables 对象
- Python之ReportLab绘制文本
- 谷歌退出中国谁对谁错
- 五种提高 SQL 性能的方法 2
- 绝对有用的纯面试急用英语
- Windows的窗口、消息、子类化和超类化
- python与reportlab类库技术用例-pdf报表1
- python reportlab调用操作分页报表
- python reportlab 相对较为可用的正式报表
- webservice 之 soap 消息
- 一段debian 下面Iptables脚本控制ip访问的例子。
- 我的java之路
- zoj3204 Connect them
- VB6支持96个1的二进制与十进制的互相转换程序
- 增大肌肉块的14大秘诀
- lighttpd fastcgi配置例子和一些备份脚本